/
view_config.js
49 lines (37 loc) · 1.41 KB
/
view_config.js
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
// ==========================================================================
// Project: Greenhouse.ViewConfig
// Copyright: ©2010 Mike Ball
// ==========================================================================
/*globals Greenhouse js_beautify*/
/** @class
(Document your Model here)
@extends SC.Record
@version 0.1
*/
Greenhouse.ViewConfig = SC.Record.extend(
/** @scope Greenhouse.ViewConfig.prototype */ {
primaryKey: 'path',
views: SC.Record.toMany('Greenhouse.Design', {nested: YES}),
panes: SC.Record.toMany('Greenhouse.Design', {nested: YES}),
controllers: SC.Record.toMany('Greenhouse.Design', {nested: YES}),
canEdit: SC.Record.attr(Boolean),
name: SC.Record.attr(String),
path: SC.Record.attr(String),
body: function(){
var ret = {name: this.get('name'), path: this.get('path'), views: [], controllers: [], panes: []},
views = this.get('views'),
controllers = this.get('controllers'),
panes = this.get('panes');
views.forEach(function(i){
ret.views.push(i.get('attributes'));
});
controllers.forEach(function(i){
ret.controllers.push(i.get('attributes'));
});
panes.forEach(function(i){
ret.panes.push(i.get('attributes'));
});
return js_beautify(SC.json.encode(ret));
}.property('views', 'panes', 'controllers')
}) ;
Greenhouse.CONFIG_QUERY = SC.Query.remote(Greenhouse.ViewConfig);