Debian Codegraph @

dojox/mvc/tests/controllers/step3_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 3 of test for Controllers, uses an EditModelRefController.</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 'dojox/mvc/getStateful',
18 'dojox/mvc/EditModelRefController',
19 'dojox/mvc/parserExtension',
20 'dijit/form/TextBox',
21 'dijit/form/Button',
22 'dojox/mvc/Group',
23 'dojox/mvc/Output'
24 ], function(parser, ready, getStateful, EditModelRefController){
25
26 // Initial data
27 var data = {
28 "id" : "360324",
29 "FullName" : "Mr. John Doe",
30 "Email" : "[email protected]",
31 "AddressLine1" : "123 Valley Rd.",
32 "AddressLine2" : "",
33 "City" : "Cary",
34 "State" : "NC",
35 "Zip" : "27513"
36 };
37
38 // To move from ModelRefController to use EditModelRefController, need to require EditModelRefController.
39 // and on the new call use sourceModel instead of model.
40 //
41 // EditModelRefController adds support for reset() and commit(), so buttons were added to show Reset and Save (commit).
42 //
43 // With holdModelUntilCommit set to true, you will want to bind the output address for the group to
44 // "target: at(ctrl,'sourceModel')", if holdModelUntilCommit is false you can stay with model, sourceModel will also work.
45 //
46 // You can change holdModelUntilCommit to false to see how that works, updates will be reflected into the Verify section
47 // immediately upon focus changes, and Reset will revert back to the last saved model.
48 // The EditModelRefController constructor sets sourceModel to the results of the getStateful call which will take json data and make it Stateful
49
50
51 transformAddress2Class = {
52 format: function(value){
53 if(value && value.trim().length > 0){
54 return "row" // if AddressLine2 is set return row for class
55 }
56 return "hiderow"; // if AddressLine2 is not set return hiderow for class
57 }
58
59 };
60
61 ctrl = new EditModelRefController({sourceModel: getStateful(data), holdModelUntilCommit: true});
62
63 parser.parse();
64 });
65 </script>
66 </head>
67 <body class="claro">
68 <script type="dojo/require">at: "dojox/mvc/at"</script>
69 <div id="wrapper">
70 <div id="main">
71 <div>
72 <h2>Step 3 of test for Controllers, uses an EditModelRefController with holdModelUntilCommit: true.</h2>
73 <h2>Enter Shipping Address</h2>
74 </div>
75 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'model')">
76 <div class="fullrow">
77 <label class="cell" for="nameInput">Full Name:</label>
78 <input class="cell" id="nameInput" data-dojo-type="dijit/form/TextBox"
79 data-dojo-props="value: at('rel:', 'FullName')">
80 </div>
81 <div class="fullrow">
82 <label class="cell" for="AddressLine1Input">Address Line1:</label>
83 <input class="cell" id="AddressLine1Input" data-dojo-type="dijit/form/TextBox"
84 data-dojo-props="value: at('rel:', 'AddressLine1')">
85 </div>
86 <div class="fullrow">
87 <label class="cell" for="AddressLine2Input">Address Line2:</label>
88 <input class="cell" id="AddressLine2Input" data-dojo-type="dijit/form/TextBox"
89 data-dojo-props="value: at('rel:', 'AddressLine2')">
90 </div>
91 <div class="fullrow">
92 <label class="cell" for="cityInput">City:</label>
93 <input class="cell" id="cityInput" data-dojo-type="dijit/form/TextBox"
94 data-dojo-props="value: at('rel:', 'City')">
95 </div>
96 <div class="fullrow">
97 <label class="cell" for="stateInput">State:</label>
98 <input class="cell" id="stateInput" data-dojo-type="dijit/form/TextBox"
99 data-dojo-props="value: at('rel:', 'State')">
100 </div>
101 <div class="fullrow">
102 <label class="cell" for="zipInput">Zipcode:</label>
103 <input class="cell" id="zipInput" data-dojo-type="dijit/form/TextBox"
104 data-dojo-props="value: at('rel:', 'Zip')">
105 </div>
106 </div>
107 <br/>
108 <div class="row">
109 <button class="buttoncell" id="reset" type="button" data-dojo-type="dijit/form/Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset</button>
110 <button class="buttoncell" id="commit" type="button" data-dojo-type="dijit/form/Button" data-dojo-props="onClick: function(){ ctrl.commit(); }">Save</button>
111 </div>
112
113 <br/>
114 <div>
115 <h2>Verify the shipping address, will not update until saved with holdModelUntilCommit true.</h2>
116 </div>
117 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'sourceModel')">
118 <div class="fullrow">
119 <div class="boldnamecell" data-dojo-type="dojox/mvc/Output"
120 data-dojo-props="value: at('rel:', 'FullName')"></div>
121 </div>
122 <div class="fullrow">
123 <div class="namecell" data-dojo-type="dojox/mvc/Output"
124 data-dojo-props="value: at('rel:', 'AddressLine1')"></div>
125 </div>
126 <div class="hiderow" data-mvc-bindings="class: at('rel:', 'AddressLine2').direction(at.from).transform(transformAddress2Class)">
127 <div class="namecell" data-dojo-type="dojox/mvc/Output"
128 data-dojo-props="value: at('rel:', 'AddressLine2')"></div>
129 </div>
130 <div class="fullrow">
131 <div class="namecell" data-dojo-type="dojox/mvc/Output"
132 data-dojo-props="value: at('rel:', 'City')">${this.value},</div>
133 <div class="namecell" data-dojo-type="dojox/mvc/Output"
134 data-dojo-props="value: at('rel:', 'State')"></div>
135 <div class="namecell" data-dojo-type="dojox/mvc/Output"
136 data-dojo-props="value: at('rel:', 'Zip')"></div>
137 </div>
138 </div>
139 </div>
140 </div>
141 </body>
142 </html>