server/apps/files_sharing/js/sharetabview.js

84 lines
1.9 KiB
JavaScript
Raw Normal View History

/*
* Copyright (c) 2015
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/
2016-07-05 21:17:43 +00:00
/* @global Handlebars */
(function() {
var TEMPLATE =
2015-08-24 11:00:03 +00:00
'<div>' +
'<div class="dialogContainer"></div>' +
'</div>';
/**
* @memberof OCA.Sharing
*/
var ShareTabView = OCA.Files.DetailTabView.extend(
/** @lends OCA.Sharing.ShareTabView.prototype */ {
id: 'shareTabView',
className: 'tab shareTabView',
2015-08-24 11:00:03 +00:00
template: function(params) {
if (!this._template) {
this._template = Handlebars.compile(TEMPLATE);
}
return this._template(params);
},
getLabel: function() {
return t('files_sharing', 'Sharing');
},
/**
* Renders this details view
*/
render: function() {
var self = this;
2015-08-24 11:00:03 +00:00
if (this._dialog) {
// remove/destroy older instance
this._dialog.model.off();
2015-08-24 11:00:03 +00:00
this._dialog.remove();
this._dialog = null;
}
if (this.model) {
2015-09-15 13:29:30 +00:00
this.$el.html(this.template());
// 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();
this._dialog.model.fetch();
this._dialog.model.on('change', function() {
self.trigger('sharesChanged', shareModel);
});
} else {
2015-08-24 11:00:03 +00:00
this.$el.empty();
// TODO: render placeholder text?
}
}
});
OCA.Sharing.ShareTabView = ShareTabView;
})();