diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-08-10 22:23:52 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:25 +0200 |
commit | 1651b8212cf67e2ca59cf890cefe6097fbfa6a8a (patch) | |
tree | 636ae542105349fba55a1eb4864cc45798163321 /core/js | |
parent | ea6e380efe68e7249917d6470ecdffb25edbcc47 (diff) | |
download | nextcloud-server-1651b8212cf67e2ca59cf890cefe6097fbfa6a8a.tar.gz nextcloud-server-1651b8212cf67e2ca59cf890cefe6097fbfa6a8a.zip |
started to port the Model to Backbone`s
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/share.js | 3 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 43 |
2 files changed, 19 insertions, 27 deletions
diff --git a/core/js/share.js b/core/js/share.js index 9aba894f676..59467427eb3 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -377,7 +377,8 @@ OC.Share = _.extend(OC.Share, { }); }, showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) { - var itemModel = new OC.Share.ShareItemModel(itemType, itemSource); + var attributes = {itemType: itemType, itemSource: itemSource}; + var itemModel = new OC.Share.ShareItemModel(attributes); var dialogView = new OC.Share.ShareDialogView({ id: 'dropdown', model: itemModel, diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 1db49536db5..2914b281ee1 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -55,59 +55,50 @@ this.initialize(itemType, itemSource); }; + // FIXME: migration is to Backbone.Model still WIP, only pushing for the night. + /** * @memberof OCA.Sharing */ - ShareItemModel.prototype = { - /** @var {string} **/ - _itemType: null, - /** @var {mixed} **/ //TODO: what type? - _itemSource: null, - - /** @var {OC.Share.Types.Reshare} **/ - _reshare: null, - - /** @var {OC.Share.Types.ShareInfo[]} **/ - _shares: null, - - initialize: function(itemType, itemSource) { - this._itemType = itemType; - this._itemSource = itemSource; - this._retrieveData(); + var ShareItemModel = OC.Backbone.Model.extend({ + initialize: function() { + this._retrieveData(); // TODO I need to get my head around fetch() respectively sync() and url(). Left for later, it's late. }, hasReshare: function() { - return _.isObject(this._reshare) && !_.isUndefined(this._reshare.uid_owner); + return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); }, getReshareOwner: function() { - return this._reshare.uid_owner; + return this.get('reshare').uid_owner; }, getReshareOwnerDisplayname: function() { - return this._reshare.displayname_owner; + return this.get('reshare').displayname_owner; }, getReshareWith: function() { - return this._reshare.share_with; + return this.get('reshare').share_with; }, getReshareType: function() { - return this._reshare.share_type; + return this.get('reshare').share_type; }, _retrieveData: function() { /** var {OC.Share.Types.ShareItemInfo} **/ - var data = OC.Share.loadItem(this._itemType, this._itemSource); + var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource')); if(data === false) { console.warn('no data was returned'); return; } - this._reshare = data.reshare; - this._shares = data.shares; - + var attributes = { + reshare: data.reshare, + shares: data.shares + }; + this.set(attributes); } - }; + }); OC.Share.ShareItemModel = ShareItemModel; })(); |