2015-08-18 22:04:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-08-19 19:03:25 +00:00
|
|
|
/* globals Handlebars */
|
|
|
|
|
2015-08-18 22:04:16 +00:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var TEMPLATE =
|
|
|
|
'<span class="reshare">' +
|
2015-09-01 10:43:04 +00:00
|
|
|
' <div class="avatar" data-userName="{{reshareOwner}}"></div>' +
|
2015-08-18 22:04:16 +00:00
|
|
|
' {{sharedByText}}' +
|
|
|
|
'</span><br/>'
|
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Share.ShareDialogView
|
|
|
|
* @member {OC.Share.ShareItemModel} model
|
|
|
|
* @member {jQuery} $el
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Represents the GUI of the share dialogue
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var ShareDialogResharerInfoView = OC.Backbone.View.extend({
|
|
|
|
/** @type {string} **/
|
|
|
|
id: 'shareDialogResharerInfo',
|
|
|
|
|
|
|
|
/** @type {string} **/
|
|
|
|
tagName: 'div',
|
|
|
|
|
|
|
|
/** @type {string} **/
|
|
|
|
className: 'reshare',
|
|
|
|
|
|
|
|
/** @type {OC.Share.ShareConfigModel} **/
|
|
|
|
configModel: undefined,
|
|
|
|
|
|
|
|
/** @type {Function} **/
|
|
|
|
_template: undefined,
|
|
|
|
|
|
|
|
initialize: function(options) {
|
|
|
|
var view = this;
|
|
|
|
|
2015-08-21 13:00:15 +00:00
|
|
|
this.model.on('change:reshare', function() {
|
2015-08-18 22:04:16 +00:00
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
if(!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel;
|
|
|
|
} else {
|
2015-08-24 21:20:01 +00:00
|
|
|
throw 'missing OC.Share.ShareConfigModel';
|
2015-08-18 22:04:16 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2015-09-15 13:29:30 +00:00
|
|
|
if (!this.model.hasReshare()
|
|
|
|
|| this.model.getReshareOwner() === OC.currentUser)
|
2015-08-18 22:04:16 +00:00
|
|
|
{
|
2015-08-21 13:00:15 +00:00
|
|
|
this.$el.empty();
|
2015-08-18 22:04:16 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
var reshareTemplate = this.template();
|
|
|
|
var ownerDisplayName = this.model.getReshareOwnerDisplayname();
|
|
|
|
var sharedByText = '';
|
|
|
|
if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you and the group {group} by {owner}',
|
|
|
|
{
|
2016-11-30 19:56:10 +00:00
|
|
|
group: this.model.getReshareWithDisplayName(),
|
2015-08-18 22:04:16 +00:00
|
|
|
owner: ownerDisplayName
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you by {owner}',
|
|
|
|
{ owner: ownerDisplayName }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-24 21:20:01 +00:00
|
|
|
this.$el.html(reshareTemplate({
|
2015-09-01 10:43:04 +00:00
|
|
|
reshareOwner: this.model.getReshareOwner(),
|
2015-08-18 22:04:16 +00:00
|
|
|
sharedByText: sharedByText
|
|
|
|
}));
|
|
|
|
|
2017-02-13 23:49:05 +00:00
|
|
|
this.$el.find('.avatar').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.avatar($this.data('username'), 32);
|
|
|
|
});
|
2015-09-12 12:21:14 +00:00
|
|
|
|
2015-08-18 22:04:16 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
template: function () {
|
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
|
|
|
return this._template;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView;
|
|
|
|
|
|
|
|
})();
|