2015-07-15 17:09:00 +03:00
|
|
|
/*
|
|
|
|
* 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 */
|
|
|
|
|
2015-07-15 17:09:00 +03:00
|
|
|
(function() {
|
|
|
|
var TEMPLATE =
|
2015-08-24 14:00:03 +03:00
|
|
|
'<div>' +
|
|
|
|
'<div class="dialogContainer"></div>' +
|
2019-01-17 14:56:18 +03:00
|
|
|
'<div id="collaborationResources"></div>' +
|
2015-08-24 14:00:03 +03:00
|
|
|
'</div>';
|
2015-07-15 17:09:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
*/
|
2015-08-12 18:30:20 +03:00
|
|
|
var ShareTabView = OCA.Files.DetailTabView.extend(
|
2015-07-15 17:09:00 +03:00
|
|
|
/** @lends OCA.Sharing.ShareTabView.prototype */ {
|
2015-08-12 18:30:20 +03:00
|
|
|
id: 'shareTabView',
|
|
|
|
className: 'tab shareTabView',
|
2015-07-15 17:09:00 +03:00
|
|
|
|
2019-02-12 18:52:26 +03:00
|
|
|
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) {
|
2018-10-01 21:08:49 +03:00
|
|
|
return TEMPLATE;
|
2015-08-24 14:00:03 +03:00
|
|
|
},
|
2015-07-15 17:09:00 +03:00
|
|
|
|
|
|
|
getLabel: function() {
|
|
|
|
return t('files_sharing', 'Sharing');
|
|
|
|
},
|
|
|
|
|
2018-10-18 16:47:18 +03:00
|
|
|
getIcon: function() {
|
|
|
|
return 'icon-shared';
|
|
|
|
},
|
|
|
|
|
2015-07-15 17:09:00 +03:00
|
|
|
/**
|
|
|
|
* Renders this details view
|
|
|
|
*/
|
|
|
|
render: function() {
|
2015-09-14 18:20:51 +03:00
|
|
|
var self = this;
|
2015-08-24 14:00:03 +03:00
|
|
|
if (this._dialog) {
|
|
|
|
// remove/destroy older instance
|
2015-09-14 18:20:51 +03:00
|
|
|
this._dialog.model.off();
|
2015-08-24 14:00:03 +03:00
|
|
|
this._dialog.remove();
|
|
|
|
this._dialog = null;
|
2015-07-15 17:09:00 +03:00
|
|
|
}
|
|
|
|
|
2015-08-12 18:30:20 +03:00
|
|
|
if (this.model) {
|
2015-09-15 16:29:30 +03:00
|
|
|
this.$el.html(this.template());
|
2015-07-15 18:35:35 +03:00
|
|
|
|
2016-10-10 11:15:42 +03:00
|
|
|
if (_.isUndefined(this.model.get('sharePermissions'))) {
|
|
|
|
this.model.set('sharePermissions', OCA.Sharing.Util.getSharePermissions(this.model.attributes));
|
|
|
|
}
|
|
|
|
|
2015-09-15 11:27:33 +03:00
|
|
|
// 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();
|
2015-09-14 18:20:51 +03:00
|
|
|
this._dialog.model.fetch();
|
|
|
|
this._dialog.model.on('change', function() {
|
|
|
|
self.trigger('sharesChanged', shareModel);
|
|
|
|
});
|
2019-01-17 14:56:18 +03:00
|
|
|
|
2019-02-20 20:40:02 +03:00
|
|
|
import('./collaborationresources').then((Resources) => {
|
2019-01-17 15:11:16 +03:00
|
|
|
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() })
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2015-07-15 17:09:00 +03:00
|
|
|
} else {
|
2015-08-24 14:00:03 +03:00
|
|
|
this.$el.empty();
|
2015-07-15 17:09:00 +03:00
|
|
|
// TODO: render placeholder text?
|
|
|
|
}
|
2019-02-12 18:52:26 +03:00
|
|
|
this.trigger('rendered');
|
2015-07-15 17:09:00 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
OCA.Sharing.ShareTabView = ShareTabView;
|
|
|
|
})();
|
|
|
|
|