diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 8ec53810b5129..6e5248e83eb30 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -30,8 +30,8 @@ '' + '{{#if editPermissionPossible}}' + '' + - '' + - '' + + '' + + '' + '' + '{{/if}}' + '' + @@ -58,8 +58,8 @@ '{{#if isResharingAllowed}} {{#if sharePermissionPossible}} {{#unless isMailShare}}' + '
  • ' + '' + - '' + - '' + + '' + + '' + '' + '
  • ' + '{{/unless}} {{/if}} {{/if}}' + @@ -67,24 +67,24 @@ '{{#if createPermissionPossible}}{{#unless isMailShare}}' + '
  • ' + '' + - '' + - '' + + '' + + '' + '' + '
  • ' + '{{/unless}}{{/if}}' + '{{#if updatePermissionPossible}}{{#unless isMailShare}}' + '
  • ' + '' + - '' + - '' + + '' + + '' + '' + '
  • ' + '{{/unless}}{{/if}}' + '{{#if deletePermissionPossible}}{{#unless isMailShare}}' + '
  • ' + '' + - '' + - '' + + '' + + '' + '' + '
  • ' + '{{/unless}}{{/if}}' + @@ -380,9 +380,7 @@ var $li = this.$('li[data-share-id=' + permissionChangeShareId + ']'); $li.find('.sharingOptionsGroup .popovermenu').replaceWith(this.popoverMenuTemplate(sharee)); - var checkBoxId = 'canEdit-' + this.cid + '-' + sharee.shareWith; - checkBoxId = '#' + checkBoxId.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1"); - var $edit = $li.parent().find(checkBoxId); + var $edit = $li.parent().find('#canEdit-' + this.cid + '-' + sharee.shareId); if($edit.length === 1) { $edit.prop('checked', sharee.hasEditPermission); } diff --git a/core/js/tests/specs/sharedialogshareelistview.js b/core/js/tests/specs/sharedialogshareelistview.js index 8ee2c48fe39c9..c1c10b6010771 100644 --- a/core/js/tests/specs/sharedialogshareelistview.js +++ b/core/js/tests/specs/sharedialogshareelistview.js @@ -122,6 +122,56 @@ describe('OC.Share.ShareDialogShareeListView', function () { expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); expect(updateShareStub.calledOnce).toEqual(true); }); + + it('Checks edit box when clicking on it', function () { + updateShareStub.callsFake(function (shareId, attributes) { + // Update the permissions to get the new value when rendering + // again. + var shareIndex = this.findShareWithIndex(shareId); + this.get('shares')[shareIndex].permissions = attributes.permissions; + }); + + shareModel.set('shares', [{ + id: 100, + item_source: 123, + permissions: 0, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user1', + share_with_displayname: 'User One' + }]); + shareModel.set('itemType', 'folder'); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(false); + listView.$el.find("input[name='edit']").click(); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); + expect(updateShareStub.calledOnce).toEqual(true); + }); + + it('Checks edit box when clicking on it for sharee with special characters', function () { + updateShareStub.callsFake(function (shareId, attributes) { + // Update the permissions to get the new value when rendering + // again. + var shareIndex = this.findShareWithIndex(shareId); + this.get('shares')[shareIndex].permissions = attributes.permissions; + }); + + shareModel.set('shares', [{ + id: 100, + item_source: 123, + permissions: 0, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user _.@-\'', + share_with_displayname: 'User One' + }]); + shareModel.set('itemType', 'folder'); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(false); + listView.$el.find("input[name='edit']").click(); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); + expect(updateShareStub.calledOnce).toEqual(true); + }); }); });