started to port the Model to Backbone`s
This commit is contained in:
parent
ea6e380efe
commit
1651b8212c
|
@ -377,7 +377,8 @@ OC.Share = _.extend(OC.Share, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) {
|
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({
|
var dialogView = new OC.Share.ShareDialogView({
|
||||||
id: 'dropdown',
|
id: 'dropdown',
|
||||||
model: itemModel,
|
model: itemModel,
|
||||||
|
|
|
@ -55,59 +55,50 @@
|
||||||
this.initialize(itemType, itemSource);
|
this.initialize(itemType, itemSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: migration is to Backbone.Model still WIP, only pushing for the night.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @memberof OCA.Sharing
|
* @memberof OCA.Sharing
|
||||||
*/
|
*/
|
||||||
ShareItemModel.prototype = {
|
var ShareItemModel = OC.Backbone.Model.extend({
|
||||||
/** @var {string} **/
|
initialize: function() {
|
||||||
_itemType: null,
|
this._retrieveData(); // TODO I need to get my head around fetch() respectively sync() and url(). Left for later, it's late.
|
||||||
/** @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();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasReshare: function() {
|
hasReshare: function() {
|
||||||
return _.isObject(this._reshare) && !_.isUndefined(this._reshare.uid_owner);
|
return _.isObject(this.get('reshare')) && !_.isUndefined(this.get('reshare').uid_owner);
|
||||||
},
|
},
|
||||||
|
|
||||||
getReshareOwner: function() {
|
getReshareOwner: function() {
|
||||||
return this._reshare.uid_owner;
|
return this.get('reshare').uid_owner;
|
||||||
},
|
},
|
||||||
|
|
||||||
getReshareOwnerDisplayname: function() {
|
getReshareOwnerDisplayname: function() {
|
||||||
return this._reshare.displayname_owner;
|
return this.get('reshare').displayname_owner;
|
||||||
},
|
},
|
||||||
|
|
||||||
getReshareWith: function() {
|
getReshareWith: function() {
|
||||||
return this._reshare.share_with;
|
return this.get('reshare').share_with;
|
||||||
},
|
},
|
||||||
|
|
||||||
getReshareType: function() {
|
getReshareType: function() {
|
||||||
return this._reshare.share_type;
|
return this.get('reshare').share_type;
|
||||||
},
|
},
|
||||||
|
|
||||||
_retrieveData: function() {
|
_retrieveData: function() {
|
||||||
/** var {OC.Share.Types.ShareItemInfo} **/
|
/** 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) {
|
if(data === false) {
|
||||||
console.warn('no data was returned');
|
console.warn('no data was returned');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._reshare = data.reshare;
|
var attributes = {
|
||||||
this._shares = data.shares;
|
reshare: data.reshare,
|
||||||
|
shares: data.shares
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
this.set(attributes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
OC.Share.ShareItemModel = ShareItemModel;
|
OC.Share.ShareItemModel = ShareItemModel;
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue