Debian Codegraph @

dojox/mvc/tests/test_mvc_search-results-ins-del.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>Static Master/Detail Pattern -- Search Results example</title>
6 <script src="../../../dojo/dojo.js" type="text/javascript"
7 data-dojo-config="parseOnLoad: 0, isDebug: true, mvc: {debugBindings: true}">
8 </script>
9 <style type="text/css">
10 @import "css/app-format.css";
11 @import "../../../dijit/themes/claro/claro.css";
12 </style>
13 <script type="text/javascript">
14 var data = [
15 {
16 id: "1",
17 Group: "Engineer",
18 First: "Anne",
19 Last: "Ackerman",
20 Location: "NY",
21 Office: "1S76",
22 Email: "[email protected]",
23 Tel: "123-764-8237",
24 Fax: "123-764-8228"
25 },
26 {
27 id: "2",
28 Group: "Engineer",
29 First: "Ben",
30 Last : "Beckham",
31 Location: "NY",
32 Office: "5N47",
33 Email: "[email protected]",
34 Tel: "123-764-8599",
35 Fax: "123-764-8600"
36 },
37 {
38 id: "3",
39 Group: "Engineer",
40 First: "Chad",
41 Last: "Chapman",
42 Location: "CA",
43 Office: "1278",
44 Email: "[email protected]",
45 Tel: "408-764-8237",
46 Fax: "408-764-8228"
47 },
48 {
49 id: "4",
50 Group: "Engineer",
51 First: "David",
52 Last: "Durham",
53 Location: "NJ",
54 Office: "C12",
55 Email: "[email protected]",
56 Tel: "514-764-8237",
57 Fax: "514-764-8228"
58 },
59 {
60 id: "5",
61 Group: "Engineer",
62 First: "Emma",
63 Last: "Eklof",
64 Location: "NY",
65 Office: "4N76",
66 Email: "[email protected]",
67 Tel: "123-764-1234",
68 Fax: "123-764-4321"
69 },
70 {
71 id: "6",
72 Group: "Manager",
73 First: "Fred",
74 Last: "Fisher",
75 Location: "NJ",
76 Office: "V89",
77 Email: "[email protected]",
78 Tel: "514-764-8567",
79 Fax: "514-764-8000"
80 },
81 {
82 id: "7",
83 Group: "Manager",
84 First: "George",
85 Last: "Garnett",
86 Location: "NY",
87 Office: "7S11",
88 Email: "[email protected]",
89 Tel: "123-999-8599",
90 Fax: "123-999-8600"
91 },
92 {
93 id: "8",
94 Group: "Accountant",
95 First: "Hunter",
96 Last: "Huffman",
97 Location: "CA",
98 Office: "6532",
99 Email: "[email protected]",
100 Tel: "408-874-8237",
101 Fax: "408-874-8228"
102 },
103 {
104 id: "9",
105 Group: "Accountant",
106 First: "Irene",
107 Last: "Ira",
108 Location: "NJ",
109 Office: "F09",
110 Email: "[email protected]",
111 Tel: "514-764-6532",
112 Fax: "514-764-7300"
113 },
114 {
115 id: "10",
116 Group: "Accountant",
117 First: "John",
118 Last: "Jacklin",
119 Location: "CA",
120 Office: "6701",
121 Email: "[email protected]",
122 Tel: "408-764-1234",
123 Fax: "408-764-4321"
124 }
125 ], ctrl;
126
127 require([
128 "dojo/_base/declare",
129 "dojo/when",
130 "dojo/parser",
131 "dojo/Stateful",
132 "dojo/store/Memory",
133 "dojox/mvc/EditStoreRefListController",
134 "dijit/form/Button",
135 "dijit/form/TextBox",
136 "dijit/form/ComboBox",
137 "dojox/mvc/Group",
138 "dojox/mvc/Output",
139 "dojox/mvc/Repeat",
140 "dojo/domReady!"
141 ], function(declare, when, parser, Stateful, Memory, EditStoreRefListController){
142
143 var inited,
144 ctrlClass = declare([EditStoreRefListController], {
145 cursorIndex: 0,
146 group: "",
147 groupTyped: "",
148 _refModelProp: "model",
149
150 addEmpty: function(){
151 this.model.push(new Stateful({id:Math.random(), Group: this.groupTyped, First: "", Last: "", Location: "", Office: "", Email: "", Tel: "", Fax: ""}));
152 this.set("cursorIndex", this.get("length") - 1);
153 },
154
155 remove: function(idx){
156 this.model.splice(idx, 1);
157 if(this.get("cursorIndex") < 0){
158 this.set("cursorIndex", this.get("length") - 1);
159 }
160 },
161
162 _setGroupAttr: function(value){
163 this.set("groupTyped", value);
164 var old = this.group;
165 if(old === value){ return; }
166 when(this.queryStore({Group: value}), function(){
167 if(!inited){
168 parser.parse();
169 inited = true;
170 }
171 });
172 this._set("group", value);
173 }
174 });
175
176 ctrl = new ctrlClass({store: new Memory({data: data})});
177 ctrl.set("group", "Engineer");
178 });
179 </script>
180 </head>
181 <body class="claro" style="background-image: url(images/master_detail.png)">
182 <script type="dojo/require">at: "dojox/mvc/at"</script>
183 <div id="wrapper">
184 <div id="header">
185 <div id="navigation"></div>
186 <div id="headerInsert">
187 <h1>Employee Search</h1>
188 <h2>Master Detail Example - Repeat with insert and delete.</h2>
189 </div>
190 </div>
191 <div id="main">
192 <div id="leftNav"></div>
193 <div id="mainContent">
194 <div class="row">
195 <div class="spacer"></div>
196 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.commit(); }">Commit All</button>
197 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset to last saved</button>
198 </div>
199 <div class="spacer"></div>
200 <div>
201 Try "Engineer", "Manager", or "Accountant":
202 </div>
203 <div class="row">
204 <label class="cell" for="queryInput">Search for:</label>
205 <!-- <input class="cell" id="queryInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at(ctrl, 'groupTyped')"> -->
206 <select id="setvaluetest" data-dojo-type="dijit.form.ComboBox" data-dojo-props="value: at(ctrl, 'groupTyped')">
207 <option value="Engineer">Engineer</option>
208 <option value="Manager">Manager</option>
209 <option value="Accountant">Accountant</option>
210 </select>
211 <button type="button" data-dojo-type="dijit.form.Button"
212 data-dojo-props="onClick: function(){ ctrl.set('group', ctrl.get('groupTyped')); }">Search</button>
213 </div>
214 <div class="spacer"></div>
215 <div id="searchBanner">
216 Search Results for group: <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(ctrl, 'group')"></span>
217 </div>
218 <div data-dojo-type="dojox.mvc.Repeat" data-dojo-props="children: at(ctrl, 'model')">
219 <div class="row" data-dojo-type="dijit._WidgetBase" data-dojo-props="target: at('rel:', ${this.index})">
220 <label class="cell" for="nameInput${this.index}">Name:</label>
221 <input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}"
222 data-dojo-props="value: at('rel:', 'First')">
223 <button type="button" data-dojo-type="dijit.form.Button"
224 data-dojo-props="onClick: function(){ ctrl.set('cursorIndex', ${this.index}); }">Details</button>
225 <button type="button" data-dojo-type="dijit.form.Button"
226 data-dojo-props="onClick: function(){ ctrl.addEmpty(); }">+</button>
227 <button type="button" data-dojo-type="dijit.form.Button"
228 data-dojo-props="onClick: function(){ ctrl.remove(${index}); }">-</button>
229 </div>
230 </div>
231 <div class="spacer"></div>
232 <div id="detailsBanner">
233 Details for result index:
234 <span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(ctrl, 'cursorIndex')"></span>
235 </div>
236 <div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'cursor')">
237 <div class="row">
238 <label class="cell" for="firstInput">First Name:</label>
239 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'First')">
240 </div>
241 <div class="row">
242 <label class="cell" for="lastInput">Last Name:</label>
243 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Last')">
244 </div>
245 <div class="row">
246 <label class="cell" for="locationInput">Location:</label>
247 <input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Location')">
248 </div>
249 <div class="row">
250 <label class="cell" for="officeInput">Office:</label>
251 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Office')">
252 </div>
253 <div class="row">
254 <label class="cell" for="emailInput">Email:</label>
255 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Email')">
256 </div>
257 <div class="row">
258 <label class="cell" for="telInput">Telephone:</label>
259 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Tel')">
260 </div>
261 <div class="row">
262 <label class="cell" for="faxInput">Fax:</label>
263 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Fax')">
264 </div>
265 </div>
266 </div>
267 </div>
268 </div>
269 </body>
270 </html>