Debian Codegraph @

dojox/mvc/tests/controllers/step5_test_mvc.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>Step 5 of test for Controllers, uses an EditControllerMixin with a StoreControllerMixin.</title>
6 <style type="text/css">
7 @import "../css/app-format.css";
8 @import "../../../../dijit/themes/claro/claro.css";
9 </style>
10 <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1,mvc:{debugBindings:1}" src="../../../../dojo/dojo.js"></script>
11 <script type="text/javascript">
12 var ctrl;
13
14 require([
15 'dojo/parser',
16 'dojo/ready',
17 'dojo/when',
18 'dojo/store/Memory',
19 'dojox/mvc/getStateful',
20 'dojox/mvc/EditStoreRefController',
21 'dojox/mvc/parserExtension',
22 'dijit/form/TextBox',
23 'dijit/form/Button',
24 'dojox/mvc/Group',
25 'dojox/mvc/Output'
26 ], function(parser, ready, when, Memory, getStateful, EditStoreRefController){
27
28 // Initial data
29 var storeData = {
30 "identifier": "id",
31 "items": [
32 {
33 "id" : "360324",
34 "FullName" : "Mr. John Doe",
35 "Email" : "[email protected]",
36 "AddressLine1" : "123 Valley Rd.",
37 "AddressLine2" : "",
38 "City" : "Cary",
39 "State" : "NC",
40 "Zip" : "27513"
41 }
42 ]
43 };
44
45 // To move from an EditModelRefController to use an EditStoreRefController, need to require EditStoreRefController,
46 // Memory, and when. Also needed to change the data to be valid for a store query.
47 //
48 // Because of the queryStore call had to move the call to parser.parse inside the when to wait for it.
49 // The change in the data for queryStore required changes to the bindings. had to add a group with target: at('rel:','0')
50 // for the bindings of fields.
51 //
52 // With holdModelUntilCommit set to true, you will want to bind the output address for the group to
53 // "target: at(ctrl,'sourceModel')", if holdModelUntilCommit is false you can stay with model, sourceModel will also work.
54 // You can change holdModelUntilCommit to false to see how that works, updates will be reflected into the Verify section
55 // immediately upon focus changes, and Reset will revert back to the last saved model.
56 // The EditStoreRefController constructor sets store to the memory store and uses queryStore() to setup the models.
57 //
58
59 transformAddress2Class = {
60 format: function(value){
61 if(value && value.trim().length > 0){
62 return "row" // if AddressLine2 is set return row for class
63 }
64 return "hiderow"; // if AddressLine2 is not set return hiderow for class
65 }
66
67 };
68
69 ctrl = new EditStoreRefController({store: new Memory({data:storeData}), holdModelUntilCommit: true});
70 when(ctrl.queryStore(), function(){
71 parser.parse();
72 });
73
74 });
75 </script>
76 </head>
77 <body class="claro">
78 <script type="dojo/require">at: "dojox/mvc/at"</script>
79 <div id="wrapper">
80 <div id="main">
81 <div>
82 <h2>Step 5 of test for Controllers, uses an EditStoreRefController with holdModelUntilCommit: true.</h2>
83 <h2>Enter Shipping Address</h2>
84 </div>
85 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'model')">
86 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at('rel:','0')">
87 <div class="fullrow">
88 <label class="cell" for="nameInput">Full Name:</label>
89 <input class="cell" id="nameInput" data-dojo-type="dijit/form/TextBox"
90 data-dojo-props="value: at('rel:', 'FullName')">
91 </div>
92 <div class="fullrow">
93 <label class="cell" for="AddressLine1Input">Address Line1:</label>
94 <input class="cell" id="AddressLine1Input" data-dojo-type="dijit/form/TextBox"
95 data-dojo-props="value: at('rel:', 'AddressLine1')">
96 </div>
97 <div class="fullrow">
98 <label class="cell" for="AddressLine2Input">Address Line2:</label>
99 <input class="cell" id="AddressLine2Input" data-dojo-type="dijit/form/TextBox"
100 data-dojo-props="value: at('rel:', 'AddressLine2')">
101 </div>
102 <div class="fullrow">
103 <label class="cell" for="cityInput">City:</label>
104 <input class="cell" id="cityInput" data-dojo-type="dijit/form/TextBox"
105 data-dojo-props="value: at('rel:', 'City')">
106 </div>
107 <div class="fullrow">
108 <label class="cell" for="stateInput">State:</label>
109 <input class="cell" id="stateInput" data-dojo-type="dijit/form/TextBox"
110 data-dojo-props="value: at('rel:', 'State')">
111 </div>
112 <div class="fullrow">
113 <label class="cell" for="zipInput">Zipcode:</label>
114 <input class="cell" id="zipInput" data-dojo-type="dijit/form/TextBox"
115 data-dojo-props="value: at('rel:', 'Zip')">
116 </div>
117 </div>
118 </div>
119 <br/>
120
121 <div class="fullrow">
122 <button class="buttoncell" id="reset" type="button" data-dojo-type="dijit/form/Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset</button>
123 <button class="buttoncell" id="commit" type="button" data-dojo-type="dijit/form/Button" data-dojo-props="onClick: function(){ ctrl.commit(); }">Save</button>
124 </div>
125
126 <br/>
127
128 <div>
129 <h2>Verify the shipping address, will not update until saved.</h2>
130 </div>
131 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'sourceModel')">
132 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at('rel:','0')">
133 <div class="fullrow">
134 <div class="boldnamecell" id="nameOutput" data-dojo-type="dojox/mvc/Output"
135 data-dojo-props="value: at('rel:', 'FullName')"></div>
136 </div>
137 <div class="fullrow">
138 <div class="namecell" data-dojo-type="dojox/mvc/Output"
139 data-dojo-props="value: at('rel:', 'AddressLine1')"></div>
140 </div>
141 <div class="hiderow" data-mvc-bindings="class: at('rel:', 'AddressLine2').direction(at.from).transform(transformAddress2Class)">
142 <div class="namecell" data-dojo-type="dojox/mvc/Output"
143 data-dojo-props="value: at('rel:', 'AddressLine2')"></div>
144 </div>
145 <div class="fullrow">
146 <div class="namecell" data-dojo-type="dojox/mvc/Output"
147 data-dojo-props="exprchar:'%', value: at('rel:', 'City')">%{this.value},</div>
148 <div class="namecell" data-dojo-type="dojox/mvc/Output"
149 data-dojo-props="value: at('rel:', 'State')"></div>
150 <div class="namecell" data-dojo-type="dojox/mvc/Output"
151 data-dojo-props="value: at('rel:', 'Zip')"></div>
152 </div>
153 </div>
154 </div>
155 </div>
156 </div>
157 </body>
158 </html>