Debian Codegraph @

dojox/mvc/tests/1.7/doh/doh_mvc_search-results-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"
18 djConfig="parseOnLoad: false, isDebug: true">
19 </script>
20 <script type="text/javascript" src="../helpers.js"></script>
21
22 <script type="text/javascript" >
23 dojo.require("dojox.mvc");
24 dojo.require("dojox.mvc.Group");
25 dojo.require("dojox.mvc.Repeat");
26 dojo.require("dijit.form.TextBox");
27 dojo.require("dijit.form.Button");
28 dojo.require("dojo.data.ItemFileWriteStore");
29 dojo.require("dojo.store.DataStore");
30 dojo.require("dojo.parser");
31
32 var results, selectedIndex = 0;
33
34 function setup() {
35 var writeStore = new dojo.data.ItemFileWriteStore({url: dojo.moduleUrl("dojox.mvc.tests._data", "mvcRepeatData.json")});
36 var modelPromise = dojox.mvc.newStatefulModel({store: new dojo.store.DataStore({store: writeStore})});
37 modelPromise.then(function(model){
38 results = model;
39 dojo.parser.parse();
40 startTests();
41 });
42 };
43
44 dojo.addOnLoad(setup);
45 </script>
46
47 <script type="text/javascript">
48 dojo.require('doh.runner');
49 dojo.require("dijit.dijit"); // optimize: load dijit layer
50 dojo.require("dojo.parser"); // scan page for widgets and instantiate them
51 function startTests(){
52 // should be able to verify all of the inputs
53 doh.register("Check initial values and bindings", [
54 {
55 name: "initial",
56 runTest: function(){
57 var name1, bind1, firstInput;
58 name1 = dijit.byId("nameInput0");
59 if (name1) {
60 bind1 = name1.get("binding");
61 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
62 doh.is("Anne",bind1.data,"bind1.data should be set");
63 doh.is("Anne",bind1.value,"bind1.value should be set");
64 }
65 }
66
67 firstInput = dijit.byId("firstInput");
68 if (firstInput) {
69 bind1 = firstInput.get("binding");
70 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
71 doh.is("Anne",bind1.data,"bind1.data should be set");
72 doh.is("Anne",bind1.value,"bind1.value should be set");
73 }
74 }
75 }
76 }
77 ]);
78
79 doh.register("select Ben", [
80 {
81 name: "testBen",
82 runTest: function(){
83 setDetailsContext(1);
84 var name1, bind1, firstInput;
85 name1 = dijit.byId("nameInput1");
86 if (name1) {
87 bind1 = name1.get("binding");
88 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
89 doh.is("Ben",bind1.data,"bind1.data is wrong");
90 doh.is("Ben",bind1.value,"bind1.value is wrong");
91 }
92 }
93
94 firstInput = dijit.byId("firstInput");
95 if (firstInput) {
96 bind1 = firstInput.get("binding");
97 if (bind1 && bind1.isInstanceOf(dojox.mvc.StatefulModel)) {
98 console.debug("firstInput.value="+firstInput.value);
99 doh.is("Ben",bind1.data,"firstInput bind1.data is wrong");
100 doh.is("Ben",bind1.value,"firstInput bind1.value is wrong");
101 }
102 }
103 }
104 }
105 ]);
106
107
108 doh.register("select John and update John to Johnny test valueOf and toString", [
109 {
110 name: "testJohn",
111 runTest: function(){
112 setDetailsContext(9); //select John
113 var name9, bind9, firstInput;
114 name9 = dijit.byId("nameInput9");
115 if (name9) {
116 bind9 = name9.get("binding");
117 if (bind9 && bind9.isInstanceOf(dojox.mvc.StatefulModel)) {
118 doh.is("John",bind9.data,"bind9.data is wrong");
119 doh.is("John",bind9.value,"bind9.value is wrong");
120 doh.is("John",bind9.valueOf(),"bind9.valueOf() is wrong");
121 doh.is("John",bind9.toString(),"bind9.toString() is wrong");
122 }
123 }
124
125 firstInput = dijit.byId("firstInput");
126 dojo.byId("firstInput").focus();
127 firstInput.set('value',"Johnny");
128 dojo.byId("lastInput").focus();
129
130 if (firstInput) {
131 bind9 = firstInput.get("binding");
132 if (bind9 && bind9.isInstanceOf(dojox.mvc.StatefulModel)) {
133 doh.is("Johnny",bind9.value,"firstInput bind9.value is wrong");
134 doh.is("Johnny",firstInput.value,"firstInput firstInput.value is wrong");
135 doh.is("Johnny",bind9.valueOf(),"firstInput bind9.valueOf() is wrong");
136 doh.is("Johnny",bind9.toString(),"firstInput bind9.toString() is wrong");
137 }
138 }
139
140 // Test the value of and toString
141 valueOfTest = new dojox.mvc.StatefulModel({ data: 42 });
142 doh.is(42,valueOfTest.data,"valueOfTest.data is wrong");
143 doh.is(42,valueOfTest.value,"valueOfTest.value is wrong");
144 doh.is(42,+valueOfTest,"valueOfTest.valueOf() is wrong");
145 doh.is("42",'' + valueOfTest,"valueOfTest.toString() is wrong");
146
147 toStringTest = new dojox.mvc.StatefulModel({ data: 'abc' });
148 doh.is('abc',toStringTest.data,"toStringTest.data is wrong");
149 doh.is('abc',toStringTest.value,"toStringTest.value is wrong");
150 doh.is(NaN,+toStringTest,"toStringTest.valueOf() is wrong");
151 doh.is('abc','' + toStringTest,"toStringTest.toString() is wrong")
152
153
154 }
155 }
156 ]);
157
158 doh.register("test Commit and Reset", [
159 {
160 name: "testC&R",
161 runTest: function(){
162 setDetailsContext(8); //select Irene
163 var name8, bind8, firstInput, lastInput;
164 name8 = dijit.byId("nameInput8");
165 if (name8) {
166 bind8 = name8.get("binding");
167 if (bind8 && bind8.isInstanceOf(dojox.mvc.StatefulModel)) {
168 doh.is("Irene",bind8.data,"bind8.data is wrong");
169 doh.is("Irene",bind8.value,"bind8.value is wrong");
170 }
171 }
172
173 //update Irene to IreneThisUpdateShouldBeSaved and commit
174 firstInput = dijit.byId("firstInput");
175 dojo.byId("firstInput").focus();
176 firstInput.set("value","IreneThisUpdateShouldBeSaved");
177 dojo.byId("lastInput").focus();
178 results.commit();
179
180 lastInput = dijit.byId("lastInput");
181 dojo.byId("lastInput").focus();
182 lastInput.set("value", "IraThisUpdateShouldBeReset");
183 dojo.byId("firstInput").focus();
184 results.reset();
185
186 if (firstInput) {
187 bind8 = firstInput.get("binding");
188 if (bind8 && bind8.isInstanceOf(dojox.mvc.StatefulModel)) {
189 doh.is("IreneThisUpdateShouldBeSaved",bind8.value,"firstInput bind8.value is wrong");
190 doh.is("IreneThisUpdateShouldBeSaved",firstInput.value,"firstInput firstInput.value is wrong");
191 doh.is("Ira",lastInput.value,"lastInput lastInput.value is wrong");
192 }
193 }
194 }
195 }
196 ]);
197
198 doh.run();
199 };
200 </script>
201 </head>
202 <body class="claro">
203 <h1 class="testTitle">doh_mvc_search-results-repeat-store.html automated tests (non-robot)</h1>
204 <div id="wrapper">
205 <div id="header">
206 <div id="navigation"></div>
207 <div id="headerInsert">
208 <h1>Employee Search</h1>
209 <h2>Master Detail Example - With repeat container.</h2>
210 </div>
211 </div>
212 <div id="main">
213 <div id="leftNav"></div>
214 <div id="mainContent">
215 <!--
216 The repeat container denotes a templated UI that operates over a collection
217 of data records.
218 The UI can be customized for each iteration using properties such as
219 ${this.index} for the iteration index.
220 -->
221 <div id="repeatId" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'results'">
222 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'">
223 <label class="cell" for="nameInput${this.index}">Name:</label>
224 <input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"/>
225 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button>
226 </div>
227 </div>
228 <div class="spacer"></div>
229 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'results'">
230 <div id="detailsBanner">Details for selected index:</div>
231 <div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'">
232 <div class="row">
233 <label class="cell" for="firstInput">First Name:</label>
234 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"/>
235 </div>
236 <div class="row">
237 <label class="cell" for="lastInput">Last Name:</label>
238 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"/>
239 </div>
240 <div class="row">
241 <label class="cell" for="locationInput">Location:</label>
242 <input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"/>
243 </div>
244 <div class="row">
245 <label class="cell" for="officeInput">Office:</label>
246 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"/>
247 </div>
248 <div class="row">
249 <label class="cell" for="emailInput">Email:</label>
250 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"/>
251 </div>
252 <div class="row">
253 <label class="cell" for="telInput">Telephone:</label>
254 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"/>
255 </div>
256 <div class="row">
257 <label class="cell" for="faxInput">Fax:</label>
258 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"/>
259 </div>
260 <div class="row">
261 <div class="spacer"></div>
262 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){results.commit();}">Commit</button>
263 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){results.reset();}">Reset</button>
264 </div>
265 </div>
266 </div>
267 </div>
268 </div>
269 </div>
270 <script type="text/javascript">
271 function setDetailsContext(index) {
272 selectedIndex = index;
273 var widget = dijit.byId("detailsGroup");
274 widget.set("ref", index);
275 }
276 </script>
277 </body>
278 </html>