2015-07-31 01:07:41 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
if(!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
OC.Share.Types = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} OC.Share.Types.Reshare
|
|
|
|
* @property {string} uid_owner
|
|
|
|
* @property {number} share_type
|
|
|
|
* @property {string} share_with
|
|
|
|
* @property {string} displayname_owner
|
|
|
|
* @property {number} permissions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} OC.Share.Types.ShareInfo
|
|
|
|
* @property {number} share_type
|
|
|
|
* @property {number} permissions
|
|
|
|
* @property {number} file_source optional
|
|
|
|
* @property {number} item_source
|
|
|
|
* @property {string} token
|
|
|
|
* @property {string} share_with
|
|
|
|
* @property {string} share_with_displayname
|
|
|
|
* @property {string} share_mail_send
|
|
|
|
* @property {bool} collection //TODO: verify
|
|
|
|
* @property {Date} expiration optional?
|
|
|
|
* @property {number} stime optional?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} OC.Share.Types.ShareItemInfo
|
|
|
|
* @property {OC.Share.Types.Reshare} reshare
|
|
|
|
* @property {OC.Share.Types.ShareInfo[]} shares
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Share.ShareItemModel
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Represents the GUI of the share dialogue
|
|
|
|
*
|
2015-08-11 15:10:25 +03:00
|
|
|
* // FIXME: use OC Share API once #17143 is done
|
2015-07-31 01:07:41 +03:00
|
|
|
*/
|
2015-08-10 23:23:52 +03:00
|
|
|
var ShareItemModel = OC.Backbone.Model.extend({
|
|
|
|
initialize: function() {
|
2015-08-11 15:10:25 +03:00
|
|
|
this.fetch();
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
/**
|
|
|
|
* whether this item has reshare information
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2015-07-31 01:07:41 +03:00
|
|
|
hasReshare: function() {
|
2015-08-10 23:23:52 +03:00
|
|
|
return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner);
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2015-07-31 01:07:41 +03:00
|
|
|
getReshareOwner: function() {
|
2015-08-10 23:23:52 +03:00
|
|
|
return this.get('reshare').uid_owner;
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2015-07-31 01:07:41 +03:00
|
|
|
getReshareOwnerDisplayname: function() {
|
2015-08-10 23:23:52 +03:00
|
|
|
return this.get('reshare').displayname_owner;
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2015-07-31 01:07:41 +03:00
|
|
|
getReshareWith: function() {
|
2015-08-10 23:23:52 +03:00
|
|
|
return this.get('reshare').share_with;
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
/**
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
2015-07-31 01:07:41 +03:00
|
|
|
getReshareType: function() {
|
2015-08-10 23:23:52 +03:00
|
|
|
return this.get('reshare').share_type;
|
2015-07-31 01:07:41 +03:00
|
|
|
},
|
|
|
|
|
2015-08-11 15:10:25 +03:00
|
|
|
fetch: function() {
|
2015-07-31 01:07:41 +03:00
|
|
|
/** var {OC.Share.Types.ShareItemInfo} **/
|
2015-08-10 23:23:52 +03:00
|
|
|
var data = OC.Share.loadItem(this.get('itemType'), this.get('itemSource'));
|
2015-08-11 15:10:25 +03:00
|
|
|
var attributes = this.parse(data);
|
|
|
|
this.set(attributes);
|
|
|
|
console.warn(this.attributes);
|
|
|
|
},
|
|
|
|
|
|
|
|
parse: function(data) {
|
2015-07-31 01:07:41 +03:00
|
|
|
if(data === false) {
|
|
|
|
console.warn('no data was returned');
|
2015-08-11 15:10:25 +03:00
|
|
|
return {};
|
2015-07-31 01:07:41 +03:00
|
|
|
}
|
2015-08-10 23:23:52 +03:00
|
|
|
var attributes = {
|
|
|
|
reshare: data.reshare,
|
|
|
|
shares: data.shares
|
|
|
|
};
|
2015-08-11 15:10:25 +03:00
|
|
|
return attributes;
|
2015-07-31 01:07:41 +03:00
|
|
|
}
|
2015-08-10 23:23:52 +03:00
|
|
|
});
|
2015-07-31 01:07:41 +03:00
|
|
|
|
|
|
|
OC.Share.ShareItemModel = ShareItemModel;
|
|
|
|
})();
|