Debian Codegraph @

dojox/mvc/tests/doh/doh_mvc_programmatic-repeat-store.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>MVC DOH Test</title>
6
7 <style>
8 @import "../../../../dojo/resources/dojo.css";
9 @import "../../../../dijit/tests/css/dijitTests.css";
10 @import "../css/app-format.css";
11 </style>
12
13 <!-- required: the default dijit theme: -->
14 <link id="themeStyles" rel="stylesheet" href="../../../../dijit/themes/claro/claro.css"/>
15
16 <!-- required: dojo.js -->
17 <script src="../../../../dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: 0, isDebug: 1, mvc: {debugBindings: 1}"></script>
18 <script type="text/javascript" src="./helpers.js"></script>
19
20 <script type="text/javascript">
21 require([
22 "doh/runner",
23 "dojo/_base/declare",
24 "dojo/when",
25 "dojo/dom",
26 "dojo/parser",
27 "dojo/promise/all",
28 "dojo/store/JsonRest",
29 "dijit/registry",
30 "dijit/_WidgetBase",
31 "dojox/mvc/at",
32 "dojox/mvc/getStateful",
33 "dojox/mvc/EditModelRefController",
34 "dojox/mvc/ListController",
35 "dojox/mvc/Repeat",
36 "dijit/form/TextBox",
37 "dijit/form/Button",
38 "dojox/mvc/Group",
39 "dojo/domReady!"
40 ], function(doh, declare, when, ddom, parser, all, JsonRest, registry, _WidgetBase, at, getStateful, EditModelRefController, ListController, Repeat){
41
42 var ctrlClass = declare([_WidgetBase, EditModelRefController, ListController], {});
43 (ctrl = (new ctrlClass({srcNodeRef: ddom.byId("detailsGroup"), cursorIndex: 0}))).startup();
44
45 var repeatClass = declare("my.Repeat", Repeat, {
46 templateString: '<script type="dojo/require">at: "dojox/mvc/at"<\/script>'
47 + '<div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(\'rel:\', \'${this.index}\')">'
48 + '<label class="cell">Name:</label>'
49 + '<input id="${id}_textbox${index}" class="cell" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at(\'rel:\', \'First\')"></input>'
50 + '<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.set(\'cursorIndex\', \'${this.index}\'); }">Details</button>'
51 + '</div>'
52 });
53
54 (new repeatClass({children: at(ctrl, "model")}).placeAt('repeat2')).startup();
55
56 when(all([parser.parse(), new JsonRest({target: require.toUrl("dojox/mvc/tests/_data/mvcRepeatData.json")}).query({})]), function(a){
57 // ctrl.set("sourceModel", getStateful(a[1].items));
58
59 // should be able to verify all of the inputs
60 doh.register("Check values and bindings", [
61 {
62 name: "setup",
63 runTest: function(){
64 ctrl.set("sourceModel", getStateful(a[1].items));
65 }
66 }, {
67 name: "Initial",
68 runTest: function(){
69 doh.is("Anne", registry.byId("my_Repeat_0_textbox0").value, "textbox0 should be Anne");
70 doh.is("Anne", registry.byId("firstInput").value, "firstInput should be Anne");
71 }
72 }, {
73 name: "TestBen",
74 runTest: function(){
75 ctrl.set("cursorIndex", 1);
76 doh.is("Ben", registry.byId("my_Repeat_0_textbox1").value, "textbox1 should be Ben");
77 doh.is("Ben", registry.byId("firstInput").value, "firstInput should be Ben");
78 }
79 }, {
80 name: "TestJohn",
81 runTest: function(){
82 ctrl.set("cursorIndex", 9);
83 doh.is("John", registry.byId("my_Repeat_0_textbox9").value, "textbox9 should be John");
84 doh.is("John", registry.byId("firstInput").value, "firstInput should be John");
85
86 registry.byId("firstInput").set("value", "Johnny");
87
88 doh.is("Johnny", ctrl.get("model").get(9).get("First"), "First name of the 10th entry should be changed to Johnny");
89 }
90 }, {
91 name: "TestCommitReset",
92 runTest: function(){
93 ctrl.set("cursorIndex", 8);
94
95 doh.is("Irene", registry.byId("my_Repeat_0_textbox8").value, "textbox8 should be Irene");
96 doh.is("Irene", registry.byId("firstInput").value, "firstInput should be Irene");
97
98 registry.byId("firstInput").set("value", "IreneThisUpdateShouldBeSaved");
99
100 ctrl.commit();
101
102 registry.byId("lastInput").set("value", "IraThisUpdateShouldBeReset");
103
104 ctrl.reset();
105
106 doh.is("IreneThisUpdateShouldBeSaved", registry.byId("my_Repeat_0_textbox8").value, "textbox8 should be IreneThisUpdateShouldBeSaved");
107 doh.is("IreneThisUpdateShouldBeSaved", registry.byId("firstInput").value, "firstInput should be IreneThisUpdateShouldBeSaved");
108 doh.is("Ira", registry.byId("lastInput").value, "lastInput should be Ira");
109 }
110 }
111 ]);
112
113 doh.run();
114 });
115 });
116 </script>
117 </head>
118 <body class="claro">
119 <script type="dojo/require">at: "dojox/mvc/at"</script>
120 <h1 class="testTitle">doh_mvc_programmatic-repeat-store.html automated tests (non-robot)</h1>
121 <div id="wrapper">
122 <div id="header">
123 <div id="navigation"></div>
124 <div id="headerInsert">
125 <h2>Master Detail Example - With repeat container, using a store, with save, commit and reset.</h2>
126 </div>
127 </div>
128 <div id="main">
129 <div id="leftNav"></div>
130 <div id="mainContent">
131 <div id="searchBanner">Search Results for term: </div>
132 <table>
133 <tbody>
134 <tr>
135 <td>
136 <div>
137 <div>Programatic Repeat using my.Repeat and its templateString: </div>
138 <div id="repeat2"></div>
139 </div>
140 </td>
141 <td>
142 <div>
143 <div>Declarative Repeat using my.Repeat does not pass templateString: </div>
144 <div id="repeatId2" data-dojo-type="my.Repeat" data-dojo-props="children: at(ctrl, 'model')"></div>
145 </div>
146 </td>
147 </tr>
148 </tbody>
149 </table>
150 <div class="spacer"></div>
151 <div id="detailsBanner">Details for selected index:</div>
152 <div id="detailsGroup">
153 <div class="row">
154 <label class="cell" for="firstInput">First Name:</label>
155 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'First')"></input>
156 </div>
157 <div class="row">
158 <label class="cell" for="lastInput">Last Name:</label>
159 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Last')"></input>
160 </div>
161 <div class="row">
162 <label class="cell" for="locationInput">Location:</label>
163 <input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Location')"></input>
164 </div>
165 <div class="row">
166 <label class="cell" for="officeInput">Office:</label>
167 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Office')"></input>
168 </div>
169 <div class="row">
170 <label class="cell" for="emailInput">Email:</label>
171 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Email')"></input>
172 </div>
173 <div class="row">
174 <label class="cell" for="telInput">Telephone:</label>
175 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Tel')"></input>
176 </div>
177 <div class="row">
178 <label class="cell" for="faxInput">Fax:</label>
179 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Fax')"></input>
180 </div>
181 <div class="row">
182 <div class="spacer"></div>
183 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.commit();}">Commit All</button>
184 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset to last saved</button>
185 </div>
186 </div>
187 </div>
188 </div>
189 </div>
190 </body>
191 </html>