bobamo /plugins/modeleditor/views/admin/list.js

Language Javascript Lines 64
MD5 Hash 33b6981968faeca5f5775cdea45365b5
Repository git://github.com/jspears/bobamo.git View Raw File
| Open JSFiddle
 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
define(['underscore', 'Backbone', 'libs/bobamo/list', 'text!${pluginUrl}/templates/admin/table.html',
    'text!${pluginUrl}/templates/admin/table-item.html'], function (_, Backbone, ListView, tableTemplate, listItemTemplate) {

    var Model = Backbone.Model.extend({
        urlRoot:'${pluginUrl}/admin',
        schema:{
            modelName:{
                type:'String'
            },
            title:{
                type:'String'
            },
            labelAttr:{
                type:'String'
            },
            hidden:{
                type:'Checkbox'
            }
        },
        idAttribute:'modelName',
        // defaults:defaults,
        initialize:function () {
        },
//        parse:function(resp){
//            return resp.payload;
//        },
        get:function (key) {
            if (key && key.indexOf('.') > -1) {
                var split = key.split('.');
                var val = this.attributes;
                while (split.length && val)
                    val = val[split.shift()];

                return val;
            }
            return Backbone.Model.prototype.get.call(this, key);
        }

    });

    var Collection = Backbone.Collection.extend({
        model:Model,
        url:'${pluginUrl}/admin/',
        parse:function(resp){
          return resp.payload;
        },
        initialize:function () {
        }
    });

    return ListView.extend({
        template:_.template(tableTemplate),
        listItemTemplate:_.template(listItemTemplate),
        collection:new Collection(),
        model:Model,
        config:{
            title:'Model',
            modelName:'model',
            plural:'Models'
        }

    })
})
;
Back to Top