nextcloud/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-06 00:17:43 +03:00
/* @global Handlebars */
(function() {
var TEMPLATE =
2015-08-24 14:00:03 +03: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 14:00:03 +03: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 14:00:03 +03:00
if (this._dialog) {
// remove/destroy older instance
this._dialog.model.off();
2015-08-24 14:00:03 +03:00
this._dialog.remove();
this._dialog = null;
}
if (this.model) {
2015-09-15 16:29:30 +03:00
this.$el.html(this.template());
// TODO: the model should read these directly off the passed fileInfoModel
2015-08-24 14:00:03 +03:00
var attributes = {
2015-09-14 01:43:11 +03:00
itemType: this.model.isDirectory() ? 'folder' : 'file',
2015-08-24 14:00:03 +03:00
itemSource: this.model.get('id'),
2015-08-24 14:15:33 +03:00
possiblePermissions: this.model.get('sharePermissions')
2015-08-24 14:00:03 +03:00
};
var configModel = new OC.Share.ShareConfigModel();
2015-09-03 16:53:17 +03:00
var shareModel = new OC.Share.ShareItemModel(attributes, {
configModel: configModel,
fileInfoModel: this.model
});
2015-08-24 14:00:03 +03: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 14:00:03 +03:00
this.$el.empty();
// TODO: render placeholder text?
}
}
});
OCA.Sharing.ShareTabView = ShareTabView;
})();