2015-07-15 14:09:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var TEMPLATE =
|
2015-08-24 11:00:03 +00:00
|
|
|
'<div>' +
|
|
|
|
'<div class="dialogContainer"></div>' +
|
|
|
|
'</div>';
|
2015-07-15 14:09:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
*/
|
2015-08-12 15:30:20 +00:00
|
|
|
var ShareTabView = OCA.Files.DetailTabView.extend(
|
2015-07-15 14:09:00 +00:00
|
|
|
/** @lends OCA.Sharing.ShareTabView.prototype */ {
|
2015-08-12 15:30:20 +00:00
|
|
|
id: 'shareTabView',
|
|
|
|
className: 'tab shareTabView',
|
2015-07-15 14:09:00 +00:00
|
|
|
|
2015-08-24 11:00:03 +00:00
|
|
|
template: function(params) {
|
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
|
|
|
return this._template(params);
|
|
|
|
},
|
2015-07-15 14:09:00 +00:00
|
|
|
|
|
|
|
getLabel: function() {
|
|
|
|
return t('files_sharing', 'Sharing');
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders this details view
|
|
|
|
*/
|
|
|
|
render: function() {
|
2015-09-14 15:20:51 +00:00
|
|
|
var self = this;
|
2015-08-24 11:00:03 +00:00
|
|
|
if (this._dialog) {
|
|
|
|
// remove/destroy older instance
|
2015-09-14 15:20:51 +00:00
|
|
|
this._dialog.model.off();
|
2015-08-24 11:00:03 +00:00
|
|
|
this._dialog.remove();
|
|
|
|
this._dialog = null;
|
2015-07-15 14:09:00 +00:00
|
|
|
}
|
|
|
|
|
2015-08-12 15:30:20 +00:00
|
|
|
if (this.model) {
|
2015-09-15 13:29:30 +00:00
|
|
|
this.$el.html(this.template());
|
2015-07-15 15:35:35 +00:00
|
|
|
|
2015-09-15 08:27:33 +00:00
|
|
|
// TODO: the model should read these directly off the passed fileInfoModel
|
2015-08-24 11:00:03 +00:00
|
|
|
var attributes = {
|
2015-09-13 22:43:11 +00:00
|
|
|
itemType: this.model.isDirectory() ? 'folder' : 'file',
|
2015-08-24 11:00:03 +00:00
|
|
|
itemSource: this.model.get('id'),
|
2015-08-24 11:15:33 +00:00
|
|
|
possiblePermissions: this.model.get('sharePermissions')
|
2015-08-24 11:00:03 +00:00
|
|
|
};
|
|
|
|
var configModel = new OC.Share.ShareConfigModel();
|
2015-09-03 13:53:17 +00:00
|
|
|
var shareModel = new OC.Share.ShareItemModel(attributes, {
|
|
|
|
configModel: configModel,
|
|
|
|
fileInfoModel: this.model
|
|
|
|
});
|
2015-08-24 11:00:03 +00:00
|
|
|
this._dialog = new OC.Share.ShareDialogView({
|
|
|
|
configModel: configModel,
|
|
|
|
model: shareModel
|
|
|
|
});
|
|
|
|
this.$el.find('.dialogContainer').append(this._dialog.$el);
|
|
|
|
this._dialog.render();
|
2015-09-14 15:20:51 +00:00
|
|
|
this._dialog.model.fetch();
|
|
|
|
this._dialog.model.on('change', function() {
|
|
|
|
self.trigger('sharesChanged', shareModel);
|
|
|
|
});
|
2015-07-15 14:09:00 +00:00
|
|
|
} else {
|
2015-08-24 11:00:03 +00:00
|
|
|
this.$el.empty();
|
2015-07-15 14:09:00 +00:00
|
|
|
// TODO: render placeholder text?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
OCA.Sharing.ShareTabView = ShareTabView;
|
|
|
|
})();
|
|
|
|
|