client/js/models.js
changeset 443 4c7ab16e5845
parent 435 e529b633c339
child 444 19f0b7803aed
equal deleted inserted replaced
442:adb907bba956 443:4c7ab16e5845
   189         }
   189         }
   190     });
   190     });
   191 
   191 
   192     // PROJECT
   192     // PROJECT
   193     var Project = Models.Project = RenkanModel.extend({
   193     var Project = Models.Project = RenkanModel.extend({
       
   194         schemaVersion : 1,
   194         type : "project",
   195         type : "project",
   195         blacklist : [ 'save_status', ],
   196         blacklist : [ 'saveStatus', 'loadingStatus',],
   196         relations : [ {
   197         relations : [ {
   197             type : Backbone.HasMany,
   198             type : Backbone.HasMany,
   198             key : "users",
   199             key : "users",
   199             relatedModel : User,
   200             relatedModel : User,
   200             reverseRelation : {
   201             reverseRelation : {
   266                 if (_item) {
   267                 if (_item) {
   267                     _item.project = _project;
   268                     _item.project = _project;
   268                 }
   269                 }
   269               }
   270               }
   270             );
   271             );
       
   272         },
       
   273         getSchemaVersion : function(data) {
       
   274           var t = data;
       
   275           if(typeof(t) === "undefined") {
       
   276             t = this;
       
   277           }
       
   278           var version = t.schemaVersion;
       
   279           if(!version) {
       
   280             return 1;
       
   281           }
       
   282           else {
       
   283             return version;
       
   284           }
   271         },
   285         },
   272         // Add event handler to remove edges when a node is removed
   286         // Add event handler to remove edges when a node is removed
   273         initialize : function() {
   287         initialize : function() {
   274             var _this = this;
   288             var _this = this;
   275             this.on("remove:nodes", function(_node) {
   289             this.on("remove:nodes", function(_node) {
   281                                 }));
   295                                 }));
   282             });
   296             });
   283         },
   297         },
   284         toJSON : function() {
   298         toJSON : function() {
   285             var json = _.clone(this.attributes);
   299             var json = _.clone(this.attributes);
       
   300             json.schema_version = this.schemaVersion;
   286             for ( var attr in json) {
   301             for ( var attr in json) {
   287                 if ((json[attr] instanceof Backbone.Model) ||
   302                 if ((json[attr] instanceof Backbone.Model) ||
   288                         (json[attr] instanceof Backbone.Collection) ||
   303                         (json[attr] instanceof Backbone.Collection) ||
   289                         (json[attr] instanceof RenkanModel)) {
   304                         (json[attr] instanceof RenkanModel)) {
   290                     json[attr] = json[attr].toJSON();
   305                     json[attr] = json[attr].toJSON();