diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-08-11 14:10:25 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:25 +0200 |
commit | 7971bc1ac0a52ed5171a3a663b6e18dcda93bbc3 (patch) | |
tree | 261a02f9fac1e580edff3d577591c8ebf666a6a3 /core/js | |
parent | 1651b8212cf67e2ca59cf890cefe6097fbfa6a8a (diff) | |
download | nextcloud-server-7971bc1ac0a52ed5171a3a663b6e18dcda93bbc3.tar.gz nextcloud-server-7971bc1ac0a52ed5171a3a663b6e18dcda93bbc3.zip |
model now extends Backbone's model and isadjusted
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/shareitemmodel.js | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 2914b281ee1..74e696e7200 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -50,53 +50,67 @@ * * Represents the GUI of the share dialogue * - */ - var ShareItemModel = function(itemType, itemSource) { - this.initialize(itemType, itemSource); - }; - - // FIXME: migration is to Backbone.Model still WIP, only pushing for the night. - - /** - * @memberof OCA.Sharing + * // FIXME: use OC Share API once #17143 is done */ 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. + this.fetch(); }, + /** + * whether this item has reshare information + * @returns {boolean} + */ hasReshare: function() { return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner); }, + /** + * @returns {string} + */ getReshareOwner: function() { return this.get('reshare').uid_owner; }, + /** + * @returns {string} + */ getReshareOwnerDisplayname: function() { return this.get('reshare').displayname_owner; }, + /** + * @returns {string} + */ getReshareWith: function() { return this.get('reshare').share_with; }, + /** + * @returns {number} + */ getReshareType: function() { return this.get('reshare').share_type; }, - _retrieveData: function() { + fetch: function() { /** var {OC.Share.Types.ShareItemInfo} **/ var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource')); + var attributes = this.parse(data); + this.set(attributes); + console.warn(this.attributes); + }, + + parse: function(data) { if(data === false) { console.warn('no data was returned'); - return; + return {}; } var attributes = { reshare: data.reshare, shares: data.shares }; - this.set(attributes); + return attributes; } }); |