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 = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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();
|
2018-07-20 12:22:24 +03:00
|
|
|
var shareNote = this.model.getReshareNote();
|
|
|
|
|
2015-08-19 01:04:16 +03:00
|
|
|
var sharedByText = '';
|
2018-07-20 12:22:24 +03:00
|
|
|
|
2015-08-19 01:04:16 +03:00
|
|
|
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
|
2017-06-13 13:14:21 +03:00
|
|
|
},
|
|
|
|
undefined,
|
|
|
|
{escape: false}
|
2015-08-19 01:04:16 +03:00
|
|
|
);
|
2017-07-06 08:56:32 +03:00
|
|
|
} else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_CIRCLE) {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you and {circle} by {owner}',
|
|
|
|
{
|
|
|
|
circle: this.model.getReshareWithDisplayName(),
|
2018-07-01 18:50:57 +03:00
|
|
|
owner: ownerDisplayName
|
|
|
|
},
|
|
|
|
undefined,
|
|
|
|
{escape: false}
|
|
|
|
);
|
|
|
|
} else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_ROOM) {
|
2018-09-11 13:57:36 +03:00
|
|
|
if (this.model.get('reshare').share_with_displayname) {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you and the conversation {conversation} by {owner}',
|
|
|
|
{
|
|
|
|
conversation: this.model.getReshareWithDisplayName(),
|
|
|
|
owner: ownerDisplayName
|
|
|
|
},
|
|
|
|
undefined,
|
|
|
|
{escape: false}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you in a conversation by {owner}',
|
|
|
|
{
|
|
|
|
owner: ownerDisplayName
|
|
|
|
},
|
|
|
|
undefined,
|
|
|
|
{escape: false}
|
|
|
|
);
|
|
|
|
}
|
2017-07-06 08:56:32 +03:00
|
|
|
} else {
|
2015-08-19 01:04:16 +03:00
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you by {owner}',
|
2017-06-13 13:14:21 +03:00
|
|
|
{ owner: ownerDisplayName },
|
|
|
|
undefined,
|
|
|
|
{escape: false}
|
2015-08-19 01:04:16 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-07-20 12:22:24 +03:00
|
|
|
|
|
|
|
|
2015-08-25 00:20:01 +03:00
|
|
|
this.$el.html(reshareTemplate({
|
2015-09-01 13:43:04 +03:00
|
|
|
reshareOwner: this.model.getReshareOwner(),
|
2018-07-20 12:22:24 +03:00
|
|
|
sharedByText: sharedByText,
|
|
|
|
shareNote: shareNote,
|
|
|
|
hasShareNote: shareNote !== ''
|
2015-08-19 01:04:16 +03:00
|
|
|
}));
|
|
|
|
|
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
|
|
|
|
2017-04-24 16:31:44 +03:00
|
|
|
this.$el.find('.reshare').contactsMenu(
|
|
|
|
this.model.getReshareOwner(),
|
|
|
|
OC.Share.SHARE_TYPE_USER,
|
|
|
|
this.$el);
|
|
|
|
|
2015-08-19 01:04:16 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
template: function () {
|
2018-10-01 21:46:29 +03:00
|
|
|
return OC.Share.Templates['sharedialogresharerinfoview'];
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView;
|
|
|
|
|
|
|
|
})();
|