Debian Codegraph @

dojox/store/tests/OData.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Dojo OData Store</title>
6 <link rel="stylesheet" type="text/css" href="../../dijit/themes/claro/claro.css">
7 <style>
8 body {
9 font-family : 'Helvetica Neue', Helvetica, Arial, sans-serif;
10 color : #222;
11 max-width:979px;
12 margin-left:auto;
13 margin-right:auto;
14 background:white;
15 margin: 20px auto;
16 border-radius:4px;
17 padding-bottom:20px;
18 }
19
20 h1 {
21 font-weight: bold;
22 letter-spacing: -1px;
23 line-height: 1;
24 font-size:60px;
25 text-shadow: 0 1px 3px rgba(0,0,0,.4), 0 0 30px rgba(0,0,0,.075);
26 padding : 30px 0 0 0;
27 margin : 0 0;
28 }
29
30 h2 {
31 margin: 20px 0;
32 color:#888;
33 }
34
35 pre {
36 font-size: 18px;
37 }
38
39 .results {
40 border-radius:3px;
41 background:#DDD;
42
43 }
44
45 .status {
46 font-weight: bold;
47 margin-left: 20px;
48 }
49
50 .nav {
51 height:500px;
52 width:200px;
53 position:absolute;
54 top:0;
55 left:0;
56 border: 1px solid #DDD;
57 border-top-left-radius: 4px;
58 border-bottom-left-radius: 4px;
59 cursor: pointer;
60 }
61
62 .nav div{
63 height: 40px;
64 border-bottom: 1px solid #DDD;
65 line-height: 40px;
66 padding: 0 0 0 20px;
67 cursor: pointer;
68 }
69
70 .nav div:hover{
71 background: #DDD;
72 }
73
74 .guide {
75 height: 500px;
76 padding-left: 200px;
77 border-top: 1px solid #DDD;
78 border-right: 1px solid #DDD;
79 border-bottom: 1px solid #DDD;
80 border-radius: 4px;
81 }
82
83 .nav div.active{
84 background: #0088cc;
85 color: white;
86 }
87
88 .guide div{
89 display: none;
90 padding: 20px;
91 height:100%;
92 }
93
94 .guide h2{
95 margin: 0px !important;
96 }
97
98 .guide div.active{
99 display:block;
100 }
101
102 .content{
103 position: relative;
104 box-shadow: 0 0 15px #888;
105 border-radius: 4px;
106 }
107 </style>
108 </head>
109 <body class="claro">
110 <h1>Dojo OData Store</h1>
111 <h2>This page should serve as a general guide to the OData store API.</h2>
112 <div class="content">
113 <div class="nav">
114 <div data-target="getIdentity" class="active">getIdentity</div>
115 <div data-target="get">get</div>
116 <div data-target="put">put</div>
117 <div data-target="add">add</div>
118 <div data-target="remove">remove</div>
119 <div data-target="query">query</div>
120 <div data-target="getChildren">getChildren</div>
121 <div data-target="getFormDigest">getFormDigest</div>
122 </div>
123 <div class="guide">
124 <div class="getIdentity active">
125 <h2>Summary</h2>
126 <p>Returns an object's identity</p>
127 <h2>Example</h2>
128 <pre>
129 var id = store.getIdentity(someObject);
130 </pre>
131 </div>
132 <div class="get">
133 <h2>Summary</h2>
134 <p>
135 Retrieves an object by its identity. This will trigger a GET request to the server using the url <code>this.target + "("+id+")"</code>.
136 </p>
137 <h2>Example</h2>
138 <pre>
139 store.get("2").then(function(){
140 // do something with item
141 });
142 </pre>
143 </div>
144 <div class="put">
145 <h2>Summary</h2>
146 <p>
147 Stores an object. This will trigger a POST or MERGE request to the server depending on if it is an incremental update
148 </p>
149 <h2>Example</h2>
150 <pre>
151 store.put({
152 '__metadata': {
153 'type': 'Microsoft.SharePoint.DataService.DojoItem'
154 },
155 'Title': 'New Item'
156 }).then(function(success){
157 // success
158 });
159 </pre>
160 </div>
161 <div class="add">
162 <h2>Summary</h2>
163 <p>
164 Adds an object. This will trigger a POST request to the server.
165 </p>
166 <h2>Example</h2>
167 <pre>
168 store.add({
169 '__metadata': {
170 'type': 'Microsoft.SharePoint.DataService.DojoItem'
171 },
172 'Title': 'New Item'
173 }).then(function(success){
174 // success
175 });
176 </pre>
177 </div>
178 <div class="remove">
179 <h2>Summary</h2>
180 <p>
181 Deletes an object by its identity. This will trigger a DELETE request to the server.
182 </p>
183 <h2>Example</h2>
184 <pre>
185 store.remove("27",{
186 headers: {"X-RequestDigest": token}
187 }).then(function(success){
188 // success
189 });
190 </pre>
191 </div>
192 <div class="query">
193 <h2>Summary</h2>
194 <p>
195 Queries the store for objects. This will trigger a GET request to the server, with the query added as a query string that adheres to OData URI conventions.
196 </p>
197 <h2>Example</h2>
198 <pre>
199 store.query({
200 Title: "Dojo*",
201 $filter: "Foo eq 'Bar'"
202 }).then(function(items){
203 // do something with items
204 });
205 </pre>
206 </div>
207 <div class="getChildren">
208 <h2>Summary</h2>
209 <p>
210 Retrieves the children of an object.
211 </p>
212 <h2>Example</h2>
213 <pre>
214 store.getChildren(someObject).then(function(children){
215 // do something with items
216 });
217 </pre>
218 </div>
219 <div class="getFormDigest">
220 <h2>Summary</h2>
221 <p>
222 Depending on the implementation of the OData endpoint being targeted, a form digest value may be required on specific requests. The store provides a convenient way to acquire this token.
223 </p>
224 <h2>Example</h2>
225 <pre>
226 store.getFormDigest().then(function(token){
227 store.put({
228 '__metadata': {
229 'type': 'Microsoft.SharePoint.DataService.DojoItem'
230 },
231 'Title': 'New Item'
232 },{
233 headers: {"X-RequestDigest": token}
234 }).then(function(success){
235 // success
236 });
237 });
238 </pre>
239
240 </div>
241 </div>
242 </div>
243 <script src="../../../dojo/dojo.js" data-dojo-config="async: true"></script>
244 <script>
245
246 require([
247 "dojo/query",
248 "dojo/dom-class",
249 "dojo/dom-attr",
250 "dijit/form/FilteringSelect",
251 "dojo/NodeList-dom"
252 ],function(query, domClass, domAttr, FilteringSelect){
253 // set up basic handler
254 query("div.nav").on("click", function(e){
255 var target = domAttr.get(e.target, "data-target");
256 query(".active").removeClass("active");
257 domClass.add(e.target, "active");
258 query("."+target).addClass("active");
259 });
260 });
261
262 </script>
263 </body>
264 </html>