equal
deleted
inserted
replaced
59 return { |
59 return { |
60 _id: this.get("_id"), |
60 _id: this.get("_id"), |
61 title: this.get("title"), |
61 title: this.get("title"), |
62 uri: this.get("uri"), |
62 uri: this.get("uri"), |
63 description: this.get("description"), |
63 description: this.get("description"), |
64 color: this.get("color"), |
64 color: this.get("color") |
65 }; |
65 }; |
66 }, |
66 } |
67 }); |
67 }); |
68 |
68 |
69 // NODE |
69 // NODE |
70 var Node = Models.Node = RenkanModel.extend({ |
70 var Node = Models.Node = RenkanModel.extend({ |
71 type: "node", |
71 type: "node", |
91 color: this.get("color"), |
91 color: this.get("color"), |
92 created_by: this.get("created_by") ? this.get("created_by").get("_id") : null, |
92 created_by: this.get("created_by") ? this.get("created_by").get("_id") : null, |
93 size: this.get("size"), |
93 size: this.get("size"), |
94 "clip-path": this.get("clip-path") |
94 "clip-path": this.get("clip-path") |
95 }; |
95 }; |
96 }, |
96 } |
97 }); |
97 }); |
98 |
98 |
99 // EDGE |
99 // EDGE |
100 var Edge = Models.Edge = RenkanModel.extend({ |
100 var Edge = Models.Edge = RenkanModel.extend({ |
101 type: "edge", |
101 type: "edge", |
112 }, |
112 }, |
113 { |
113 { |
114 type: Backbone.HasOne, |
114 type: Backbone.HasOne, |
115 key: "to", |
115 key: "to", |
116 relatedModel: Node |
116 relatedModel: Node |
117 }, |
117 } |
118 ], |
118 ], |
119 prepare: function(options) { |
119 prepare: function(options) { |
120 var project = options.project; |
120 var project = options.project; |
121 this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user); |
121 this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user); |
122 this.addReference(options, "from", project.get("nodes"), options.from); |
122 this.addReference(options, "from", project.get("nodes"), options.from); |
132 from: this.get("from") ? this.get("from").get("_id") : null, |
132 from: this.get("from") ? this.get("from").get("_id") : null, |
133 to: this.get("to") ? this.get("to").get("_id") : null, |
133 to: this.get("to") ? this.get("to").get("_id") : null, |
134 color: this.get("color"), |
134 color: this.get("color"), |
135 created_by: this.get("created_by") ? this.get("created_by").get("_id") : null |
135 created_by: this.get("created_by") ? this.get("created_by").get("_id") : null |
136 }; |
136 }; |
137 }, |
137 } |
138 }); |
138 }); |
139 |
139 |
140 // PROJECT |
140 // PROJECT |
141 var Project = Models.Project = RenkanModel.extend({ |
141 var Project = Models.Project = RenkanModel.extend({ |
142 type: "project", |
142 type: "project", |
146 key: "users", |
146 key: "users", |
147 relatedModel: User, |
147 relatedModel: User, |
148 reverseRelation: { |
148 reverseRelation: { |
149 key: 'project', |
149 key: 'project', |
150 includeInJSON: '_id' |
150 includeInJSON: '_id' |
151 }, |
151 } |
152 }, |
152 }, |
153 { |
153 { |
154 type: Backbone.HasMany, |
154 type: Backbone.HasMany, |
155 key: "nodes", |
155 key: "nodes", |
156 relatedModel: Node, |
156 relatedModel: Node, |
157 reverseRelation: { |
157 reverseRelation: { |
158 key: 'project', |
158 key: 'project', |
159 includeInJSON: '_id' |
159 includeInJSON: '_id' |
160 }, |
160 } |
161 }, |
161 }, |
162 { |
162 { |
163 type: Backbone.HasMany, |
163 type: Backbone.HasMany, |
164 key: "edges", |
164 key: "edges", |
165 relatedModel: Edge, |
165 relatedModel: Edge, |
166 reverseRelation: { |
166 reverseRelation: { |
167 key: 'project', |
167 key: 'project', |
168 includeInJSON: '_id' |
168 includeInJSON: '_id' |
169 }, |
169 } |
170 } |
170 } |
171 ], |
171 ], |
172 addUser: function(_props, _options) { |
172 addUser: function(_props, _options) { |
173 _props.project = this; |
173 _props.project = this; |
174 var _user = User.findOrCreate(_props); |
174 var _user = User.findOrCreate(_props); |
258 description: this.get("description"), |
258 description: this.get("description"), |
259 color: this.get("color"), |
259 color: this.get("color"), |
260 project: (this.get("project") != null)?this.get("project").get("id"):null, |
260 project: (this.get("project") != null)?this.get("project").get("id"):null, |
261 site_id: this.get("site_id") |
261 site_id: this.get("site_id") |
262 }; |
262 }; |
263 }, |
263 } |
264 }); |
264 }); |
265 |
265 |
266 var UsersList = Models.UsersList = Backbone.Collection.extend({ |
266 var UsersList = Models.UsersList = Backbone.Collection.extend({ |
267 model: RosterUser |
267 model: RosterUser |
268 }); |
268 }); |