2016-07-27 16:08:24 +03:00
|
|
|
/* global OC, Handlebars */
|
|
|
|
|
2015-08-25 17:07:14 +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-25 17:07:14 +03:00
|
|
|
(function() {
|
|
|
|
if (!OC.Share) {
|
|
|
|
OC.Share = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
var TEMPLATE =
|
2015-10-16 11:54:45 +03:00
|
|
|
'<ul id="shareWithList" class="shareWithList">' +
|
2015-08-25 17:07:14 +03:00
|
|
|
'{{#each sharees}}' +
|
2016-03-18 13:59:57 +03:00
|
|
|
'<li data-share-id="{{shareId}}" data-share-type="{{shareType}}" data-share-with="{{shareWith}}">' +
|
|
|
|
'{{#if avatarEnabled}}' +
|
2016-11-29 13:24:35 +03:00
|
|
|
'<div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" data-displayname="{{shareWithDisplayName}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' +
|
2016-03-18 13:59:57 +03:00
|
|
|
'{{/if}}' +
|
2016-10-25 17:24:49 +03:00
|
|
|
'<span class="has-tooltip username" title="{{shareWithTitle}}">{{shareWithDisplayName}}</span>' +
|
2016-07-27 16:08:24 +03:00
|
|
|
'<span class="sharingOptionsGroup">' +
|
|
|
|
'{{#if editPermissionPossible}}' +
|
2016-10-26 12:27:43 +03:00
|
|
|
'{{#unless isFileSharedByMail}}' +
|
2016-03-18 13:59:57 +03:00
|
|
|
'<span class="shareOption">' +
|
2016-07-27 16:08:24 +03:00
|
|
|
'<input id="canEdit-{{cid}}-{{shareWith}}" type="checkbox" name="edit" class="permissions checkbox" {{#if hasEditPermission}}checked="checked"{{/if}} />' +
|
|
|
|
'<label for="canEdit-{{cid}}-{{shareWith}}">{{canEditLabel}}</label>' +
|
2016-03-18 13:59:57 +03:00
|
|
|
'</span>' +
|
2016-10-26 12:27:43 +03:00
|
|
|
'{{/unless}}' +
|
2016-04-04 18:01:51 +03:00
|
|
|
'{{/if}}' +
|
2016-08-19 14:07:04 +03:00
|
|
|
'<a href="#"><span class="icon icon-more"></span></a>' +
|
2016-11-29 14:51:37 +03:00
|
|
|
'{{{popoverMenu}}}' +
|
2016-10-26 12:27:43 +03:00
|
|
|
'</span>' +
|
2016-03-18 13:59:57 +03:00
|
|
|
'</li>' +
|
2015-08-25 17:07:14 +03:00
|
|
|
'{{/each}}' +
|
2016-08-28 21:59:12 +03:00
|
|
|
'{{#each linkReshares}}' +
|
2016-10-10 13:57:57 +03:00
|
|
|
'<li data-share-id="{{shareId}}" data-share-type="{{shareType}}">' +
|
2016-10-05 21:35:46 +03:00
|
|
|
'{{#if avatarEnabled}}' +
|
|
|
|
'<div class="avatar" data-username="{{shareInitiator}}"></div>' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'<span class="has-tooltip username" title="{{shareInitiator}}">' + t('core', '{{shareInitiatorDisplayName}} shared via link') + '</span>' +
|
|
|
|
|
|
|
|
'<span class="sharingOptionsGroup">' +
|
|
|
|
'<a href="#" class="unshare"><span class="icon-loading-small hidden"></span><span class="icon icon-delete"></span><span class="hidden-visually">{{unshareLabel}}</span></a>' +
|
|
|
|
'</span>' +
|
2016-08-28 21:59:12 +03:00
|
|
|
'</li>' +
|
|
|
|
'{{/each}}' +
|
|
|
|
'</ul>'
|
|
|
|
;
|
2015-08-25 17:07:14 +03:00
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
var TEMPLATE_POPOVER_MENU =
|
|
|
|
'<div class="popovermenu bubble hidden menu">' +
|
|
|
|
'<ul>' +
|
|
|
|
'{{#if isResharingAllowed}} {{#if sharePermissionPossible}} {{#unless isMailShare}}' +
|
|
|
|
'<li>' +
|
|
|
|
'<span class="shareOption">' +
|
|
|
|
'<input id="canShare-{{cid}}-{{shareWith}}" type="checkbox" name="share" class="permissions checkbox" {{#if hasSharePermission}}checked="checked"{{/if}} data-permissions="{{sharePermission}}" />' +
|
|
|
|
'<label for="canShare-{{cid}}-{{shareWith}}">{{canShareLabel}}</label>' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
|
|
|
'{{/unless}} {{/if}} {{/if}}' +
|
|
|
|
'{{#if isFolder}}' +
|
|
|
|
'{{#if createPermissionPossible}}{{#unless isMailShare}}' +
|
|
|
|
'<li>' +
|
|
|
|
'<span class="shareOption">' +
|
|
|
|
'<input id="canCreate-{{cid}}-{{shareWith}}" type="checkbox" name="create" class="permissions checkbox" {{#if hasCreatePermission}}checked="checked"{{/if}} data-permissions="{{createPermission}}"/>' +
|
|
|
|
'<label for="canCreate-{{cid}}-{{shareWith}}">{{createPermissionLabel}}</label>' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
|
|
|
'{{/unless}}{{/if}}' +
|
|
|
|
'{{#if updatePermissionPossible}}{{#unless isMailShare}}' +
|
|
|
|
'<li>' +
|
|
|
|
'<span class="shareOption">' +
|
|
|
|
'<input id="canUpdate-{{cid}}-{{shareWith}}" type="checkbox" name="update" class="permissions checkbox" {{#if hasUpdatePermission}}checked="checked"{{/if}} data-permissions="{{updatePermission}}"/>' +
|
|
|
|
'<label for="canUpdate-{{cid}}-{{shareWith}}">{{updatePermissionLabel}}</label>' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
|
|
|
'{{/unless}}{{/if}}' +
|
|
|
|
'{{#if deletePermissionPossible}}{{#unless isMailShare}}' +
|
|
|
|
'<li>' +
|
|
|
|
'<span class="shareOption">' +
|
|
|
|
'<input id="canDelete-{{cid}}-{{shareWith}}" type="checkbox" name="delete" class="permissions checkbox" {{#if hasDeletePermission}}checked="checked"{{/if}} data-permissions="{{deletePermission}}"/>' +
|
|
|
|
'<label for="canDelete-{{cid}}-{{shareWith}}">{{deletePermissionLabel}}</label>' +
|
|
|
|
'</span>' +
|
|
|
|
'</li>' +
|
|
|
|
'{{/unless}}{{/if}}' +
|
|
|
|
'{{/if}}' +
|
|
|
|
'<li>' +
|
|
|
|
'<a href="#" class="unshare"><span class="icon-loading-small hidden"></span><span class="icon icon-delete"></span><span>{{unshareLabel}}</span></a>' +
|
|
|
|
'</li>' +
|
|
|
|
'</ul>' +
|
|
|
|
'</div>';
|
|
|
|
|
2015-08-25 17:07:14 +03: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,
|
|
|
|
|
|
|
|
/** @type {Function} **/
|
|
|
|
_template: undefined,
|
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
/** @type {Function} **/
|
|
|
|
_popoverMenuTemplate: undefined,
|
|
|
|
|
2016-07-28 11:46:00 +03:00
|
|
|
_menuOpen: false,
|
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
/** @type {boolean|number} **/
|
|
|
|
_renderPermissionChange: false,
|
|
|
|
|
2015-09-14 18:47:47 +03:00
|
|
|
events: {
|
|
|
|
'click .unshare': 'onUnshare',
|
2016-07-27 16:08:24 +03:00
|
|
|
'click .icon-more': 'onToggleMenu',
|
2015-09-14 18:47:47 +03:00
|
|
|
'click .permissions': 'onPermissionChange',
|
|
|
|
},
|
|
|
|
|
2015-08-25 17:07:14 +03:00
|
|
|
initialize: function(options) {
|
|
|
|
if(!_.isUndefined(options.configModel)) {
|
|
|
|
this.configModel = options.configModel;
|
|
|
|
} else {
|
|
|
|
throw 'missing OC.Share.ShareConfigModel';
|
|
|
|
}
|
2015-09-01 13:43:04 +03:00
|
|
|
|
|
|
|
var view = this;
|
|
|
|
this.model.on('change:shares', function() {
|
|
|
|
view.render();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {OC.Share.Types.ShareInfo} shareInfo
|
|
|
|
* @returns {object}
|
|
|
|
*/
|
|
|
|
getShareeObject: function(shareIndex) {
|
|
|
|
var shareWith = this.model.getShareWith(shareIndex);
|
|
|
|
var shareWithDisplayName = this.model.getShareWithDisplayName(shareIndex);
|
2016-10-25 17:24:49 +03:00
|
|
|
var shareWithTitle = '';
|
2015-09-01 13:43:04 +03:00
|
|
|
var shareType = this.model.getShareType(shareIndex);
|
|
|
|
|
2015-09-02 18:27:25 +03:00
|
|
|
var hasPermissionOverride = {};
|
2015-09-01 13:43:04 +03:00
|
|
|
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
|
|
|
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')';
|
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
|
|
|
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
|
2016-10-25 17:24:49 +03:00
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
|
|
|
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'email') + ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
|
|
|
shareWithTitle = shareWith + " (" + t('core', 'group') + ')';
|
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
|
|
|
shareWithTitle = shareWith + " (" + t('core', 'remote') + ')';
|
|
|
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
|
|
|
shareWithTitle = shareWith + " (" + t('core', 'email') + ')';
|
2015-09-01 13:43:04 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 18:27:25 +03:00
|
|
|
return _.extend(hasPermissionOverride, {
|
2015-10-16 11:54:45 +03:00
|
|
|
cid: this.cid,
|
2015-09-01 13:43:04 +03:00
|
|
|
hasSharePermission: this.model.hasSharePermission(shareIndex),
|
|
|
|
hasEditPermission: this.model.hasEditPermission(shareIndex),
|
|
|
|
hasCreatePermission: this.model.hasCreatePermission(shareIndex),
|
|
|
|
hasUpdatePermission: this.model.hasUpdatePermission(shareIndex),
|
|
|
|
hasDeletePermission: this.model.hasDeletePermission(shareIndex),
|
|
|
|
shareWith: shareWith,
|
|
|
|
shareWithDisplayName: shareWithDisplayName,
|
2016-10-25 17:24:49 +03:00
|
|
|
shareWithTitle: shareWithTitle,
|
2015-09-01 13:43:04 +03:00
|
|
|
shareType: shareType,
|
2016-01-22 19:30:18 +03:00
|
|
|
shareId: this.model.get('shares')[shareIndex].id,
|
2015-09-02 17:47:25 +03:00
|
|
|
modSeed: shareType !== OC.Share.SHARE_TYPE_USER,
|
2016-10-26 12:27:43 +03:00
|
|
|
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE,
|
|
|
|
isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL,
|
|
|
|
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder()
|
2015-09-02 18:27:25 +03:00
|
|
|
});
|
2015-08-25 17:07:14 +03:00
|
|
|
},
|
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
getShareProperties: function() {
|
|
|
|
return {
|
2015-08-25 17:07:14 +03:00
|
|
|
avatarEnabled: this.configModel.areAvatarsEnabled(),
|
|
|
|
unshareLabel: t('core', 'Unshare'),
|
2016-08-19 13:49:42 +03:00
|
|
|
canShareLabel: t('core', 'can reshare'),
|
2015-09-01 13:43:04 +03:00
|
|
|
canEditLabel: t('core', 'can edit'),
|
2016-10-29 17:07:49 +03:00
|
|
|
createPermissionLabel: t('core', 'can create'),
|
|
|
|
updatePermissionLabel: t('core', 'can change'),
|
|
|
|
deletePermissionLabel: t('core', 'can delete'),
|
2015-09-01 13:43:04 +03:00
|
|
|
crudsLabel: t('core', 'access control'),
|
|
|
|
triangleSImage: OC.imagePath('core', 'actions/triangle-s'),
|
2015-09-05 03:02:55 +03:00
|
|
|
isResharingAllowed: this.configModel.get('isResharingAllowed'),
|
2015-09-01 13:43:04 +03: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 16:24:51 +03:00
|
|
|
deletePermission: OC.PERMISSION_DELETE,
|
|
|
|
isFolder: this.model.isFolder()
|
2015-08-25 17:07:14 +03:00
|
|
|
};
|
2016-11-29 14:51:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get an array of sharees' share properties
|
|
|
|
*
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
getShareeList: function() {
|
|
|
|
var universal = this.getShareProperties();
|
2015-08-25 17:07:14 +03:00
|
|
|
|
2015-09-14 18:20:51 +03:00
|
|
|
if(!this.model.hasUserShares()) {
|
2015-09-01 13:43:04 +03:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2015-09-02 14:06:00 +03:00
|
|
|
var shares = this.model.get('shares');
|
2015-09-01 13:43:04 +03:00
|
|
|
var list = [];
|
2015-09-02 14:06:00 +03:00
|
|
|
for(var index = 0; index < shares.length; index++) {
|
2016-08-28 21:59:12 +03:00
|
|
|
var share = this.getShareeObject(index);
|
|
|
|
|
|
|
|
if (share.shareType === OC.Share.SHARE_TYPE_LINK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// first empty {} is necessary, otherwise we get in trouble
|
|
|
|
// with references
|
|
|
|
list.push(_.extend({}, universal, share));
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
getLinkReshares: function() {
|
|
|
|
var universal = {
|
|
|
|
unshareLabel: t('core', 'Unshare'),
|
2016-10-05 21:35:46 +03:00
|
|
|
avatarEnabled: this.configModel.areAvatarsEnabled(),
|
2016-08-28 21:59:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if(!this.model.hasUserShares()) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
var shares = this.model.get('shares');
|
|
|
|
var list = [];
|
|
|
|
for(var index = 0; index < shares.length; index++) {
|
|
|
|
var share = this.getShareeObject(index);
|
|
|
|
|
|
|
|
if (share.shareType !== OC.Share.SHARE_TYPE_LINK) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-22 19:30:18 +03:00
|
|
|
// first empty {} is necessary, otherwise we get in trouble
|
|
|
|
// with references
|
2016-08-28 21:59:12 +03:00
|
|
|
list.push(_.extend({}, universal, share, {
|
|
|
|
shareInitiator: shares[index].uid_owner,
|
|
|
|
shareInitiatorDisplayName: shares[index].displayname_owner
|
|
|
|
}));
|
2015-09-01 13:43:04 +03:00
|
|
|
}
|
2015-08-25 17:07:14 +03:00
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2016-11-29 14:51:37 +03:00
|
|
|
if(!this._renderPermissionChange) {
|
|
|
|
this.$el.html(this.template({
|
|
|
|
cid: this.cid,
|
|
|
|
sharees: this.getShareeList(),
|
|
|
|
linkReshares: this.getLinkReshares()
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (this.configModel.areAvatarsEnabled()) {
|
|
|
|
this.$('.avatar').each(function () {
|
|
|
|
var $this = $(this);
|
|
|
|
if ($this.hasClass('imageplaceholderseed')) {
|
|
|
|
$this.css({width: 32, height: 32});
|
|
|
|
$this.imageplaceholder($this.data('seed'));
|
|
|
|
} else {
|
2016-12-06 14:41:15 +03:00
|
|
|
// user, size, ie8fix, hidedefault, callback, displayname
|
|
|
|
$this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname'));
|
2016-11-29 14:51:37 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$('.has-tooltip').tooltip({
|
|
|
|
placement: 'bottom'
|
2015-09-12 15:21:14 +03:00
|
|
|
});
|
2016-11-29 14:51:37 +03:00
|
|
|
} else {
|
|
|
|
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('.popovermenu').replaceWith(this.popoverMenuTemplate(sharee));
|
2016-11-29 17:44:43 +03:00
|
|
|
|
2016-12-06 14:41:15 +03:00
|
|
|
var checkBoxId = 'canEdit-' + this.cid + '-' + sharee.shareWith;
|
|
|
|
checkBoxId = '#' + checkBoxId.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1");
|
|
|
|
var $edit = $li.parent().find(checkBoxId);
|
2016-12-02 14:27:15 +03:00
|
|
|
if($edit.length === 1) {
|
2016-11-29 17:44:43 +03:00
|
|
|
$edit.prop('checked', sharee.hasEditPermission);
|
|
|
|
}
|
2015-09-12 15:21:14 +03:00
|
|
|
}
|
|
|
|
|
2016-07-28 11:46:00 +03:00
|
|
|
var _this = this;
|
|
|
|
this.$('.popovermenu').on('afterHide', function() {
|
|
|
|
_this._menuOpen = false;
|
|
|
|
});
|
2016-11-28 12:56:22 +03:00
|
|
|
if (this._menuOpen != false) {
|
2016-07-28 11:46:00 +03:00
|
|
|
// Open menu again if it was opened before
|
2016-11-28 12:56:22 +03:00
|
|
|
var shareId = parseInt(this._menuOpen, 10);
|
|
|
|
if(!_.isNaN(shareId)) {
|
|
|
|
var liSelector = 'li[data-share-id=' + shareId + ']';
|
|
|
|
OC.showMenu(null, this.$(liSelector + ' .popovermenu'));
|
|
|
|
}
|
2016-07-28 11:46:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
this._renderPermissionChange = false;
|
|
|
|
|
2015-09-14 18:47:47 +03:00
|
|
|
this.delegateEvents();
|
2015-09-14 02:24:21 +03:00
|
|
|
|
2015-08-25 17:07:14 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Function} from Handlebars
|
|
|
|
* @private
|
|
|
|
*/
|
2015-10-16 11:54:45 +03:00
|
|
|
template: function (data) {
|
2015-08-25 17:07:14 +03:00
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
2016-12-02 14:27:15 +03:00
|
|
|
var sharees = data.sharees;
|
2016-11-29 14:51:37 +03:00
|
|
|
if(_.isArray(sharees)) {
|
|
|
|
for (var i = 0; i < sharees.length; i++) {
|
2016-12-02 14:27:15 +03:00
|
|
|
data.sharees[i].popoverMenu = this.popoverMenuTemplate(sharees[i]);
|
2016-11-29 14:51:37 +03:00
|
|
|
}
|
|
|
|
}
|
2015-10-16 11:54:45 +03:00
|
|
|
return this._template(data);
|
2015-09-14 02:24:21 +03:00
|
|
|
},
|
|
|
|
|
2016-11-29 14:51:37 +03:00
|
|
|
/**
|
|
|
|
* renders the popover template and returns the resulting HTML
|
|
|
|
*
|
|
|
|
* @param {Object} data
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
popoverMenuTemplate: function(data) {
|
|
|
|
if(!this._popoverMenuTemplate) {
|
|
|
|
this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU);
|
|
|
|
}
|
|
|
|
return this._popoverMenuTemplate(data);
|
|
|
|
},
|
|
|
|
|
2015-09-14 18:47:47 +03:00
|
|
|
onUnshare: function(event) {
|
2016-07-27 16:08:24 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2016-01-22 19:30:18 +03:00
|
|
|
var self = this;
|
2015-09-14 18:47:47 +03:00
|
|
|
var $element = $(event.target);
|
2015-12-07 19:58:17 +03:00
|
|
|
if (!$element.is('a')) {
|
|
|
|
$element = $element.closest('a');
|
|
|
|
}
|
2015-09-14 02:24:21 +03:00
|
|
|
|
2015-12-07 19:58:17 +03:00
|
|
|
var $loading = $element.find('.icon-loading-small').eq(0);
|
2015-09-25 13:11:50 +03:00
|
|
|
if(!$loading.hasClass('hidden')) {
|
2015-09-14 02:24:21 +03:00
|
|
|
// in process
|
2015-12-07 19:58:17 +03:00
|
|
|
return false;
|
2015-09-14 02:24:21 +03:00
|
|
|
}
|
2015-09-25 13:11:50 +03:00
|
|
|
$loading.removeClass('hidden');
|
2015-09-14 02:24:21 +03:00
|
|
|
|
2016-07-27 16:08:24 +03:00
|
|
|
var $li = $element.closest('li[data-share-id]');
|
2015-09-14 02:24:21 +03:00
|
|
|
|
2016-01-22 19:30:18 +03:00
|
|
|
var shareId = $li.data('share-id');
|
2015-09-14 02:24:21 +03:00
|
|
|
|
2016-01-22 19:30:18 +03:00
|
|
|
self.model.removeShare(shareId)
|
|
|
|
.done(function() {
|
|
|
|
$li.remove();
|
|
|
|
})
|
|
|
|
.fail(function() {
|
|
|
|
$loading.addClass('hidden');
|
|
|
|
OC.Notification.showTemporary(t('core', 'Could not unshare'));
|
|
|
|
});
|
2015-09-14 02:40:16 +03:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2016-07-27 16:08:24 +03:00
|
|
|
onToggleMenu: function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
var $element = $(event.target);
|
|
|
|
var $li = $element.closest('li[data-share-id]');
|
|
|
|
var $menu = $li.find('.popovermenu');
|
|
|
|
|
|
|
|
OC.showMenu(null, $menu);
|
2016-11-28 12:56:22 +03:00
|
|
|
this._menuOpen = $li.data('share-id');
|
2016-07-27 16:08:24 +03:00
|
|
|
},
|
|
|
|
|
2015-09-14 18:47:47 +03:00
|
|
|
onPermissionChange: function(event) {
|
2016-07-27 16:08:24 +03:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2015-09-14 18:47:47 +03:00
|
|
|
var $element = $(event.target);
|
2016-07-27 16:08:24 +03:00
|
|
|
var $li = $element.closest('li[data-share-id]');
|
2016-01-22 19:30:18 +03:00
|
|
|
var shareId = $li.data('share-id');
|
2015-09-14 03:29:22 +03:00
|
|
|
|
2016-08-10 11:32:59 +03:00
|
|
|
var permissions = OC.PERMISSION_READ;
|
|
|
|
|
|
|
|
if (this.model.isFolder()) {
|
|
|
|
// adjust checkbox states
|
|
|
|
var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]');
|
|
|
|
var checked;
|
|
|
|
if ($element.attr('name') === 'edit') {
|
|
|
|
checked = $element.is(':checked');
|
|
|
|
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck
|
|
|
|
$($checkboxes).prop('checked', checked);
|
2016-12-06 17:41:10 +03:00
|
|
|
if (checked) {
|
|
|
|
permissions |= OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE;
|
|
|
|
}
|
2016-08-10 11:32:59 +03:00
|
|
|
} else {
|
|
|
|
var numberChecked = $checkboxes.filter(':checked').length;
|
|
|
|
checked = numberChecked > 0;
|
|
|
|
$('input[name="edit"]', $li).prop('checked', checked);
|
|
|
|
}
|
2016-12-06 17:41:10 +03:00
|
|
|
} else {
|
|
|
|
if ($element.attr('name') === 'edit' && $element.is(':checked')) {
|
|
|
|
permissions |= OC.PERMISSION_UPDATE;
|
|
|
|
}
|
2015-09-14 03:29:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) {
|
|
|
|
permissions |= $(checkbox).data('permissions');
|
|
|
|
});
|
|
|
|
|
2016-12-02 15:14:25 +03:00
|
|
|
|
|
|
|
/** disable checkboxes during save operation to avoid race conditions **/
|
|
|
|
$li.find('input[type=checkbox]').prop('disabled', true);
|
|
|
|
var enableCb = function() {
|
|
|
|
$li.find('input[type=checkbox]').prop('disabled', false);
|
|
|
|
};
|
|
|
|
var errorCb = function(elem, msg) {
|
|
|
|
OC.dialogs.alert(msg, t('core', 'Error while sharing'));
|
|
|
|
enableCb();
|
|
|
|
};
|
|
|
|
|
|
|
|
this.model.updateShare(shareId, {permissions: permissions}, {error: errorCb, success: enableCb});
|
2016-11-29 14:51:37 +03:00
|
|
|
|
|
|
|
this._renderPermissionChange = shareId;
|
2015-09-14 03:29:22 +03:00
|
|
|
},
|
2015-08-25 17:07:14 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
OC.Share.ShareDialogShareeListView = ShareDialogShareeListView;
|
|
|
|
|
|
|
|
})();
|