nextcloud/apps/files_sharing/src/sharetabview.js

109 lines
2.6 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 id="collaborationResources"></div>' +
2015-08-24 14:00:03 +03:00
'</div>';
/**
* @memberof OCA.Sharing
*/
var ShareTabView = OCA.Files.DetailTabView.extend(
/** @lends OCA.Sharing.ShareTabView.prototype */ {
id: 'shareTabView',
className: 'tab shareTabView',
initialize: function(name, options) {
OCA.Files.DetailTabView.prototype.initialize.call(this, name, options);
OC.Plugins.attach('OCA.Sharing.ShareTabView', this);
},
2015-08-24 14:00:03 +03:00
template: function(params) {
return TEMPLATE;
2015-08-24 14:00:03 +03:00
},
getLabel: function() {
return t('files_sharing', 'Sharing');
},
getIcon: function() {
return 'icon-shared';
},
/**
* 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());
if (_.isUndefined(this.model.get('sharePermissions'))) {
this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes));
}
// 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);
});
import('./collaborationresources').then((Resources) => {
var vm = new Resources.Vue({
el: '#collaborationResources',
render: h => h(Resources.View),
data: {
model: this.model.toJSON()
},
});
this.model.on('change', () => { vm.data = this.model.toJSON() })
})
} else {
2015-08-24 14:00:03 +03:00
this.$el.empty();
// TODO: render placeholder text?
}
this.trigger('rendered');
}
});
OCA.Sharing.ShareTabView = ShareTabView;
})();