Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat #921 aria:List widget refresh on datamodel change
Now when you use aria.utils.Json.add and aria.utils.Json.removeAt functions to add items to an aria:List widget (or to remove one), the list template is refreshed and it displays the new item.
- Loading branch information
Showing
7 changed files
with
225 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,83 @@ | |||
/* | |||
* Copyright 2012 Amadeus s.a.s. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
Aria.classDefinition({ | |||
$classpath : "test.aria.widgets.form.list.ListTestCase", | |||
$extends : "aria.jsunit.TemplateTestCase", | |||
$dependencies : ["aria.utils.Json"], | |||
$constructor : function () { | |||
this.$TemplateTestCase.constructor.call(this); | |||
this.listContainer = null; | |||
this.children = null; | |||
this.data = { | |||
italian : [{ value: "D", label: "Donizetti"}, { value: "B", label: "Bellini" }, { value: "V", label: "Verdi" }] | |||
}; | |||
this.setTestEnv({ | |||
template : "test.aria.widgets.form.list.ListTestCaseTpl", | |||
data : this.data | |||
}); | |||
}, | |||
$destructor : function () { | |||
this.listContainer = null; | |||
this.children = null; | |||
this.$TemplateTestCase.$destructor.call(this); | |||
}, | |||
$prototype : { | |||
runTemplateTest : function () { | |||
this.listContainer = this.getWidgetDomElement("myId", "div"); | |||
this.children = this.getElementsByClassName(this.listContainer, "xListEnabledItem_std"); | |||
|
|||
this.assertTrue(this.children.length === 3, "The number of list items is not 3"); | |||
|
|||
if (aria.core.Browser.isIE && aria.core.Browser.majorVersion < 9) { | |||
aria.core.Timer.addCallback({ | |||
fn: this.waitForIE, | |||
scope: this, | |||
delay: 500 | |||
}); | |||
} else { | |||
this.addItem(); | |||
this.assertTrue(this.children.length === 4, "The item was not added to the DOM"); | |||
|
|||
this.removeItem(); | |||
this.assertTrue(this.children.length === 3, "The item was not removed from the DOM"); | |||
|
|||
this.notifyTemplateTestEnd(); | |||
} | |||
}, | |||
|
|||
waitForIE : function () { | |||
this.addItem(); | |||
this.listContainer = this.getWidgetDomElement("myId", "div"); | |||
this.children = this.getElementsByClassName(this.listContainer, "xListEnabledItem_std"); | |||
this.assertTrue(this.children.length === 4, "The item was not added to the DOM"); | |||
|
|||
this.removeItem(); | |||
this.listContainer = this.getWidgetDomElement("myId", "div"); | |||
this.children = this.getElementsByClassName(this.listContainer, "xListEnabledItem_std"); | |||
this.assertTrue(this.children.length === 3, "The item was not removed from the DOM"); | |||
|
|||
this.notifyTemplateTestEnd(); | |||
}, | |||
|
|||
addItem : function () { | |||
aria.utils.Json.add(this.data.italian, { value: "p", label: "Puccini"}); | |||
}, | |||
|
|||
removeItem : function () { | |||
aria.utils.Json.removeAt(this.data.italian, 3); | |||
} | |||
} | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
/* | |||
* Copyright 2012 Amadeus s.a.s. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
{Template { | |||
$classpath : "test.aria.widgets.form.list.ListTestCaseTpl", | |||
$templates : ["aria.widgets.form.list.templates.ListTemplate"] | |||
}} | |||
|
|||
{macro main()} | |||
|
|||
<div id="justToGetTheCorrectDom"> | |||
|
|||
<p>List of Italian composers (bound to data model):</p> | |||
{@aria:List { | |||
id: "myId", | |||
minWidth:200, | |||
bind: { | |||
items: { | |||
to: "italian", | |||
inside: data | |||
} | |||
} | |||
}/} | |||
|
|||
</div> | |||
|
|||
{/macro} | |||
{/Template} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
/* | |||
* Copyright 2012 Amadeus s.a.s. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
Aria.classDefinition({ | |||
$classpath : "test.aria.widgets.form.list.ListTestSuite", | |||
$extends : "aria.jsunit.TestSuite", | |||
$constructor : function () { | |||
this.$TestSuite.constructor.call(this); | |||
this.addTests("test.aria.widgets.form.list.ListControllerTest"); | |||
this.addTests("test.aria.widgets.form.list.ListTestCase"); | |||
} | |||
}); |