2019-09-25 19:19:42 +03:00
|
|
|
/* eslint-disable */
|
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) {
|
2019-09-25 19:19:42 +03:00
|
|
|
OC.Share = {}
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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) {
|
2019-09-25 19:19:42 +03:00
|
|
|
var view = this
|
2015-08-19 01:04:16 +03:00
|
|
|
|
2015-08-21 16:00:15 +03:00
|
|
|
this.model.on('change:reshare', function() {
|
2019-09-25 19:19:42 +03:00
|
|
|
view.render()
|
|
|
|
})
|
2015-08-19 01:04:16 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
if (!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel
|
2015-08-19 01:04:16 +03:00
|
|
|
} else {
|
2019-09-25 19:19:42 +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()
|
2019-09-25 19:19:42 +03:00
|
|
|
|| this.model.getReshareOwner() === OC.currentUser) {
|
|
|
|
this.$el.empty()
|
|
|
|
return this
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
var reshareTemplate = this.template()
|
|
|
|
var ownerDisplayName = this.model.getReshareOwnerDisplayname()
|
|
|
|
var shareNote = this.model.getReshareNote()
|
|
|
|
|
|
|
|
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,
|
2019-09-25 19:19:42 +03:00
|
|
|
{ escape: false }
|
|
|
|
)
|
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,
|
2019-09-25 19:19:42 +03:00
|
|
|
{ escape: false }
|
|
|
|
)
|
2018-07-01 18:50:57 +03:00
|
|
|
} 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,
|
2019-09-25 19:19:42 +03:00
|
|
|
{ escape: false }
|
|
|
|
)
|
2018-09-11 13:57:36 +03:00
|
|
|
} else {
|
|
|
|
sharedByText = t(
|
|
|
|
'core',
|
|
|
|
'Shared with you in a conversation by {owner}',
|
|
|
|
{
|
|
|
|
owner: ownerDisplayName
|
|
|
|
},
|
|
|
|
undefined,
|
2019-09-25 19:19:42 +03:00
|
|
|
{ escape: false }
|
|
|
|
)
|
2018-09-11 13:57:36 +03:00
|
|
|
}
|
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,
|
2019-09-25 19:19:42 +03:00
|
|
|
{ escape: false }
|
|
|
|
)
|
2015-08-19 01:04:16 +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 !== ''
|
2019-09-25 19:19:42 +03:00
|
|
|
}))
|
2015-08-19 01:04:16 +03:00
|
|
|
|
2017-02-14 02:49:05 +03:00
|
|
|
this.$el.find('.avatar').each(function() {
|
2019-09-25 19:19:42 +03:00
|
|
|
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,
|
2019-09-25 19:19:42 +03:00
|
|
|
this.$el)
|
2017-04-24 16:31:44 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
return this
|
2015-08-19 01:04:16 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
2019-09-25 19:19:42 +03:00
|
|
|
template: function() {
|
|
|
|
return OC.Share.Templates['sharedialogresharerinfoview']
|
2015-08-19 01:04:16 +03:00
|
|
|
}
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
})
|
2015-08-19 01:04:16 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
OC.Share.ShareDialogResharerInfoView = ShareDialogResharerInfoView
|
2015-08-19 01:04:16 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
})()
|