2019-09-25 16:19:42 +00:00
|
|
|
/* eslint-disable */
|
2016-07-27 13:08:24 +00:00
|
|
|
/* global OC, Handlebars */
|
|
|
|
|
2015-08-25 14:07:14 +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-25 14:07:14 +00:00
|
|
|
(function() {
|
2017-03-28 12:39:38 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var PASSWORD_PLACEHOLDER = '**********'
|
|
|
|
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the mail share')
|
2017-03-28 12:39:38 +00:00
|
|
|
|
2015-08-25 14:07:14 +00:00
|
|
|
if (!OC.Share) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share = {}
|
2015-08-25 14:07:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Share.ShareDialogShareeListView
|
|
|
|
* @member {OC.Share.ShareItemModel} model
|
|
|
|
* @member {jQuery} $el
|
|
|
|
* @memberof OCA.Sharing
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Represents the sharee list part in the GUI of the share dialogue
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var ShareDialogShareeListView = OC.Backbone.View.extend({
|
|
|
|
/** @type {string} **/
|
|
|
|
id: 'shareDialogLinkShare',
|
|
|
|
|
|
|
|
/** @type {OC.Share.ShareConfigModel} **/
|
|
|
|
configModel: undefined,
|
|
|
|
|
2016-07-28 08:46:00 +00:00
|
|
|
_menuOpen: false,
|
|
|
|
|
2016-11-29 11:51:37 +00:00
|
|
|
/** @type {boolean|number} **/
|
|
|
|
_renderPermissionChange: false,
|
|
|
|
|
2015-09-14 15:47:47 +00:00
|
|
|
events: {
|
|
|
|
'click .unshare': 'onUnshare',
|
2018-07-18 15:42:30 +00:00
|
|
|
'click .share-add': 'showNoteForm',
|
|
|
|
'click .share-note-delete': 'deleteNote',
|
|
|
|
'click .share-note-submit': 'updateNote',
|
2018-07-19 08:04:37 +00:00
|
|
|
'click .share-menu .icon-more': 'onToggleMenu',
|
2015-09-14 15:47:47 +00:00
|
|
|
'click .permissions': 'onPermissionChange',
|
2019-09-25 16:19:42 +00:00
|
|
|
'click .expireDate': 'onExpireDateChange',
|
|
|
|
'click .password': 'onMailSharePasswordProtectChange',
|
|
|
|
'click .passwordByTalk': 'onMailSharePasswordProtectByTalkChange',
|
|
|
|
'click .secureDrop': 'onSecureDropChange',
|
2017-03-28 12:39:38 +00:00
|
|
|
'keyup input.passwordField': 'onMailSharePasswordKeyUp',
|
2017-03-29 14:50:23 +00:00
|
|
|
'focusout input.passwordField': 'onMailSharePasswordEntered',
|
|
|
|
'change .datepicker': 'onChangeExpirationDate',
|
2019-09-25 16:19:42 +00:00
|
|
|
'click .datepicker': 'showDatePicker'
|
2015-09-14 15:47:47 +00:00
|
|
|
},
|
|
|
|
|
2015-08-25 14:07:14 +00:00
|
|
|
initialize: function(options) {
|
2019-09-25 16:19:42 +00:00
|
|
|
if (!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel
|
2015-08-25 14:07:14 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
throw 'missing OC.Share.ShareConfigModel'
|
2015-08-25 14:07:14 +00:00
|
|
|
}
|
2015-09-01 10:43:04 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var view = this
|
2015-09-01 10:43:04 +00:00
|
|
|
this.model.on('change:shares', function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
view.render()
|
|
|
|
})
|
2015-09-01 10:43:04 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {OC.Share.Types.ShareInfo} shareInfo
|
|
|
|
* @returns {object}
|
|
|
|
*/
|
|
|
|
getShareeObject: function(shareIndex) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareWith = this.model.getShareWith(shareIndex)
|
|
|
|
var shareWithDisplayName = this.model.getShareWithDisplayName(shareIndex)
|
|
|
|
var shareWithAvatar = this.model.getShareWithAvatar(shareIndex)
|
|
|
|
var shareWithTitle = ''
|
|
|
|
var shareType = this.model.getShareType(shareIndex)
|
|
|
|
var sharedBy = this.model.getSharedBy(shareIndex)
|
|
|
|
var sharedByDisplayName = this.model.getSharedByDisplayName(shareIndex)
|
|
|
|
var fileOwnerUid = this.model.getFileOwnerUid(shareIndex)
|
|
|
|
|
|
|
|
var hasPermissionOverride = {}
|
2015-09-01 10:43:04 +00:00
|
|
|
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithDisplayName = shareWithDisplayName + ' (' + t('core', 'group') + ')'
|
2015-09-01 10:43:04 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithDisplayName = shareWithDisplayName + ' (' + t('core', 'remote') + ')'
|
2018-07-02 09:29:03 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithDisplayName = shareWithDisplayName + ' (' + t('core', 'remote group') + ')'
|
2016-10-25 14:24:49 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithDisplayName = shareWithDisplayName + ' (' + t('core', 'email') + ')'
|
2017-03-17 19:48:33 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
2018-07-01 15:50:18 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_ROOM) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithDisplayName = shareWithDisplayName + ' (' + t('core', 'conversation') + ')'
|
2016-10-25 14:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle = shareWith + ' (' + t('core', 'group') + ')'
|
2016-10-25 14:24:49 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle = shareWith + ' (' + t('core', 'remote') + ')'
|
2018-07-02 09:29:03 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle = shareWith + ' (' + t('core', 'remote group') + ')'
|
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
|
|
|
shareWithTitle = shareWith + ' (' + t('core', 'email') + ')'
|
2017-03-17 19:48:33 +00:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle = shareWith
|
2017-06-06 11:21:42 +00:00
|
|
|
// Force "shareWith" in the template to a safe value, as the
|
|
|
|
// original "shareWith" returned by the model may contain
|
|
|
|
// problematic characters like "'".
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWith = 'circle-' + shareIndex
|
2015-09-01 10:43:04 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 18:29:51 +00:00
|
|
|
if (sharedBy !== OC.getCurrentUser().uid) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var empty = shareWithTitle === ''
|
2017-04-10 15:07:45 +00:00
|
|
|
if (!empty) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle += ' ('
|
2017-04-10 15:07:45 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle += t('core', 'shared by {sharer}', { sharer: sharedByDisplayName })
|
2017-04-10 15:07:45 +00:00
|
|
|
if (!empty) {
|
2019-09-25 16:19:42 +00:00
|
|
|
shareWithTitle += ')'
|
2017-04-10 15:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var share = this.model.get('shares')[shareIndex]
|
|
|
|
var password = share.password
|
|
|
|
var hasPassword = password !== null && password !== ''
|
|
|
|
var sendPasswordByTalk = share.send_password_by_talk
|
2017-03-28 12:39:38 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareNote = this.model.getNote(shareIndex)
|
2018-10-31 09:49:06 +00:00
|
|
|
|
2015-09-02 15:27:25 +00:00
|
|
|
return _.extend(hasPermissionOverride, {
|
2015-10-16 08:54:45 +00:00
|
|
|
cid: this.cid,
|
2015-09-01 10:43:04 +00:00
|
|
|
hasSharePermission: this.model.hasSharePermission(shareIndex),
|
2018-02-15 20:10:39 +00:00
|
|
|
editPermissionState: this.model.editPermissionState(shareIndex),
|
2015-09-01 10:43:04 +00:00
|
|
|
hasCreatePermission: this.model.hasCreatePermission(shareIndex),
|
|
|
|
hasUpdatePermission: this.model.hasUpdatePermission(shareIndex),
|
|
|
|
hasDeletePermission: this.model.hasDeletePermission(shareIndex),
|
2018-10-30 13:22:33 +00:00
|
|
|
sharedBy: sharedBy,
|
|
|
|
sharedByDisplayName: sharedByDisplayName,
|
2015-09-01 10:43:04 +00:00
|
|
|
shareWith: shareWith,
|
|
|
|
shareWithDisplayName: shareWithDisplayName,
|
2017-06-06 11:21:42 +00:00
|
|
|
shareWithAvatar: shareWithAvatar,
|
2016-10-25 14:24:49 +00:00
|
|
|
shareWithTitle: shareWithTitle,
|
2015-09-01 10:43:04 +00:00
|
|
|
shareType: shareType,
|
2016-01-22 16:30:18 +00:00
|
|
|
shareId: this.model.get('shares')[shareIndex].id,
|
2018-07-01 15:50:18 +00:00
|
|
|
modSeed: shareWithAvatar || (shareType !== OC.Share.SHARE_TYPE_USER && shareType !== OC.Share.SHARE_TYPE_CIRCLE && shareType !== OC.Share.SHARE_TYPE_ROOM),
|
2018-10-30 13:22:33 +00:00
|
|
|
owner: fileOwnerUid,
|
2019-05-07 18:29:51 +00:00
|
|
|
isShareWithCurrentUser: (shareType === OC.Share.SHARE_TYPE_USER && shareWith === OC.getCurrentUser().uid),
|
|
|
|
canUpdateShareSettings: (sharedBy === OC.getCurrentUser().uid || fileOwnerUid === OC.getCurrentUser().uid),
|
2016-10-26 09:27:43 +00:00
|
|
|
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE,
|
2018-07-02 09:29:03 +00:00
|
|
|
isRemoteGroupShare: shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP,
|
2018-07-19 21:28:46 +00:00
|
|
|
isNoteAvailable: shareType !== OC.Share.SHARE_TYPE_REMOTE && shareType !== OC.Share.SHARE_TYPE_REMOTE_GROUP,
|
2016-10-26 09:27:43 +00:00
|
|
|
isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL,
|
2017-03-17 19:48:33 +00:00
|
|
|
isCircleShare: shareType === OC.Share.SHARE_TYPE_CIRCLE,
|
2017-03-28 12:39:38 +00:00
|
|
|
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder(),
|
2018-07-13 11:00:10 +00:00
|
|
|
isPasswordSet: hasPassword && !sendPasswordByTalk,
|
|
|
|
isPasswordByTalkSet: hasPassword && sendPasswordByTalk,
|
2019-05-07 07:03:14 +00:00
|
|
|
isTalkEnabled: OC.appswebroots['spreed'] !== undefined,
|
2017-03-29 09:58:04 +00:00
|
|
|
secureDropMode: !this.model.hasReadPermission(shareIndex),
|
2017-03-29 14:50:23 +00:00
|
|
|
hasExpireDate: this.model.getExpireDate(shareIndex) !== null,
|
2018-10-31 09:49:06 +00:00
|
|
|
shareNote: shareNote,
|
|
|
|
hasNote: shareNote !== '',
|
2017-04-07 11:54:32 +00:00
|
|
|
expireDate: moment(this.model.getExpireDate(shareIndex), 'YYYY-MM-DD').format('DD-MM-YYYY'),
|
2018-07-13 11:00:10 +00:00
|
|
|
// The password placeholder does not take into account if
|
|
|
|
// sending the password by Talk is enabled or not; when
|
|
|
|
// switching from sending the password by Talk to sending the
|
|
|
|
// password by email the password is reused and the share
|
|
|
|
// updated, so the placeholder already shows the password in the
|
|
|
|
// brief time between disabling sending the password by email
|
|
|
|
// and receiving the updated share.
|
2017-03-28 12:39:38 +00:00
|
|
|
passwordPlaceholder: hasPassword ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE,
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordByTalkPlaceholder: (hasPassword && sendPasswordByTalk) ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE
|
|
|
|
})
|
2015-08-25 14:07:14 +00:00
|
|
|
},
|
|
|
|
|
2016-11-29 11:51:37 +00:00
|
|
|
getShareProperties: function() {
|
|
|
|
return {
|
2015-08-25 14:07:14 +00:00
|
|
|
unshareLabel: t('core', 'Unshare'),
|
2018-07-31 12:20:09 +00:00
|
|
|
addNoteLabel: t('core', 'Note to recipient'),
|
2017-03-29 16:13:12 +00:00
|
|
|
canShareLabel: t('core', 'Can reshare'),
|
|
|
|
canEditLabel: t('core', 'Can edit'),
|
|
|
|
createPermissionLabel: t('core', 'Can create'),
|
|
|
|
updatePermissionLabel: t('core', 'Can change'),
|
|
|
|
deletePermissionLabel: t('core', 'Can delete'),
|
2017-05-18 14:53:10 +00:00
|
|
|
secureDropLabel: t('core', 'File drop (upload only)'),
|
2017-03-29 16:13:12 +00:00
|
|
|
expireDateLabel: t('core', 'Set expiration date'),
|
|
|
|
passwordLabel: t('core', 'Password protect'),
|
2018-07-13 11:00:10 +00:00
|
|
|
passwordByTalkLabel: t('core', 'Password protect by Talk'),
|
2017-03-29 16:13:12 +00:00
|
|
|
crudsLabel: t('core', 'Access control'),
|
2018-01-05 07:26:01 +00:00
|
|
|
expirationDatePlaceholder: t('core', 'Expiration date'),
|
|
|
|
defaultExpireDate: moment().add(1, 'day').format('DD-MM-YYYY'), // Can't expire today
|
2015-09-01 10:43:04 +00:00
|
|
|
triangleSImage: OC.imagePath('core', 'actions/triangle-s'),
|
2015-09-05 00:02:55 +00:00
|
|
|
isResharingAllowed: this.configModel.get('isResharingAllowed'),
|
2017-04-10 16:36:23 +00:00
|
|
|
isPasswordForMailSharesRequired: this.configModel.get('isPasswordForMailSharesRequired'),
|
2015-09-01 10:43:04 +00:00
|
|
|
sharePermissionPossible: this.model.sharePermissionPossible(),
|
|
|
|
editPermissionPossible: this.model.editPermissionPossible(),
|
|
|
|
createPermissionPossible: this.model.createPermissionPossible(),
|
|
|
|
updatePermissionPossible: this.model.updatePermissionPossible(),
|
|
|
|
deletePermissionPossible: this.model.deletePermissionPossible(),
|
|
|
|
sharePermission: OC.PERMISSION_SHARE,
|
|
|
|
createPermission: OC.PERMISSION_CREATE,
|
|
|
|
updatePermission: OC.PERMISSION_UPDATE,
|
2016-07-20 13:24:51 +00:00
|
|
|
deletePermission: OC.PERMISSION_DELETE,
|
2017-03-29 09:58:04 +00:00
|
|
|
readPermission: OC.PERMISSION_READ,
|
2016-07-20 13:24:51 +00:00
|
|
|
isFolder: this.model.isFolder()
|
2019-09-25 16:19:42 +00:00
|
|
|
}
|
2016-11-29 11:51:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get an array of sharees' share properties
|
|
|
|
*
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
getShareeList: function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
var universal = this.getShareProperties()
|
2015-08-25 14:07:14 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
if (!this.model.hasUserShares()) {
|
|
|
|
return []
|
2015-09-01 10:43:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var shares = this.model.get('shares')
|
|
|
|
var list = []
|
|
|
|
for (var index = 0; index < shares.length; index++) {
|
|
|
|
var share = this.getShareeObject(index)
|
2016-08-28 18:59:12 +00:00
|
|
|
|
|
|
|
if (share.shareType === OC.Share.SHARE_TYPE_LINK) {
|
2019-09-25 16:19:42 +00:00
|
|
|
continue
|
2016-08-28 18:59:12 +00:00
|
|
|
}
|
|
|
|
// first empty {} is necessary, otherwise we get in trouble
|
|
|
|
// with references
|
2019-09-25 16:19:42 +00:00
|
|
|
list.push(_.extend({}, universal, share))
|
2016-08-28 18:59:12 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
return list
|
2016-08-28 18:59:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getLinkReshares: function() {
|
|
|
|
var universal = {
|
2019-09-25 16:19:42 +00:00
|
|
|
unshareLabel: t('core', 'Unshare')
|
|
|
|
}
|
2016-08-28 18:59:12 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
if (!this.model.hasUserShares()) {
|
|
|
|
return []
|
2016-08-28 18:59:12 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var shares = this.model.get('shares')
|
|
|
|
var list = []
|
|
|
|
for (var index = 0; index < shares.length; index++) {
|
|
|
|
var share = this.getShareeObject(index)
|
2016-08-28 18:59:12 +00:00
|
|
|
|
|
|
|
if (share.shareType !== OC.Share.SHARE_TYPE_LINK) {
|
2019-09-25 16:19:42 +00:00
|
|
|
continue
|
2016-08-28 18:59:12 +00:00
|
|
|
}
|
2016-01-22 16:30:18 +00:00
|
|
|
// first empty {} is necessary, otherwise we get in trouble
|
|
|
|
// with references
|
2016-08-28 18:59:12 +00:00
|
|
|
list.push(_.extend({}, universal, share, {
|
|
|
|
shareInitiator: shares[index].uid_owner,
|
2019-09-25 16:19:42 +00:00
|
|
|
shareInitiatorText: t('core', '{shareInitiatorDisplayName} shared via link', { shareInitiatorDisplayName: shares[index].displayname_owner })
|
|
|
|
}))
|
2015-09-01 10:43:04 +00:00
|
|
|
}
|
2015-08-25 14:07:14 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
return list
|
2015-08-25 14:07:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
if (!this._renderPermissionChange) {
|
2016-11-29 11:51:37 +00:00
|
|
|
this.$el.html(this.template({
|
|
|
|
cid: this.cid,
|
|
|
|
sharees: this.getShareeList(),
|
|
|
|
linkReshares: this.getLinkReshares()
|
2019-09-25 16:19:42 +00:00
|
|
|
}))
|
2016-11-29 11:51:37 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this.$('.avatar').each(function() {
|
|
|
|
var $this = $(this)
|
2017-06-06 11:21:42 +00:00
|
|
|
|
2017-02-13 23:49:05 +00:00
|
|
|
if ($this.hasClass('imageplaceholderseed')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$this.css({ width: 32, height: 32 })
|
2017-06-06 11:21:42 +00:00
|
|
|
if ($this.data('avatar')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$this.css('border-radius', '0%')
|
|
|
|
$this.css('background', 'url(' + $this.data('avatar') + ') no-repeat')
|
|
|
|
$this.css('background-size', '31px')
|
2017-06-06 11:21:42 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
$this.imageplaceholder($this.data('seed'))
|
2017-06-06 11:21:42 +00:00
|
|
|
}
|
2017-02-13 23:49:05 +00:00
|
|
|
} else {
|
|
|
|
// user, size, ie8fix, hidedefault, callback, displayname
|
2019-09-25 16:19:42 +00:00
|
|
|
$this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'))
|
2017-02-13 23:49:05 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2016-11-29 11:51:37 +00:00
|
|
|
|
|
|
|
this.$('.has-tooltip').tooltip({
|
|
|
|
placement: 'bottom'
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2017-04-24 09:39:03 +00:00
|
|
|
|
|
|
|
this.$('ul.shareWithList > li').each(function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
var $this = $(this)
|
2017-04-24 09:39:03 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareWith = $this.data('share-with')
|
|
|
|
var shareType = $this.data('share-type')
|
2017-04-24 09:39:03 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
$this.find('div.avatar, span.username').contactsMenu(shareWith, shareType, $this)
|
|
|
|
})
|
2016-11-29 11:51:37 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
var permissionChangeShareId = parseInt(this._renderPermissionChange, 10)
|
|
|
|
var shareWithIndex = this.model.findShareWithIndex(permissionChangeShareId)
|
|
|
|
var sharee = this.getShareeObject(shareWithIndex)
|
|
|
|
$.extend(sharee, this.getShareProperties())
|
|
|
|
var $li = this.$('li[data-share-id=' + permissionChangeShareId + ']')
|
|
|
|
$li.find('.sharingOptionsGroup .popovermenu').replaceWith(this.popoverMenuTemplate(sharee))
|
2018-02-15 21:41:09 +00:00
|
|
|
}
|
2016-11-29 14:44:43 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var _this = this
|
2018-02-15 21:41:09 +00:00
|
|
|
this.getShareeList().forEach(function(sharee) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var $edit = _this.$('#canEdit-' + _this.cid + '-' + sharee.shareId)
|
|
|
|
if ($edit.length === 1) {
|
|
|
|
$edit.prop('checked', sharee.editPermissionState === 'checked')
|
2018-10-31 10:23:23 +00:00
|
|
|
if (sharee.isFolder) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$edit.prop('indeterminate', sharee.editPermissionState === 'indeterminate')
|
2018-10-31 10:23:23 +00:00
|
|
|
}
|
2016-11-29 14:44:43 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2016-07-28 08:46:00 +00:00
|
|
|
this.$('.popovermenu').on('afterHide', function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
_this._menuOpen = false
|
|
|
|
})
|
2017-04-05 14:36:07 +00:00
|
|
|
this.$('.popovermenu').on('beforeHide', function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareId = parseInt(_this._menuOpen, 10)
|
|
|
|
if (!_.isNaN(shareId)) {
|
|
|
|
var datePickerClass = '.expirationDateContainer-' + _this.cid + '-' + shareId
|
|
|
|
var datePickerInput = '#expirationDatePicker-' + _this.cid + '-' + shareId
|
|
|
|
var expireDateCheckbox = '#expireDate-' + _this.cid + '-' + shareId
|
2017-04-05 14:36:07 +00:00
|
|
|
if ($(expireDateCheckbox).prop('checked')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$(datePickerInput).removeClass('hidden-visually')
|
|
|
|
$(datePickerClass).removeClass('hasDatepicker')
|
|
|
|
$(datePickerClass + ' .ui-datepicker').hide()
|
2017-04-05 14:36:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2017-11-17 16:08:29 +00:00
|
|
|
if (this._menuOpen !== false) {
|
2016-07-28 08:46:00 +00:00
|
|
|
// Open menu again if it was opened before
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareId = parseInt(this._menuOpen, 10)
|
|
|
|
if (!_.isNaN(shareId)) {
|
|
|
|
var liSelector = 'li[data-share-id=' + shareId + ']'
|
|
|
|
OC.showMenu(null, this.$(liSelector + ' .sharingOptionsGroup .popovermenu'))
|
2016-11-28 09:56:22 +00:00
|
|
|
}
|
2016-07-28 08:46:00 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this._renderPermissionChange = false
|
2016-11-29 11:51:37 +00:00
|
|
|
|
2018-07-18 16:04:15 +00:00
|
|
|
// new note autosize
|
2019-09-25 16:19:42 +00:00
|
|
|
autosize(this.$el.find('.share-note-form .share-note'))
|
2018-07-18 16:04:15 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this.delegateEvents()
|
2015-09-13 23:24:21 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
return this
|
2015-08-25 14:07:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
2019-09-25 16:19:42 +00:00
|
|
|
template: function(data) {
|
|
|
|
var sharees = data.sharees
|
|
|
|
if (_.isArray(sharees)) {
|
2016-11-29 11:51:37 +00:00
|
|
|
for (var i = 0; i < sharees.length; i++) {
|
2019-09-25 16:19:42 +00:00
|
|
|
data.sharees[i].popoverMenu = this.popoverMenuTemplate(sharees[i])
|
2016-11-29 11:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
return OC.Share.Templates['sharedialogshareelistview'](data)
|
2015-09-13 23:24:21 +00:00
|
|
|
},
|
|
|
|
|
2016-11-29 11:51:37 +00:00
|
|
|
/**
|
|
|
|
* renders the popover template and returns the resulting HTML
|
|
|
|
*
|
|
|
|
* @param {Object} data
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
popoverMenuTemplate: function(data) {
|
2019-09-25 16:19:42 +00:00
|
|
|
return OC.Share.Templates['sharedialogshareelistview_popover_menu'](data)
|
2016-11-29 11:51:37 +00:00
|
|
|
},
|
|
|
|
|
2018-07-20 07:39:52 +00:00
|
|
|
showNoteForm: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $menu = $element.closest('li')
|
|
|
|
var $form = $menu.next('li.share-note-form')
|
2018-07-19 06:57:20 +00:00
|
|
|
|
2018-07-18 15:42:30 +00:00
|
|
|
// show elements
|
2019-09-25 16:19:42 +00:00
|
|
|
$menu.find('.share-note-delete').toggleClass('hidden')
|
|
|
|
$form.toggleClass('hidden')
|
|
|
|
$form.find('textarea').focus()
|
2018-07-18 15:42:30 +00:00
|
|
|
},
|
|
|
|
|
2018-07-20 07:39:52 +00:00
|
|
|
deleteNote: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var self = this
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $li = $element.closest('li[data-share-id]')
|
|
|
|
var shareId = $li.data('share-id')
|
|
|
|
var $menu = $element.closest('li')
|
|
|
|
var $form = $menu.next('li.share-note-form')
|
|
|
|
|
|
|
|
console.log($form.find('.share-note'))
|
|
|
|
$form.find('.share-note').val('')
|
|
|
|
|
|
|
|
$form.addClass('hidden')
|
|
|
|
$menu.find('.share-note-delete').addClass('hidden')
|
|
|
|
|
|
|
|
self.sendNote('', shareId, $menu)
|
2018-07-18 15:42:30 +00:00
|
|
|
},
|
|
|
|
|
2018-07-20 07:39:52 +00:00
|
|
|
updateNote: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var self = this
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $li = $element.closest('li[data-share-id]')
|
|
|
|
var shareId = $li.data('share-id')
|
|
|
|
var $form = $element.closest('li.share-note-form')
|
|
|
|
var $menu = $form.prev('li')
|
|
|
|
var message = $form.find('.share-note').val().trim()
|
2018-07-18 15:42:30 +00:00
|
|
|
|
|
|
|
if (message.length < 1) {
|
2019-09-25 16:19:42 +00:00
|
|
|
return
|
2018-07-18 15:42:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
self.sendNote(message, shareId, $menu)
|
2018-07-18 15:42:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-07-20 07:39:52 +00:00
|
|
|
sendNote: function(note, shareId, $menu) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var $form = $menu.next('li.share-note-form')
|
|
|
|
var $submit = $form.find('input.share-note-submit')
|
|
|
|
var $error = $form.find('input.share-note-error')
|
2018-07-18 15:42:30 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
$submit.prop('disabled', true)
|
|
|
|
$menu.find('.icon-loading-small').removeClass('hidden')
|
|
|
|
$menu.find('.icon-edit').hide()
|
2018-07-18 15:42:30 +00:00
|
|
|
|
|
|
|
var complete = function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$submit.prop('disabled', false)
|
|
|
|
$menu.find('.icon-loading-small').addClass('hidden')
|
|
|
|
$menu.find('.icon-edit').show()
|
|
|
|
}
|
2018-07-18 15:42:30 +00:00
|
|
|
var error = function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$error.show()
|
2018-07-18 15:42:30 +00:00
|
|
|
setTimeout(function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$error.hide()
|
|
|
|
}, 3000)
|
|
|
|
}
|
2018-07-18 15:42:30 +00:00
|
|
|
|
|
|
|
// send data
|
|
|
|
$.ajax({
|
|
|
|
method: 'PUT',
|
2019-09-25 16:19:42 +00:00
|
|
|
url: OC.linkToOCS('apps/files_sharing/api/v1/shares', 2) + shareId + '?' + OC.buildQueryString({ format: 'json' }),
|
2018-07-18 15:42:30 +00:00
|
|
|
data: { note: note },
|
2019-09-25 16:19:42 +00:00
|
|
|
complete: complete,
|
2018-07-18 15:42:30 +00:00
|
|
|
error: error
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2018-07-14 09:45:04 +00:00
|
|
|
},
|
|
|
|
|
2015-09-14 15:47:47 +00:00
|
|
|
onUnshare: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var self = this
|
|
|
|
var $element = $(event.target)
|
2015-12-07 16:58:17 +00:00
|
|
|
if (!$element.is('a')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
$element = $element.closest('a')
|
2015-12-07 16:58:17 +00:00
|
|
|
}
|
2015-09-13 23:24:21 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var $loading = $element.find('.icon-loading-small').eq(0)
|
|
|
|
if (!$loading.hasClass('hidden')) {
|
2015-09-13 23:24:21 +00:00
|
|
|
// in process
|
2019-09-25 16:19:42 +00:00
|
|
|
return false
|
2015-09-13 23:24:21 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
$loading.removeClass('hidden')
|
2015-09-13 23:24:21 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var $li = $element.closest('li[data-share-id]')
|
2015-09-13 23:24:21 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var shareId = $li.data('share-id')
|
2015-09-13 23:24:21 +00:00
|
|
|
|
2016-01-22 16:30:18 +00:00
|
|
|
self.model.removeShare(shareId)
|
|
|
|
.done(function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$li.remove()
|
2016-01-22 16:30:18 +00:00
|
|
|
})
|
|
|
|
.fail(function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$loading.addClass('hidden')
|
|
|
|
OC.Notification.showTemporary(t('core', 'Could not unshare'))
|
|
|
|
})
|
|
|
|
return false
|
2015-09-13 23:40:16 +00:00
|
|
|
},
|
|
|
|
|
2016-07-27 13:08:24 +00:00
|
|
|
onToggleMenu: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $li = $element.closest('li[data-share-id]')
|
|
|
|
var $menu = $li.find('.sharingOptionsGroup .popovermenu')
|
|
|
|
|
|
|
|
OC.showMenu(null, $menu)
|
|
|
|
this._menuOpen = $li.data('share-id')
|
2016-07-27 13:08:24 +00:00
|
|
|
},
|
|
|
|
|
2017-03-27 20:03:10 +00:00
|
|
|
onExpireDateChange: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var $element = $(event.target)
|
|
|
|
var li = $element.closest('li[data-share-id]')
|
|
|
|
var shareId = li.data('share-id')
|
|
|
|
var datePickerClass = '.expirationDateContainer-' + this.cid + '-' + shareId
|
|
|
|
var datePicker = $(datePickerClass)
|
|
|
|
var state = $element.prop('checked')
|
|
|
|
datePicker.toggleClass('hidden', !state)
|
2017-03-27 20:03:10 +00:00
|
|
|
if (!state) {
|
2018-07-19 18:05:37 +00:00
|
|
|
// disabled, let's hide the input and
|
|
|
|
// set the expireDate to nothing
|
2019-09-25 16:19:42 +00:00
|
|
|
$element.closest('li').next('li').addClass('hidden')
|
|
|
|
this.setExpirationDate(shareId, '')
|
2017-03-27 20:03:10 +00:00
|
|
|
} else {
|
2018-07-19 18:05:37 +00:00
|
|
|
// enabled, show the input and the datepicker
|
2019-09-25 16:19:42 +00:00
|
|
|
$element.closest('li').next('li').removeClass('hidden')
|
|
|
|
this.showDatePicker(event)
|
2017-03-29 14:50:23 +00:00
|
|
|
|
2017-03-27 20:03:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-03-29 14:50:23 +00:00
|
|
|
showDatePicker: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var element = $(event.target)
|
|
|
|
var li = element.closest('li[data-share-id]')
|
|
|
|
var shareId = li.data('share-id')
|
|
|
|
var expirationDatePicker = '#expirationDatePicker-' + this.cid + '-' + shareId
|
|
|
|
var view = this
|
2017-12-13 10:11:05 +00:00
|
|
|
$(expirationDatePicker).datepicker({
|
2019-09-25 16:19:42 +00:00
|
|
|
dateFormat: 'dd-mm-yy',
|
|
|
|
onSelect: function(expireDate) {
|
|
|
|
view.setExpirationDate(shareId, expireDate)
|
2017-12-13 10:11:05 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
|
|
|
$(expirationDatePicker).focus()
|
2017-03-29 14:50:23 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setExpirationDate: function(shareId, expireDate) {
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { expireDate: expireDate }, {})
|
2017-03-29 14:50:23 +00:00
|
|
|
},
|
|
|
|
|
2017-03-28 12:39:38 +00:00
|
|
|
onMailSharePasswordProtectChange: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var element = $(event.target)
|
|
|
|
var li = element.closest('li[data-share-id]')
|
|
|
|
var shareId = li.data('share-id')
|
|
|
|
var passwordContainerClass = '.passwordMenu-' + this.cid + '-' + shareId
|
|
|
|
var passwordContainer = $(passwordContainerClass)
|
|
|
|
var loading = this.$el.find(passwordContainerClass + ' .icon-loading-small')
|
|
|
|
var inputClass = '#passwordField-' + this.cid + '-' + shareId
|
|
|
|
var passwordField = $(inputClass)
|
|
|
|
var state = element.prop('checked')
|
|
|
|
var passwordByTalkElement = $('#passwordByTalk-' + this.cid + '-' + shareId)
|
|
|
|
var passwordByTalkState = passwordByTalkElement.prop('checked')
|
2018-07-13 11:00:10 +00:00
|
|
|
if (!state && !passwordByTalkState) {
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { password: '', sendPasswordByTalk: false })
|
|
|
|
passwordField.attr('value', '')
|
|
|
|
passwordField.removeClass('error')
|
|
|
|
passwordField.tooltip('hide')
|
|
|
|
loading.addClass('hidden')
|
|
|
|
passwordField.attr('placeholder', PASSWORD_PLACEHOLDER_MESSAGE)
|
2017-04-06 09:33:24 +00:00
|
|
|
// We first need to reset the password field before we hide it
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordContainer.toggleClass('hidden', !state)
|
2018-07-13 11:00:10 +00:00
|
|
|
} else if (state) {
|
|
|
|
if (passwordByTalkState) {
|
|
|
|
// Switching from sending the password by Talk to sending
|
|
|
|
// the password by mail can be done keeping the previous
|
|
|
|
// password sent by Talk.
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { sendPasswordByTalk: false })
|
2018-07-13 11:00:10 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var passwordByTalkContainerClass = '.passwordByTalkMenu-' + this.cid + '-' + shareId
|
|
|
|
var passwordByTalkContainer = $(passwordByTalkContainerClass)
|
|
|
|
passwordByTalkContainer.addClass('hidden')
|
|
|
|
passwordByTalkElement.prop('checked', false)
|
2018-07-13 11:00:10 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordContainer.toggleClass('hidden', !state)
|
|
|
|
passwordField = '#passwordField-' + this.cid + '-' + shareId
|
|
|
|
this.$(passwordField).focus()
|
2017-03-28 12:39:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-07-13 11:00:10 +00:00
|
|
|
onMailSharePasswordProtectByTalkChange: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var element = $(event.target)
|
|
|
|
var li = element.closest('li[data-share-id]')
|
|
|
|
var shareId = li.data('share-id')
|
|
|
|
var passwordByTalkContainerClass = '.passwordByTalkMenu-' + this.cid + '-' + shareId
|
|
|
|
var passwordByTalkContainer = $(passwordByTalkContainerClass)
|
|
|
|
var loading = this.$el.find(passwordByTalkContainerClass + ' .icon-loading-small')
|
|
|
|
var inputClass = '#passwordByTalkField-' + this.cid + '-' + shareId
|
|
|
|
var passwordByTalkField = $(inputClass)
|
|
|
|
var state = element.prop('checked')
|
|
|
|
var passwordElement = $('#password-' + this.cid + '-' + shareId)
|
|
|
|
var passwordState = passwordElement.prop('checked')
|
2018-07-13 11:00:10 +00:00
|
|
|
if (!state) {
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { password: '', sendPasswordByTalk: false })
|
|
|
|
passwordByTalkField.attr('value', '')
|
|
|
|
passwordByTalkField.removeClass('error')
|
|
|
|
passwordByTalkField.tooltip('hide')
|
|
|
|
loading.addClass('hidden')
|
|
|
|
passwordByTalkField.attr('placeholder', PASSWORD_PLACEHOLDER_MESSAGE)
|
2018-07-13 11:00:10 +00:00
|
|
|
// We first need to reset the password field before we hide it
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordByTalkContainer.toggleClass('hidden', !state)
|
2018-07-13 11:00:10 +00:00
|
|
|
} else if (state) {
|
|
|
|
if (passwordState) {
|
|
|
|
// Enabling sending the password by Talk requires a new
|
|
|
|
// password to be given (the one sent by mail is not reused,
|
|
|
|
// as it would defeat the purpose of checking the identity
|
|
|
|
// of the sharee by Talk if it was already sent by mail), so
|
|
|
|
// the share is not updated until the user explicitly gives
|
|
|
|
// the new password.
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var passwordContainerClass = '.passwordMenu-' + this.cid + '-' + shareId
|
|
|
|
var passwordContainer = $(passwordContainerClass)
|
|
|
|
passwordContainer.addClass('hidden')
|
|
|
|
passwordElement.prop('checked', false)
|
2018-07-13 11:00:10 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordByTalkContainer.toggleClass('hidden', !state)
|
|
|
|
passwordByTalkField = '#passwordByTalkField-' + this.cid + '-' + shareId
|
|
|
|
this.$(passwordByTalkField).focus()
|
2018-07-13 11:00:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-03-28 12:39:38 +00:00
|
|
|
onMailSharePasswordKeyUp: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
if (event.keyCode === 13) {
|
|
|
|
this.onMailSharePasswordEntered(event)
|
2017-03-28 12:39:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onMailSharePasswordEntered: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
var passwordField = $(event.target)
|
|
|
|
var li = passwordField.closest('li[data-share-id]')
|
|
|
|
var shareId = li.data('share-id')
|
|
|
|
var passwordContainerClass = '.passwordMenu-' + this.cid + '-' + shareId
|
|
|
|
var passwordByTalkContainerClass = '.passwordByTalkMenu-' + this.cid + '-' + shareId
|
|
|
|
var sendPasswordByTalk = passwordField.attr('id').startsWith('passwordByTalk')
|
|
|
|
var loading
|
2018-07-13 11:00:10 +00:00
|
|
|
if (sendPasswordByTalk) {
|
2019-09-25 16:19:42 +00:00
|
|
|
loading = this.$el.find(passwordByTalkContainerClass + ' .icon-loading-small')
|
2018-07-13 11:00:10 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
loading = this.$el.find(passwordContainerClass + ' .icon-loading-small')
|
2018-07-13 11:00:10 +00:00
|
|
|
}
|
2017-03-28 12:39:38 +00:00
|
|
|
if (!loading.hasClass('hidden')) {
|
|
|
|
// still in process
|
2019-09-25 16:19:42 +00:00
|
|
|
return
|
2017-03-28 12:39:38 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordField.removeClass('error')
|
|
|
|
var password = passwordField.val()
|
2017-03-28 12:39:38 +00:00
|
|
|
// in IE9 the password might be the placeholder due to bugs in the placeholders polyfill
|
2019-09-25 16:19:42 +00:00
|
|
|
if (password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) {
|
|
|
|
return
|
2017-03-28 12:39:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
loading
|
|
|
|
.removeClass('hidden')
|
2019-09-25 16:19:42 +00:00
|
|
|
.addClass('inlineblock')
|
2017-03-28 12:39:38 +00:00
|
|
|
|
|
|
|
this.model.updateShare(shareId, {
|
2018-07-13 11:00:10 +00:00
|
|
|
password: password,
|
|
|
|
sendPasswordByTalk: sendPasswordByTalk
|
2017-03-28 12:39:38 +00:00
|
|
|
}, {
|
|
|
|
error: function(model, msg) {
|
|
|
|
// destroy old tooltips
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordField.tooltip('destroy')
|
|
|
|
loading.removeClass('inlineblock').addClass('hidden')
|
|
|
|
passwordField.addClass('error')
|
|
|
|
passwordField.attr('title', msg)
|
|
|
|
passwordField.tooltip({ placement: 'bottom', trigger: 'manual' })
|
|
|
|
passwordField.tooltip('show')
|
2017-03-28 12:39:38 +00:00
|
|
|
},
|
|
|
|
success: function(model, msg) {
|
2019-09-25 16:19:42 +00:00
|
|
|
passwordField.blur()
|
|
|
|
passwordField.attr('value', '')
|
|
|
|
passwordField.attr('placeholder', PASSWORD_PLACEHOLDER)
|
|
|
|
loading.removeClass('inlineblock').addClass('hidden')
|
2017-03-28 12:39:38 +00:00
|
|
|
}
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2017-03-28 12:39:38 +00:00
|
|
|
},
|
|
|
|
|
2015-09-14 15:47:47 +00:00
|
|
|
onPermissionChange: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $li = $element.closest('li[data-share-id]')
|
|
|
|
var shareId = $li.data('share-id')
|
2015-09-14 00:29:22 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var permissions = OC.PERMISSION_READ
|
2016-08-10 08:32:59 +00:00
|
|
|
|
|
|
|
if (this.model.isFolder()) {
|
|
|
|
// adjust checkbox states
|
2019-09-25 16:19:42 +00:00
|
|
|
var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]')
|
|
|
|
var checked
|
2016-08-10 08:32:59 +00:00
|
|
|
if ($element.attr('name') === 'edit') {
|
2019-09-25 16:19:42 +00:00
|
|
|
checked = $element.is(':checked')
|
2016-08-10 08:32:59 +00:00
|
|
|
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck
|
2019-09-25 16:19:42 +00:00
|
|
|
$($checkboxes).prop('checked', checked)
|
2016-12-06 14:41:10 +00:00
|
|
|
if (checked) {
|
2019-09-25 16:19:42 +00:00
|
|
|
permissions |= OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE
|
2016-12-06 14:41:10 +00:00
|
|
|
}
|
2016-08-10 08:32:59 +00:00
|
|
|
} else {
|
2019-09-25 16:19:42 +00:00
|
|
|
var numberChecked = $checkboxes.filter(':checked').length
|
|
|
|
checked = numberChecked === $checkboxes.length
|
|
|
|
var $editCb = $('input[name="edit"]', $li)
|
|
|
|
$editCb.prop('checked', checked)
|
|
|
|
$editCb.prop('indeterminate', !checked && numberChecked > 0)
|
2016-08-10 08:32:59 +00:00
|
|
|
}
|
2016-12-06 14:41:10 +00:00
|
|
|
} else {
|
|
|
|
if ($element.attr('name') === 'edit' && $element.is(':checked')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
permissions |= OC.PERMISSION_UPDATE
|
2016-12-06 14:41:10 +00:00
|
|
|
}
|
2015-09-14 00:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) {
|
2019-09-25 16:19:42 +00:00
|
|
|
permissions |= $(checkbox).data('permissions')
|
|
|
|
})
|
2016-12-02 12:14:25 +00:00
|
|
|
|
|
|
|
/** disable checkboxes during save operation to avoid race conditions **/
|
2019-09-25 16:19:42 +00:00
|
|
|
$li.find('input[type=checkbox]').prop('disabled', true)
|
2016-12-02 12:14:25 +00:00
|
|
|
var enableCb = function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$li.find('input[type=checkbox]').prop('disabled', false)
|
|
|
|
}
|
2016-12-02 12:14:25 +00:00
|
|
|
var errorCb = function(elem, msg) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.dialogs.alert(msg, t('core', 'Error while sharing'))
|
|
|
|
enableCb()
|
|
|
|
}
|
2016-12-02 12:14:25 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { permissions: permissions }, { error: errorCb, success: enableCb })
|
2016-11-29 11:51:37 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this._renderPermissionChange = shareId
|
2015-09-14 00:29:22 +00:00
|
|
|
},
|
2017-03-29 09:58:04 +00:00
|
|
|
|
|
|
|
onSecureDropChange: function(event) {
|
2019-09-25 16:19:42 +00:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
var $element = $(event.target)
|
|
|
|
var $li = $element.closest('li[data-share-id]')
|
|
|
|
var shareId = $li.data('share-id')
|
2017-03-29 09:58:04 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
var permissions = OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE | OC.PERMISSION_READ
|
2017-03-29 09:58:04 +00:00
|
|
|
if ($element.is(':checked')) {
|
2019-09-25 16:19:42 +00:00
|
|
|
permissions = OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE
|
2017-03-29 09:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** disable checkboxes during save operation to avoid race conditions **/
|
2019-09-25 16:19:42 +00:00
|
|
|
$li.find('input[type=checkbox]').prop('disabled', true)
|
2017-03-29 09:58:04 +00:00
|
|
|
var enableCb = function() {
|
2019-09-25 16:19:42 +00:00
|
|
|
$li.find('input[type=checkbox]').prop('disabled', false)
|
|
|
|
}
|
2017-03-29 09:58:04 +00:00
|
|
|
var errorCb = function(elem, msg) {
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.dialogs.alert(msg, t('core', 'Error while sharing'))
|
|
|
|
enableCb()
|
|
|
|
}
|
2017-03-29 09:58:04 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this.model.updateShare(shareId, { permissions: permissions }, { error: errorCb, success: enableCb })
|
2017-03-29 09:58:04 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
this._renderPermissionChange = shareId
|
2017-03-29 09:58:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
})
|
2015-08-25 14:07:14 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
OC.Share.ShareDialogShareeListView = ShareDialogShareeListView
|
2015-08-25 14:07:14 +00:00
|
|
|
|
2019-09-25 16:19:42 +00:00
|
|
|
})()
|