--- a/client/js/models.js Sat Apr 26 21:28:54 2014 +0200
+++ b/client/js/models.js Mon Apr 28 16:11:21 2014 +0200
@@ -1,7 +1,7 @@
(function() {
"use strict";
var root = this;
-
+
var Backbone = root.Backbone;
var Models = root.Rkns.Models = {};
@@ -136,6 +136,18 @@
};
}
});
+
+ // View
+ var View = Models.View = RenkanModel.extend({
+ type: "view",
+ relations: [
+ {
+ type: Backbone.HasOne,
+ key: "created_by",
+ relatedModel: User
+ }
+ ],
+ });
// PROJECT
var Project = Models.Project = RenkanModel.extend({
@@ -167,6 +179,15 @@
key: 'project',
includeInJSON: '_id'
}
+ },
+ {
+ type: Backbone.HasMany,
+ key: "views",
+ relatedModel: View,
+ reverseRelation: {
+ key: 'project',
+ includeInJSON: '_id'
+ }
}
],
addUser: function(_props, _options) {
@@ -187,6 +208,14 @@
this.get("edges").push(_edge, _options);
return _edge;
},
+ addView: function(_props, _options) {
+ _props.project = this;
+ // TODO: check if need to replace with create only
+ var _view = View.findOrCreate(_props);
+ // TODO: Should we remember only one view?
+ this.get("views").push(_view, _options);
+ return _view;
+ },
removeNode: function(_model) {
this.get("nodes").remove(_model);
},