2015-08-19 01:04:16 +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-08-19 22:03:25 +03:00
|
|
|
/* globals Handlebars */
|
|
|
|
|
2015-08-19 01:04:16 +03:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var TEMPLATE =
|
|
|
|
'<span class="reshare">' +
|
2015-09-01 13:43:04 +03:00
|
|
|
' <div class="avatar" data-userName="{{reshareOwner}}"></div>' +
|
2015-08-19 01:04:16 +03: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 16:00:15 +03:00
|
|
|
this.model.on('change:reshare', function() {
|
2015-08-19 01:04:16 +03:00
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
|
|
|
|
if(!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel;
|
|
|
|
} else {
|
2015-08-25 00:20:01 +03:00
|
|
|
throw 'missing OC.Share.ShareConfigModel';
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2015-09-15 16:29:30 +03:00
|
|
|
if (!this.model.hasReshare()
|
|
|
|
|| this.model.getReshareOwner() === OC.currentUser)
|
2015-08-19 01:04:16 +03:00
|
|
|
{
|
2015-08-21 16:00:15 +03:00
|
|
|
this.$el.empty();
|
2015-08-19 01:04:16 +03: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 22:56:10 +03:00
|
|
|
group: this.model.getReshareWithDisplayName(),
|
2015-08-19 01:04:16 +03:00
|
|
|
owner: ownerDisplayName
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you by {owner}',
|
|
|
|
{ owner: ownerDisplayName }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-25 00:20:01 +03:00
|
|
|
this.$el.html(reshareTemplate({
|
2015-09-01 13:43:04 +03:00
|
|
|
reshareOwner: this.model.getReshareOwner(),
|
2015-08-19 01:04:16 +03:00
|
|
|
sharedByText: sharedByText
|
|
|
|
}));
|
|
|
|
|
2017-02-14 02:49:05 +03:00
|
|
|
this.$el.find('.avatar').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.avatar($this.data('username'), 32);
|
|
|
|
});
|
2015-09-12 15:21:14 +03:00
|
|
|
|
2015-08-19 01:04:16 +03: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;
|
|
|
|
|
|
|
|
})();
|