Debian Codegraph @

dojox/mvc/tests/test_mvc_search-results-repeat-store.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html style="width: 100%; height: 100%;">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>Dojo Repeat Selection Test</title>
6
7 <style type="text/css">
8 @import "../../../dijit/themes/dijit.css";
9 @import "../../../dijit/themes/claro/document.css";
10 @import "../../../dijit/tests/css/dijitTests.css";
11 @import "css/app-format.css";
12 </style>
13
14 <!-- required: a default dijit theme: -->
15 <link id="themeStyles" rel="stylesheet"
16 href="../../../dijit/themes/claro/claro.css" />
17
18
19 <!-- required: dojo.js -->
20 <script type="text/javascript" src="../../../dojo/dojo.js"
21 data-dojo-config="isDebug: true, async: true, parseOnLoad: false, mvc: {debugBindings: true}"></script>
22
23 <script type="text/javascript">
24 var results, savedData;
25 require([
26 "dojo/parser",
27 "dijit/registry",
28 "dojox/mvc/at",
29 "dojox/mvc/getStateful",
30 "dojo/data/ItemFileWriteStore",
31 "dojo/store/DataStore",
32 "dojo/_base/kernel",
33 "dojox/mvc/_atBindingExtension",
34 "dojox/mvc/ListController",
35 "dojox/mvc/EditModelRefController",
36 "dojox/mvc/StatefulArray",
37 "dojox/mvc/Group",
38 "dojox/mvc/Output",
39 "dojox/mvc/Repeat",
40 "dijit/form/Button",
41 "dijit/layout/ContentPane",
42 "dijit/form/TextBox"
43 ],
44 function(parser, registry, at, getStateful, ItemFileWriteStore, DataStore, kernel){
45 var writeStore = new ItemFileWriteStore({url: kernel.moduleUrl("dojox.mvc.tests._data", "mvcRepeatData.json")});
46 var modelPromise = new DataStore({store: writeStore}).query();
47 modelPromise.then(function(data){
48 savedData = data;
49 results = getStateful(data);
50
51 parser.parse();
52 });
53
54 setDetailsContext = function(index){
55 var ctl=registry.byId("listCtl");
56 ctl.set("cursorIndex", index);
57 };
58
59 saveData = function(){
60 //var ctl=registry.byId("listCtl");
61 var ctl=registry.byId("editCtl");
62 var ind = ctl.sourceModel.get('cursorIndex');
63 var ind2 = ctl.commitCurrent();
64 console.log(results[ind]);
65 };
66
67 saveAllData = function(){
68 var ctl=registry.byId("editCtl");
69 var ind = ctl.commit();
70 console.log(results);
71 };
72
73 resetData = function(){
74 var ctl=registry.byId("editCtl");
75 var ind = ctl.reset();
76 //results[ind].set(savedData[ind]);
77 //results.set(savedData);
78 };
79
80 });
81 </script>
82 </head>
83 <body class="claro"
84 style="width: 100%; height: 100%; margin: 0; padding: 0;">
85 <script type="dojo/require">at: "dojox/mvc/at"</script>
86 <span id="listCtl" data-dojo-type="dojox.mvc.ListController"
87 data-dojo-props="model: results, cursorIndex: 0"></span>
88 <div id="header">
89 <div id="navigation"></div>
90 <div id="headerInsert">
91 <h1>Employee Search</h1>
92 <h2>Master Detail Example - With repeat container.</h2>
93 </div>
94 </div>
95 <div id="main">
96 <div id="leftNav"></div>
97 <div id="mainContent">
98 <!--
99 The group container denotes some logical grouping of widgets and also serves
100 to establish a parent data binding context for its children.
101 The target attribute for the outermost container obtains the binding from the
102 "page scope" itself.
103 -->
104 <div id="searchBanner">Search Results for term: Engineers</div>
105
106 <!--
107 The repeat container denotes a templated UI that operates over a collection
108 of data records.
109 The UI can be customized for each iteration using properties such as
110 listCtl cursor or cursorIndex for the iteration.
111 -->
112 <div data-dojo-type="dojox.mvc.Repeat"
113 data-dojo-props="children: results">
114 <div class="row" data-dojo-type="dojox.mvc.Group"
115 data-dojo-props="target: at('rel:${this.index}')">
116 <label class="cell" for="nameInput${this.index}">Name:</label>
117 <div class="cell" data-dojo-type="dojox.mvc.Output"
118 id="nameInput${this.index}"
119 data-dojo-props="value: at('rel:', 'First')"></div>
120 <button type="button" data-dojo-type="dijit.form.Button"
121 data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button>
122 </div>
123 </div>
124 <div class="spacer"></div>
125 <div id="editCtl" data-dojo-type="dijit.layout.ContentPane" data-dojo-mixins="dojox.mvc.EditModelRefController"
126 data-dojo-props="region: 'center', style: 'background-color: white;', sourceModel: at('widget:listCtl', 'cursor')">
127 <!--
128 <div id="editCtl" data-dojo-type="dijit.layout.ContentPane" data-dojo-mixins="dojox.mvc.EditModelRefController"
129 data-dojo-props="region: 'center', style: 'background-color: white;', sourceModel: at('widget:listCtl', 'cursor')">
130 <div data-dojo-type="dojox.mvc.Group"
131 data-dojo-props="target: at('widget:listCtl', 'cursor')">
132 -->
133 <div class="row">
134 <div style="display: inline-block;" id="detailsBanner">Details for result index:</div>
135 <span class="cell" id="indexOutput"
136 data-dojo-type="dojox.mvc.Output"
137 data-dojo-props="value: at('widget:listCtl', 'cursorIndex')"></span>
138 </div>
139 <div class="row">
140 <label class="cell" for="firstInput">First Name:</label>
141 <input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox"
142 data-dojo-props="value: at('rel:', 'First')">
143 </div>
144 <div class="row">
145 <label class="cell" for="lastInput">Last Name:</label>
146 <input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox"
147 data-dojo-props="value: at('rel:', 'Last')">
148 </div>
149 <div class="row">
150 <label class="cell" for="locationInput">Location:</label>
151 <input class="cell" id="locationInput"
152 data-dojo-type="dijit.form.TextBox"
153 data-dojo-props="value: at('rel:', 'Location')">
154 </div>
155 <div class="row">
156 <label class="cell" for="officeInput">Office:</label>
157 <input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox"
158 data-dojo-props="value: at('rel:', 'Office')">
159 </div>
160 <div class="row">
161 <label class="cell" for="emailInput">Email:</label>
162 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox"
163 data-dojo-props="value: at('rel:', 'Email')">
164 </div>
165 <div class="row">
166 <label class="cell" for="telInput">Telephone:</label>
167 <input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox"
168 data-dojo-props="value: at('rel:', 'Tel')">
169 </div>
170 <div class="row">
171 <label class="cell" for="faxInput">Fax:</label>
172 <input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox"
173 data-dojo-props="value: at('rel:', 'Fax')">
174 </div>
175 <div class="row">
176 <div class="spacer"></div>
177 <button type="button" data-dojo-type="dijit.form.Button"
178 data-dojo-props="onClick: function(){saveData();}">Save Item</button>
179 <button type="button" data-dojo-type="dijit.form.Button"
180 data-dojo-props="onClick: function(){saveAllData();}">Commit All</button>
181 <button type="button" data-dojo-type="dijit.form.Button"
182 data-dojo-props="onClick: function(){resetData();}">Reset to last saved</button>
183 </div>
184
185 </div>
186 </div>
187 </div>
188 </body>
189 </html>