forked from evoluteur/evolutility-ui-jquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui-model.html
More file actions
617 lines (576 loc) · 20.8 KB
/
Copy pathui-model.html
File metadata and controls
617 lines (576 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="../dist/css/vendors.min.css" rel="stylesheet" />
<link href="../dist/css/demo.css" rel="stylesheet" />
<link href="../dist/css/evolutility.css" rel="stylesheet" />
<title>UI Models :: Evolutility</title>
</head>
<body>
<div class="evo-header">
<div class="evo-logo"><a href="../index.html"><span>evol</span>utility<span>.js</span></a></div>
<ul class="evo-head-links">
<li><a href="../demo/index.html">demos</a></li>
<li><a href="../doc/index.html" class="sel">doc</a></li>
<li class="evo-link2">
<ul class="evo-head-links2">
<li><a href="views.html">views</a></li>
<li><a class="sel" href="ui-model.html">ui-model</a></li>
<li><a href="controller.html">controller</a></li>
</ul>
</li>
<li class="spaced"><a href="https://github.com/evoluteur/evolutility" target="_new">GitHub</a></li>
</ul>
<div class="clearfix"></div>
</div>
<div class="evo-title2">
<h1>UI Model</h1>
<div class="list-views">
<div>
<a href="#object">object</a>
<a href="#field">field</a>
</div>
<div>
<a href="#panel">panel</a>
<a href="#panel-list">panel-list</a>
<a href="#tab">tab</a>
</div>
</div>
</div>
<div class="evo-content2">
<p>With Evolutility views are fully defined by UI models (rather than hand coded templates and custom Javascript code).</p>
<p>For each Backbone model and collection, a single UI model defines all information necessary to render all views associated to that entity.
The UI model maps attributes in the Backbone model to <a href="#field">fields</a> on the screen. It also groups fields into <a href="#panel">panels</a> and panels into <a href="#tab">tabs</a>.
Nested collections can also be included as <a href="#panel-list">panel-list</a> to provide master-details capability.
</p>
<p>It is a first draft and it is nor fully implemented yet. It is still a work in progress based on
<a href="http://www.codeproject.com/Articles/28636/Minimalist-Meta-Model-for-CRUD-Applications" target="evomm">Evolutility minimalist meta-model</a>.</p>
<p>Elements:
<a href="#object">object</a> -
<a href="#field">field</a> -
<a href="#panel">panel</a> -
<a href="#panel-list">panel-list</a> -
<a href="#tab">tab</a>
</p>
<span class="evol-required">*</span>: required attribute.
<span class="evol-asterix">*</span>: partially or not implemented yet.
<a name="object" class="evo-anchor"> </a>
<section>
<h1>object</h1>
<p>An "object" is the UI information mapped to a Backbone model to drive all <a href="views.html">views</a> for that model.
<table class="table table-bordered">
<tbody>
<tr>
<td style="width: 120px; ">id<span class="evol-required">*</span>
</td>
<td>UI-model unique ID. It is used as a key to identify the UI-model but never displayed to the user.
</td>
</tr>
<tr>
<td>entity<span class="evol-required">*</span>
</td>
<td>User's object name for the Backbone model.
<br>Example: "task" for a
to do list application.
</td>
</tr>
<tr>
<td>entities<span class="evol-required">*</span>
</td>
<td>Plural for <code>entity</code>.<br>Example "tasks".
</td>
</tr>
<tr>
<td>elements[]<span class="evol-required">*</span>
</td>
<td>
Array of tabs or panels which contains fields.
</td>
</tr>
<tr>
<td>help<span class="evol-asterix">*</span>
</td>
<td>Introduction text about for the entity.
</td>
</tr>
<tr>
<td>badge</td>
<td>id of the field to display as a badge near the items' title. Can also be a function taking model as a parameter.
<br/>Example: badgefield = "price"</td>
</tr>
<tr>
<td>leadfield</td>
<td>id of the field to use for the page title (when using option "$title"). Can also be a function taking model as a parameter.
<br/>Example 1: leadfield = "firstname"<br/>
Exemple 2: leadfield = function(model){ return model.get('firstname')+' '+model.get('lastname')}</td>
</tr>
<tr>
<td>icon
</td>
<td>Filename of the records icon (same one for all records).
<br />
Example: <code>icon</code> ="todo.png"
</td>
</tr>
<tr>
<td>summary <span class="evol-asterix">*</span></td>
<td>Summary row of data with aggregations like
<br />
Example:
<code>summary</code>=[
{id:'count_completed', label:'# Completed', fieldId: 'complete', formula: 'count'},
{id:'count_have', label:'# Have', fieldId: 'haveNb', formula: 'sum'}
]</td>
</tr>
<tr>
<td>searchfields <span class="evol-asterix">*</span>
</td>
<td>
</td>
</tr>
<tr>
<td>$title</td>
<td>jQuery selector for an element outside of the View to show item main field as a title on navigation.
<br />
Example: <code>$title</code>="#title" </td>
</tr>
</tbody></table>
</section>
<a name="field" class="evo-anchor"> </a>
<section>
<h1>field</h1>
<p>Attributes in your Backbone model are mapped to fields in the UI.</p>
<p>These fields have the following properties:</p>
<table class="table table-bordered">
<tbody>
<tr>
<th colspan="2">Identity</th>
</tr>
<tr>
<td>id<span class="evol-required">*</span></td>
<td>Field Id in the UI.</td>
</tr>
<tr>
<td>attribute <span class="evol-asterix">*</span> </td>
<td>Model attribute mapping to the field.
If no value is provided for "attribute", the value of the attribute "id" is used.</td>
</tr>
<tr>
<td>value
</td>
<td>Function to evaluate to render the field content.
<br/>i.e.: value = function(model) {return model.escape('name');}
</td>
</tr>
<tr>
<td>label<span class="evol-required">*</span>
</td>
<td>Field title in all views. (Can be overridden for specific views with labellist, labelexport...).
</td>
</tr>
<tr>
<td>labelcharts
</td>
<td>Title of the Chart based on this field (in Charts view).
</td>
</tr>
<tr>
<td>labeltrue, labelfalse
</td>
<td>Only applies to boolean fields. Displayed value for true or false in charts (may be used in other places in the future).
</td>
</tr>
<tr>
<td>defaultvalue
</td>
<td>Default value for the field when creating a new record.
</td>
</tr>
<tr>
<td>type<span class="evol-required">*</span>
<span class="evol-asterix">*</span>
</td>
<td>
<p>The type of the field in the UI.</p>
<ul class="indent list-unstyled" style="float:left;width:170px">
<li><span data-id="#boolean"><img src="../dico/pix/ft-bool.gif" class="Icon">boolean</span></li>
<li><span data-id="#color"><img src="../dico/pix/ft-color.gif" class="Icon">color</span></li>
<li><span data-id="#date"><img src="../dico/pix/ft-date.gif" class="Icon">date</span></li>
<li><span data-id="#datetime"><img src="../dico/pix/ft-datehm.gif" class="Icon">datetime</span><span class="evol-asterix">*</span></li>
<li><span data-id="#decimal"><img src="../dico/pix/ft-dec.gif" class="Icon">decimal</span></li>
<li><span data-id="#document"><img src="../dico/pix/ft-doc.gif" class="Icon">document</span><span class="evol-asterix">*</span></li>
<li><span data-id="#email"><img src="../dico/pix/ft-email.gif" class="Icon">email</span></li>
<li><span data-id="#hidden"><img class="Icon" src="../dico/pix/ft-hidden.png">hidden</span></li>
<li><span data-id="#html"><img class="Icon" src="../dico/pix/ft-htm.gif">html</span><span class="evol-asterix">*</span></li>
</ul>
<ul class="indent list-unstyled" style="float:left;width:170px">
<li><span data-id="#image"><img src="../dico/pix/ft-img.gif" class="Icon">image</span><span class="evol-asterix">*</span></li>
<li><span data-id="#url"><img src="../dico/pix/ft-url.gif" class="Icon">url</span></li>
<li><span data-id="#lov"><img src="../dico/pix/ft-lov.gif" class="Icon">lov (single value)</span></li>
<li><span data-id="#list"><img src="../dico/pix/ft-list.png" class="Icon">list (multiple values)</span></li>
<li><span data-id="#money"><img src="../dico/pix/ft-money.gif" class="Icon">money</span></li>
<li><span data-id="#text"><img src="../dico/pix/ft-txt.gif" class="Icon">text</span></li>
<li><span data-id="#textmultiline"><img src="../dico/pix/ft-txtml.gif" class="Icon">textmultiline</span></li>
<li><span data-id="#integer"><img src="../dico/pix/ft-int.gif" class="Icon">integer</span></li>
<li><span data-id="#time"><img src="../dico/pix/ft-time.gif" class="Icon">time</span><span class="evol-asterix">*</span></li>
</ul>
<div class="clearfix"></div>
</td>
</tr>
<tr>
<th colspan="2">Layout</th>
</tr>
<tr>
<td>typechart<span class="evol-asterix">*</span>
</td>
<td>Type of chart used for this fields (in Charts view). Possible values: Pie, vBar, hBar (more later).
<br>Note: Only applies for fields which supports charts (fields of type boolean, integer, money, lov).
</td>
</tr>
<tr>
<td >css<span class="evol-asterix">*</span>
</td>
<td>CSS class name for the specific field.
</td>
</tr>
<tr>
<td>csslabel
</td>
<td>CSS class name for the specific field label (in views Edit, Browse and Mini).
</td>
</tr>
<tr>
<td>format<span class="evol-asterix">*</span>
</td>
<td>Field format (for fields of type boolean, date, decimal, or integer).
<br />
Example: <code>format</code>="'$'#,##0.00"
</td>
</tr>
<tr>
<td>height
</td>
<td>Height of the field, in number of rows (default to 1 for all field except
fields of type TextMultilines).
</td>
</tr>
<tr>
<td>img
</td>
<td>Image to display (for fields of type "boolean" or "url") in Edit or Browse modes.
</td>
</tr>
<tr>
<td>width
</td>
<td><p>Width of the field in percentage of the Panel it belongs to.
<br/>Default: 100%
</p></td>
</tr>
<tr>
<th colspan="2">Validation</th>
</tr>
<tr>
<td>max</td>
<td>Maximum value allowed for the field (N/A for some field types).</td>
</tr>
<tr>
<td>maxlength</td>
<td>Maximum number of characters allowed for the field value.
</td>
</tr>
<tr>
<td>min</td>
<td>Minimum value allowed for the field (only applicable to integer, decimal, money field types).</td>
</tr>
<tr>
<td>minlength</td>
<td>Minimum number of characters allowed for the field value to be valid.
</td>
</tr>
<tr>
<td>regex
</td>
<td>Regular expression to validate the field value against.
</td>
</tr>
<tr>
<td>required
</td>
<td>Determines if the field is required for saving the model.
</td>
</tr>
<tr>
<td>unique<span class="evol-asterix">*</span>
</td>
<td>Do not allow duplicate values.
</td>
</tr>
<tr>
<td>customvalidation</td>
<td>Name of the Javascript custom method for the field validation (validation for required, min, max, type is still performed in addition).</td>
</tr>
<tr>
<th colspan="2">Behavior</th>
</tr>
<tr>
<td>help
</td>
<td>Help tip for the field (only used in Edit, Browse, and Mini views).
</td>
</tr>
<tr>
<td>link<span class="evol-asterix">*</span>
</td>
<td>Displays the field as a link to another web page.
</td>
</tr>
<tr>
<td>linklabel<span class="evol-asterix">*</span>
</td>
<td>Display a sentence or an image as the link. Can also be a function (model).
</td>
</tr>
<tr>
<td>linktarget<span class="evol-asterix">*</span>
</td>
<td>Directs to a new tab in the browser (HTML attribute "target").
</td>
</tr>
<tr>
<td>optional<span class="evol-asterix">*</span>
</td>
<td>Filter condition to hide the field.
<br>Example: function(model){return model.get('type')=='integer';}
</td>
</tr>
<tr>
<td>readonly
</td>
<td>
Determines if the field is read only or can be edited
(will later have the possibility for fields that can be set at creation but not edited later).
</td>
</tr>
<tr>
<td>sortable
</td>
<td>Column can be sorted by the field value (in "List" view).
</td>
</tr>
<tr>
<td>tooltip<span class="evol-asterix">*</span>
</td>
<td>Tooltip when the mouse is over the field.
</td>
</tr>
<tr>
<td>viewcharts
</td>
<td>Determines if a chart is displayed in the Charts view for grouping by this specific field.
</td>
</tr>
<tr>
<td>viewmany, viewlist, <br/>
viewcards, viewedit, <br/>
viewmini, viewexport,
viewcharts
</td>
<td>Determines if the field is available in specific views.
</td>
</tr>
</tbody></table>
</section>
<a name="panel" class="evo-anchor"> </a>
<section>
<h1>panel</h1>
<p>The <code>panel</code> element is used to group fields together in the forms.
Fields are grouped in panels and panels can be grouped in tabs. </p>
<table class="table table-bordered">
<tbody>
<tr>
<td style="width: 120px; ">id</td>
<td>Panel Id in the UI (if not specified, the default is "p-<panel index>").</td>
</tr>
<tr>
<td>css
</td>
<td>Additional CSS class for the panel.
</td>
</tr>
<tr>
<td>csslabel
</td>
<td>
Additional CSS class for the panel title (label).
</td>
</tr>
<tr>
<td>elements[]<span class="evol-required">*</span>
</td>
<td>
Array of fields.
</td>
</tr>
<tr>
<td>help
</td>
<td>Introduction text about for the panel and its fields.
</td>
</tr>
<tr>
<td>label<span class="evol-required">*</span>
</td>
<td>Panel title.
</td>
</tr>
<tr>
<td>label2
</td>
<td>Panel sub-title.
</td>
</tr>
<tr>
<td>optional<span class="evol-asterix">*</span>
</td>
<td>
Skips the panel from displaying, if every field contained is empty and
optional (only applies to the view Browse).
</td>
</tr>
<tr>
<td>readonly
</td>
<td>
Makes all fields in the panel read-only (in Edit view).
</td>
</tr>
<tr>
<td>width
</td>
<td>Width of the panel in percentage of the total width of the form.<br />
Example: <code>width</code>="100" for the full width.
</td>
</tr>
</tbody></table>
</section>
<a name="panel-list" class="evo-anchor"> </a>
<section>
<h1>panel-list</h1>
<p>Similar to a panel but used to display a sub-collection (an array of objects). It is the "details" part in a "master-details" (and can have multiple details).</p>
<table class="table table-bordered">
<tbody>
<tr>
<td>attribute<span class="evol-required">*</span></td>
<td>Model attribute for the sub-collection.</td>
</tr>
<tr>
<td style="width: 120px; ">id<span class="evol-required">*</span></td>
<td>Panel Id in the UI.</td>
</tr>
<tr>
<td>badge<span class="evol-asterix">*</span>
</td>
<td>Field name or function which value is displayed as a badge in the panel header.
</td>
</tr>
<tr>
<td>css
</td>
<td>CSS class for the panel (replaces of the one specified in the view options). Possible values: "panel-primary", "panel-success", "panel-warning"...
</td>
</tr>
<tr>
<td>csslabel
</td>
<td>
Additional CSS class for the panel title (label).
</td>
</tr>
<tr>
<td>elements[]<span class="evol-required">*</span>
</td>
<td>
Array of fields in the sub-collection.
</td>
</tr>
<tr>
<td>label
</td>
<td>Panel title.
</td>
</tr>
<tr>
<td>label2
</td>
<td>Panel sub-title.
</td>
</tr>
<tr>
<td>readonly<span class="evol-asterix">*</span>
</td>
<td>
Makes all fields in the panel-list read-only (not implemented yet).
</td>
</tr>
<tr>
<td>width
</td>
<td>Width of the panel in percentage of the total width of the form.<br />
Example: <code>width</code>="100" for the full width.
</td>
</tr>
</tbody></table>
</section>
<a name="tab" class="evo-anchor"> </a>
<section>
<h1>tab</h1>
<p>The <code>tab</code> element can be used to group panels and panel-lists.</p>
<table class="table table-bordered">
<tbody><tr>
<td style="width: 120px; ">
css
</td>
<td>
Additional CSS class for the tab content.
</td>
</tr>
<tr>
<td>
csslabel
</td>
<td>
Additional CSS class for the tab title.
</td>
</tr>
<tr>
<td>elements[]<span class="evol-required">*</span>
</td>
<td>
Array of panels and panel-lists.
</td>
</tr>
<tr>
<td>
label<span class="evol-required">*</span>
</td>
<td>
Tab title.
</td>
</tr>
</tbody></table>
</section>
<a name="sample" class="evo-anchor"> </a>
<section>
<h1>Sample UI-model</h1>
<p>The classic "todo app".</p>
<iframe style="width:100%;height:300px" src="../js/ui-models/apps/todo.js"></iframe>
</section>
<p><br/>evolutility.js at <a href="https://github.com/evoluteur/evolutility" target="download">GitHub</a></p>
<div class="footer">© 2015 Olivier Giulieri</div>
</div>
</body>
</html>