| 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 |
require([ |
| 22 |
"doh/runner", |
| 23 |
"dojo/_base/declare", |
| 24 |
"dojo/when", |
| 25 |
"dojo/dom", |
| 26 |
"dojo/parser", |
| 27 |
"dojo/promise/all", |
| 28 |
"dojo/store/JsonRest", |
| 29 |
"dijit/registry", |
| 30 |
"dijit/_WidgetBase", |
| 31 |
"dojox/mvc/getStateful", |
| 32 |
"dojox/mvc/EditModelRefController", |
| 33 |
"dojox/mvc/ListController", |
| 34 |
"dijit/form/TextBox", |
| 35 |
"dijit/form/Button", |
| 36 |
"dojox/mvc/Group", |
| 37 |
"dojox/mvc/WidgetList", |
| 38 |
"dojo/domReady!" |
| 39 |
], function(doh, declare, when, ddom, parser, all, JsonRest, registry, _WidgetBase, getStateful, EditModelRefController, ListController){ |
| 40 |
|
| 41 |
var ctrlClass = declare([_WidgetBase, EditModelRefController, ListController], {}); |
| 42 |
(ctrl = (new ctrlClass({srcNodeRef: ddom.byId("detailsGroup"), cursorIndex: 0}))).startup(); |
| 43 |
|
| 44 |
when(all([parser.parse(), new JsonRest({target: require.toUrl("dojox/mvc/tests/_data/mvcRepeatData.json")}).query({})]), function(a){ |
| 45 |
ctrl.set("sourceModel", getStateful(a[1].items)); |
| 46 |
|
| 47 |
// should be able to verify all of the inputs |
| 48 |
doh.register("Check values and bindings", [ |
| 49 |
{ |
| 50 |
name: "Initial", |
| 51 |
runTest: function(){ |
| 52 |
doh.is("Anne", registry.byId("nameInput0").value, "nameInput0 should be Anne"); |
| 53 |
doh.is("Anne", registry.byId("firstInput").value, "firstInput should be Anne"); |
| 54 |
} |
| 55 |
}, { |
| 56 |
name: "TestBen", |
| 57 |
runTest: function(){ |
| 58 |
ctrl.set("cursorIndex", 1); |
| 59 |
doh.is("Ben", registry.byId("nameInput1").value, "nameInput1 should be Ben"); |
| 60 |
doh.is("Ben", registry.byId("firstInput").value, "firstInput should be Ben"); |
| 61 |
} |
| 62 |
}, { |
| 63 |
name: "TestJohn", |
| 64 |
runTest: function(){ |
| 65 |
ctrl.set("cursorIndex", 9); |
| 66 |
doh.is("John", registry.byId("nameInput9").value, "nameInput9 should be John"); |
| 67 |
doh.is("John", registry.byId("firstInput").value, "firstInput should be John"); |
| 68 |
|
| 69 |
registry.byId("firstInput").set("value", "Johnny"); |
| 70 |
|
| 71 |
doh.is("Johnny", ctrl.get("model").get(9).get("First"), "First name of the 10th entry should be changed to Johnny"); |
| 72 |
} |
| 73 |
}, { |
| 74 |
name: "TestCommitReset", |
| 75 |
runTest: function(){ |
| 76 |
ctrl.set("cursorIndex", 8); |
| 77 |
|
| 78 |
doh.is("Irene", registry.byId("nameInput8").value, "nameInput8 should be Irene"); |
| 79 |
doh.is("Irene", registry.byId("firstInput").value, "firstInput should be Irene"); |
| 80 |
|
| 81 |
registry.byId("firstInput").set("value", "IreneThisUpdateShouldBeSaved"); |
| 82 |
|
| 83 |
ctrl.commit(); |
| 84 |
|
| 85 |
registry.byId("lastInput").set("value", "IraThisUpdateShouldBeReset"); |
| 86 |
|
| 87 |
ctrl.reset(); |
| 88 |
|
| 89 |
doh.is("IreneThisUpdateShouldBeSaved", registry.byId("nameInput8").value, "nameInput8 should be IreneThisUpdateShouldBeSaved"); |
| 90 |
doh.is("IreneThisUpdateShouldBeSaved", registry.byId("firstInput").value, "firstInput should be IreneThisUpdateShouldBeSaved"); |
| 91 |
doh.is("Ira", registry.byId("lastInput").value, "lastInput should be Ira"); |
| 92 |
} |
| 93 |
} |
| 94 |
]); |
| 95 |
|
| 96 |
doh.run(); |
| 97 |
}); |
| 98 |
}); |
| 99 |
</script> |
| 100 |
</head> |
| 101 |
<body class="claro"> |
| 102 |
<script type="dojo/require">at: "dojox/mvc/at"</script> |
| 103 |
<h1 class="testTitle">doh_mvc_programmatic-repeat-store.html automated tests (non-robot)</h1> |
| 104 |
<div id="wrapper"> |
| 105 |
<div id="header"> |
| 106 |
<div id="navigation"></div> |
| 107 |
<div id="headerInsert"> |
| 108 |
<h2>Master Detail Example - With repeat container, using a store, with save, commit and reset.</h2> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
<div id="main"> |
| 112 |
<div id="leftNav"></div> |
| 113 |
<div id="mainContent"> |
| 114 |
<div id="searchBanner">Search Results for term: </div> |
| 115 |
<table> |
| 116 |
<tbody> |
| 117 |
<tr> |
| 118 |
<td> |
| 119 |
<div> |
| 120 |
<div>Declarative Repeat using my.Repeat does not pass templateString: </div> |
| 121 |
<div id="repeatId" |
| 122 |
data-dojo-type="dojox/mvc/WidgetList" |
| 123 |
data-dojo-mixins="dojox/mvc/_InlineTemplateMixin" |
| 124 |
data-dojo-props="children: at(ctrl, 'model')"> |
| 125 |
<script type="dojox/mvc/InlineTemplate"> |
| 126 |
<div class="row"> |
| 127 |
<label class="cell" for="nameInput${indexAtStartup}">Name:</label> |
| 128 |
<input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${indexAtStartup}" data-dojo-props="value: at('rel:', 'First')"/> |
| 129 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.set('cursorIndex', '${indexAtStartup}'); }">Details</button> |
| 130 |
</div> |
| 131 |
</script> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
</td> |
| 135 |
</tr> |
| 136 |
</tbody> |
| 137 |
</table> |
| 138 |
<div class="spacer"></div> |
| 139 |
<div id="detailsBanner">Details for selected index:</div> |
| 140 |
<div id="detailsGroup"> |
| 141 |
<div class="row"> |
| 142 |
<label class="cell" for="firstInput">First Name:</label> |
| 143 |
<input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'First')"> |
| 144 |
</div> |
| 145 |
<div class="row"> |
| 146 |
<label class="cell" for="lastInput">Last Name:</label> |
| 147 |
<input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" 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" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Location')"> |
| 152 |
</div> |
| 153 |
<div class="row"> |
| 154 |
<label class="cell" for="officeInput">Office:</label> |
| 155 |
<input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Office')"> |
| 156 |
</div> |
| 157 |
<div class="row"> |
| 158 |
<label class="cell" for="emailInput">Email:</label> |
| 159 |
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Email')"> |
| 160 |
</div> |
| 161 |
<div class="row"> |
| 162 |
<label class="cell" for="telInput">Telephone:</label> |
| 163 |
<input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Tel')"> |
| 164 |
</div> |
| 165 |
<div class="row"> |
| 166 |
<label class="cell" for="faxInput">Fax:</label> |
| 167 |
<input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="value: at('rel:', 'Fax')"> |
| 168 |
</div> |
| 169 |
<div class="row"> |
| 170 |
<div class="spacer"></div> |
| 171 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.commit();}">Commit All</button> |
| 172 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ ctrl.reset(); }">Reset to last saved</button> |
| 173 |
</div> |
| 174 |
</div> |
| 175 |
</div> |
| 176 |
</div> |
| 177 |
</div> |
| 178 |
</body> |
| 179 |
</html> |