| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>MVC DOH Test</title> |
| 6 |
|
| 7 |
<style> |
| 8 |
@import "../../../../../dojo/resources/dojo.css"; |
| 9 |
@import "../../../../../dijit/tests/css/dijitTests.css"; |
| 10 |
@import "../../css/app-format.css"; |
| 11 |
</style> |
| 12 |
|
| 13 |
|
| 14 |
<link id="themeStyles" rel="stylesheet" href="../../../../../dijit/themes/claro/claro.css"/> |
| 15 |
|
| 16 |
|
| 17 |
<script src="../../../../../dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: 0, isDebug: 1, mvc: {debugBindings: 1}"></script> |
| 18 |
<script type="text/javascript" src="../helpers.js"></script> |
| 19 |
|
| 20 |
<script type="text/javascript"> |
| 21 |
var templateString = '<div class="row">' |
| 22 |
+ '<script type="dojo/require">at: "dojox/mvc/at"<\/script>' |
| 23 |
+ '<label class="cell">Name:</label>' |
| 24 |
+ '<input id="${parent.id}_textbox${indexAtStartup}" class="cell" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at(\'rel:\', \'First\')"></input>' |
| 25 |
+ '<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.set(\'cursorIndex\', \'${indexAtStartup}\'); }">Details</button>' |
| 26 |
+ '</div>'; |
| 27 |
|
| 28 |
require([ |
| 29 |
"doh/runner", |
| 30 |
"dojo/_base/declare", |
| 31 |
"dojo/when", |
| 32 |
"dojo/dom", |
| 33 |
"dojo/parser", |
| 34 |
"dojo/promise/all", |
| 35 |
"dojo/store/JsonRest", |
| 36 |
"dijit/registry", |
| 37 |
"dijit/_WidgetBase", |
| 38 |
"dojox/mvc/at", |
| 39 |
"dojox/mvc/getStateful", |
| 40 |
"dojox/mvc/EditModelRefController", |
| 41 |
"dojox/mvc/ListController", |
| 42 |
"dojox/mvc/WidgetList", |
| 43 |
"dijit/form/TextBox", |
| 44 |
"dijit/form/Button", |
| 45 |
"dojox/mvc/Group", |
| 46 |
"dojo/domReady!" |
| 47 |
], function(doh, declare, when, ddom, parser, all, JsonRest, registry, _WidgetBase, at, getStateful, EditModelRefController, ListController, WidgetList){ |
| 48 |
|
| 49 |
var ctrlClass = declare([_WidgetBase, EditModelRefController, ListController], {}); |
| 50 |
(ctrl = (new ctrlClass({srcNodeRef: ddom.byId("detailsGroup"), cursorIndex: 0}))).startup(); |
| 51 |
|
| 52 |
(new WidgetList({templateString: templateString, children: at(ctrl, "model")}, ddom.byId("repeat2"))).startup(); |
| 53 |
|
| 54 |
when(all([parser.parse(), new JsonRest({target: require.toUrl("dojox/mvc/tests/_data/mvcRepeatData.json")}).query({})]), function(a){ |
| 55 |
// ctrl.set("sourceModel", getStateful(a[1].items)); |
| 56 |
|
| 57 |
// should be able to verify all of the inputs |
| 58 |
doh.register("Check values and bindings", [ |
| 59 |
{ |
| 60 |
name: "setup", |
| 61 |
runTest: function(){ |
| 62 |
ctrl.set("sourceModel", getStateful(a[1].items)); |
| 63 |
} |
| 64 |
}, { |
| 65 |
name: "Initial", |
| 66 |
runTest: function(){ |
| 67 |
doh.is("Anne", registry.byId("repeat2_textbox0").value, "textbox0 should be Anne"); |
| 68 |
doh.is("Anne", registry.byId("firstInput").value, "firstInput should be Anne"); |
| 69 |
} |
| 70 |
}, { |
| 71 |
name: "TestBen", |
| 72 |
runTest: function(){ |
| 73 |
ctrl.set("cursorIndex", 1); |
| 74 |
doh.is("Ben", registry.byId("repeat2_textbox1").value, "textbox1 should be Ben"); |
| 75 |
doh.is("Ben", registry.byId("firstInput").value, "firstInput should be Ben"); |
| 76 |
} |
| 77 |
}, { |
| 78 |
name: "TestJohn", |
| 79 |
runTest: function(){ |
| 80 |
ctrl.set("cursorIndex", 9); |
| 81 |
doh.is("John", registry.byId("repeat2_textbox9").value, "textbox9 should be John"); |
| 82 |
doh.is("John", registry.byId("firstInput").value, "firstInput should be John"); |
| 83 |
|
| 84 |
registry.byId("firstInput").set("value", "Johnny"); |
| 85 |
|
| 86 |
doh.is("Johnny", ctrl.get("model").get(9).get("First"), "First name of the 10th entry should be changed to Johnny"); |
| 87 |
} |
| 88 |
}, { |
| 89 |
name: "TestCommitReset", |
| 90 |
runTest: function(){ |
| 91 |
ctrl.set("cursorIndex", 8); |
| 92 |
|
| 93 |
doh.is("Irene", registry.byId("repeat2_textbox8").value, "textbox8 should be Irene"); |
| 94 |
doh.is("Irene", registry.byId("firstInput").value, "firstInput should be Irene"); |
| 95 |
|
| 96 |
registry.byId("firstInput").set("value", "IreneThisUpdateShouldBeSaved"); |
| 97 |
|
| 98 |
ctrl.commit(); |
| 99 |
|
| 100 |
registry.byId("lastInput").set("value", "IraThisUpdateShouldBeReset"); |
| 101 |
|
| 102 |
ctrl.reset(); |
| 103 |
|
| 104 |
doh.is("IreneThisUpdateShouldBeSaved", registry.byId("repeat2_textbox8").value, "textbox8 should be IreneThisUpdateShouldBeSaved"); |
| 105 |
doh.is("IreneThisUpdateShouldBeSaved", registry.byId("firstInput").value, "firstInput should be IreneThisUpdateShouldBeSaved"); |
| 106 |
doh.is("Ira", registry.byId("lastInput").value, "lastInput should be Ira"); |
| 107 |
} |
| 108 |
} |
| 109 |
]); |
| 110 |
|
| 111 |
doh.run(); |
| 112 |
}); |
| 113 |
}); |
| 114 |
</script> |
| 115 |
</head> |
| 116 |
<body class="claro"> |
| 117 |
<script type="dojo/require">at: "dojox/mvc/at"</script> |
| 118 |
<h1 class="testTitle">doh_mvc_programmatic-repeat-store.html automated tests (non-robot)</h1> |
| 119 |
<div id="wrapper"> |
| 120 |
<div id="header"> |
| 121 |
<div id="navigation"></div> |
| 122 |
<div id="headerInsert"> |
| 123 |
<h2>Master Detail Example - With repeat container, using a store, with save, commit and reset.</h2> |
| 124 |
</div> |
| 125 |
</div> |
| 126 |
<div id="main"> |
| 127 |
<div id="leftNav"></div> |
| 128 |
<div id="mainContent"> |
| 129 |
<div id="searchBanner">Search Results for term: </div> |
| 130 |
<table> |
| 131 |
<tbody> |
| 132 |
<tr> |
| 133 |
<td> |
| 134 |
<div> |
| 135 |
<div>Programatic Repeat using my.Repeat and its templateString: </div> |
| 136 |
<div id="repeat2"></div> |
| 137 |
</div> |
| 138 |
</td> |
| 139 |
<td> |
| 140 |
<div> |
| 141 |
<div>Declarative Repeat using my.Repeat does not pass templateString: </div> |
| 142 |
<div id="repeatId2" |
| 143 |
data-dojo-type="dojox/mvc/WidgetList" |
| 144 |
data-dojo-props="templateString: templateString, children: at(ctrl, 'model')"></div> |
| 145 |
</div> |
| 146 |
</td> |
| 147 |
</tr> |
| 148 |
</tbody> |
| 149 |
</table> |
| 150 |
<div class="spacer"></div> |
| 151 |
<div id="detailsBanner">Details for selected index:</div> |
| 152 |
<div id="detailsGroup"> |
| 153 |
<div class="row"> |
| 154 |
<label class="cell" for="firstInput">First Name:</label> |
| 155 |
<input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'First')"></input> |
| 156 |
</div> |
| 157 |
<div class="row"> |
| 158 |
<label class="cell" for="lastInput">Last Name:</label> |
| 159 |
<input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Last')"></input> |
| 160 |
</div> |
| 161 |
<div class="row"> |
| 162 |
<label class="cell" for="locationInput">Location:</label> |
| 163 |
<input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Location')"></input> |
| 164 |
</div> |
| 165 |
<div class="row"> |
| 166 |
<label class="cell" for="officeInput">Office:</label> |
| 167 |
<input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Office')"></input> |
| 168 |
</div> |
| 169 |
<div class="row"> |
| 170 |
<label class="cell" for="emailInput">Email:</label> |
| 171 |
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Email')"></input> |
| 172 |
</div> |
| 173 |
<div class="row"> |
| 174 |
<label class="cell" for="telInput">Telephone:</label> |
| 175 |
<input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Tel')"></input> |
| 176 |
</div> |
| 177 |
<div class="row"> |
| 178 |
<label class="cell" for="faxInput">Fax:</label> |
| 179 |
<input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Fax')"></input> |
| 180 |
</div> |
| 181 |
<div class="row"> |
| 182 |
<div class="spacer"></div> |
| 183 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.commit();}">Commit All</button> |
| 184 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset to last saved</button> |
| 185 |
</div> |
| 186 |
</div> |
| 187 |
</div> |
| 188 |
</div> |
| 189 |
</div> |
| 190 |
</body> |
| 191 |
</html> |