Debian Codegraph @

dojox/mvc/tests/1.7/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
7 <script src="../../../../dojo/dojo.js"
8 type="text/javascript"
9 djConfig="parseOnLoad: true, isDebug: true">
10 </script>
11 <style type="text/css">
12 @import "css/app-format.css";
13 @import "../../../../dijit/themes/claro/claro.css";
14 </style>
15 <script type="text/javascript">
16 dojo.require("dojox.mvc");
17 dojo.require("dojox.mvc.Group");
18 dojo.require("dojox.mvc.Repeat");
19 dojo.require("dijit.form.TextBox");
20 dojo.require("dijit.form.Button");
21 dojo.require("dojo.parser");
22
23 // Initial raw records for the master detail
24 var search_results_init =
25 {
26 "Query" : "Engineers",
27 "Results" : [
28 {
29 "First" : "Anne",
30 "Last" : "Ackerman",
31 "Location": "NY",
32 "Office" : "1S76",
33 "Email" : "[email protected]",
34 "Tel" : "123-764-8237",
35 "Fax" : "123-764-8228"
36 },
37 {
38 "First" : "Ben",
39 "Last" : "Beckham",
40 "Location": "NY",
41 "Office" : "5N47",
42 "Email" : "[email protected]",
43 "Tel" : "123-764-8599",
44 "Fax" : "123-764-8600"
45 },
46 {
47 "First" : "Chad",
48 "Last" : "Chapman",
49 "Location": "CA",
50 "Office" : "1278",
51 "Email" : "[email protected]",
52 "Tel" : "408-764-8237",
53 "Fax" : "408-764-8228"
54 },
55 {
56 "First" : "David",
57 "Last" : "Durham",
58 "Location": "NJ",
59 "Office" : "C12",
60 "Email" : "[email protected]",
61 "Tel" : "514-764-8237",
62 "Fax" : "514-764-8228"
63 },
64 {
65 "First" : "Emma",
66 "Last" : "Eklof",
67 "Location": "NY",
68 "Office" : "4N76",
69 "Email" : "[email protected]",
70 "Tel" : "123-764-1234",
71 "Fax" : "123-764-4321"
72 },
73 {
74 "First" : "Fred",
75 "Last" : "Fisher",
76 "Location": "NJ",
77 "Office" : "V89",
78 "Email" : "[email protected]",
79 "Tel" : "514-764-8567",
80 "Fax" : "514-764-8000"
81 },
82 {
83 "First" : "George",
84 "Last" : "Garnett",
85 "Location": "NY",
86 "Office" : "7S11",
87 "Email" : "[email protected]",
88 "Tel" : "123-999-8599",
89 "Fax" : "123-999-8600"
90 },
91 {
92 "First" : "Hunter",
93 "Last" : "Huffman",
94 "Location": "CA",
95 "Office" : "6532",
96 "Email" : "[email protected]",
97 "Tel" : "408-874-8237",
98 "Fax" : "408-874-8228"
99 },
100 {
101 "First" : "Irene",
102 "Last" : "Ira",
103 "Location": "NJ",
104 "Office" : "F09",
105 "Email" : "[email protected]",
106 "Tel" : "514-764-6532",
107 "Fax" : "514-764-7300"
108 },
109 {
110 "First" : "John",
111 "Last" : "Jacklin",
112 "Location": "CA",
113 "Office" : "6701",
114 "Email" : "[email protected]",
115 "Tel" : "408-764-1234",
116 "Fax" : "408-764-4321"
117 }
118 ]
119 };
120
121 // The dojox.mvc.StatefulModel class creates a data model instance
122 // where each leaf within the data model is decorated with dojo.Stateful
123 // properties that widgets can bind to and watch for their changes.
124 var searchRecords = dojox.mvc.newStatefulModel({ data : search_results_init });
125 </script>
126 </head>
127 <body class="claro" style="background-image: url(images/master_detail.png)">
128 <div id="wrapper">
129 <div id="header">
130 <div id="navigation">
131 </div>
132 <div id="headerInsert">
133 <h1>Employee Search</h1>
134 <h2>Master Detail Example - Repeat with insert and delete.</h2>
135 </div>
136 </div>
137 <div id="main">
138 <div id="leftNav">
139 </div>
140 <div id="mainContent">
141 <div class="row">
142 <div class="spacer"></div>
143 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){console.log(searchRecords.Results.toPlainObject());searchRecords.Results.commit();;}">Commit All</button>
144 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){searchRecords.Results.reset();}">Reset to last saved</button>
145 </div>
146 <!--
147 The group container denotes some logical grouping of widgets and also serves
148 to establish a parent data binding context for its children.
149 The ref attribute for the outermost container obtains the binding from the
150 "page scope" itself.
151 -->
152 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'searchRecords'">
153 <div class="row">
154 <label class="cell" for="queryInput">Search for:</label>
155 <input class="cell" id="queryInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Query'"/>
156 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setSearchBanner();}">Search</button>
157 </div>
158 <div class="spacer"></div>
159
160 <div id="searchBanner">Search Results for term: Engineers</div>
161
162 <!--
163 The repeat container denotes a templated UI that operates over a collection
164 of data records.
165 The UI can be customized for each iteration using properties such as
166 ${this.index} for the iteration index.
167 -->
168 <div data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'Results'">
169 <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'">
170 <label class="cell" for="nameInput${this.index}">Name:</label>
171 <input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"/>
172 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button>
173 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){insertResult('${this.index}');}">+</button>
174 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){deleteResult('${this.index}');}">-</button>
175 </div>
176 </div>
177 <div class="spacer"></div>
178
179 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'Results'">
180 <div id="detailsBanner">Details for result index: 0</div>
181
182 <div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'">
183 <div class="row">
184 <label class="cell" for="firstInput">First Name:</label>
185 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"/>
186 </div>
187 <div class="row">
188 <label class="cell" for="lastInput">Last Name:</label>
189 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"/>
190 </div>
191 <div class="row">
192 <label class="cell" for="locationInput">Location:</label>
193 <input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"/>
194 </div>
195 <div class="row">
196 <label class="cell" for="officeInput">Office:</label>
197 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"/>
198 </div>
199 <div class="row">
200 <label class="cell" for="emailInput">Email:</label>
201 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"/>
202 </div>
203 <div class="row">
204 <label class="cell" for="telInput">Telephone:</label>
205 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"/>
206 </div>
207 <div class="row">
208 <label class="cell" for="faxInput">Fax:</label>
209 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"/>
210 </div>
211 </div>
212 </div>
213 </div>
214 </div>
215 </div>
216 <script type="text/javascript">
217 function setDetailsContext(index) {
218 var widget = dijit.byId("detailsGroup");
219 widget.set("ref", index);
220 var detailsBanner = dojo.byId("detailsBanner");
221 detailsBanner.innerHTML = "Details for result index: " + index;
222 }
223 function insertResult(index) {
224 var insert = dojox.mvc.newStatefulModel({ "data" : {
225 "First" : "",
226 "Last" : "",
227 "Location": "",
228 "Office" : "",
229 "Email" : "",
230 "Tel" : "",
231 "Fax" : ""
232 } });
233 searchRecords.Results.add(parseInt(index)+1, insert);
234 }
235 function deleteResult(index) {
236 searchRecords.Results.remove(index);
237 }
238 function setSearchBanner() {
239 var searchBanner = dojo.byId("searchBanner");
240 searchBanner.innerHTML = "Search Results for term: " + searchRecords.Query.get("value");
241 }
242 </script>
243 </body>
244 </html>