diff options
author | Maximilian Wende <dasisdormax@secure.mailbox.org> | 2018-02-15 21:10:39 +0100 |
---|---|---|
committer | Maximilian Wende <dasisdormax@secure.mailbox.org> | 2018-02-15 21:10:39 +0100 |
commit | d4238a52b29033716e5836b426f2c6b91d11e11c (patch) | |
tree | 3f59826513bedcd2d72c2720529b262acc01aae7 /core | |
parent | 14bc9b171427c1512226d5ea402021d8b44ac690 (diff) | |
download | nextcloud-server-d4238a52b29033716e5836b426f2c6b91d11e11c.tar.gz nextcloud-server-d4238a52b29033716e5836b426f2c6b91d11e11c.zip |
Add indeterminate state to 'can edit' share permission checkbox, see #8371
Signed-off-by: Maximilian Wende <dasisdormax@secure.mailbox.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/js/sharedialogshareelistview.js | 7 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 26 |
2 files changed, 24 insertions, 9 deletions
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 30cbeff3c64..c4b56627093 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -30,7 +30,7 @@ '<span class="sharingOptionsGroup">' + '{{#if editPermissionPossible}}' + '<span class="shareOption">' + - '<input id="canEdit-{{cid}}-{{shareWith}}" type="checkbox" name="edit" class="permissions checkbox" {{#if hasEditPermission}}checked="checked"{{/if}} />' + + '<input id="canEdit-{{cid}}-{{shareWith}}" type="checkbox" name="edit" class="permissions checkbox" {{#if editPermissionState}}{{editPermissionState}}="{{editPermissionState}}"{{/if}} />' + '<label for="canEdit-{{cid}}-{{shareWith}}">{{canEditLabel}}</label>' + '</span>' + '{{/if}}' + @@ -232,7 +232,7 @@ return _.extend(hasPermissionOverride, { cid: this.cid, hasSharePermission: this.model.hasSharePermission(shareIndex), - hasEditPermission: this.model.hasEditPermission(shareIndex), + editPermissionState: this.model.editPermissionState(shareIndex), hasCreatePermission: this.model.hasCreatePermission(shareIndex), hasUpdatePermission: this.model.hasUpdatePermission(shareIndex), hasDeletePermission: this.model.hasDeletePermission(shareIndex), @@ -384,7 +384,8 @@ checkBoxId = '#' + checkBoxId.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1"); var $edit = $li.parent().find(checkBoxId); if($edit.length === 1) { - $edit.prop('checked', sharee.hasEditPermission); + $edit.prop('checked', sharee.editPermissionState === 'checked'); + $edit.prop('indeterminate', sharee.editPermissionState === 'indeterminate'); } } diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index afe86fa464b..b699513c734 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -567,12 +567,26 @@ }, /** - * @returns {boolean} - */ - hasEditPermission: function(shareIndex) { - return this.hasCreatePermission(shareIndex) - || this.hasUpdatePermission(shareIndex) - || this.hasDeletePermission(shareIndex); + * @returns {string} + * The state that the 'can edit' permission checkbox should have. + * Possible values: + * - empty string: no permission + * - 'checked': all applicable permissions + * - 'indeterminate': some but not all permissions + */ + editPermissionState: function(shareIndex) { + var hcp = this.hasCreatePermission(shareIndex); + var hup = this.hasUpdatePermission(shareIndex); + var hdp = this.hasDeletePermission(shareIndex); + if (!hcp && !hup && !hdp) { + return ''; + } + if ( (this.createPermissionPossible() && !hcp) + || (this.updatePermissionPossible() && !hup) + || (this.deletePermissionPossible() && !hdp) ) { + return 'indeterminate'; + } + return 'checked'; }, /** |