diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-07-13 17:29:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 17:29:57 +0200 |
commit | 82021b2b1bd6e6ae9c85564ba614797a1110e29c (patch) | |
tree | dcae47bf607411ae0e2e4e54ed5715aa98354c35 /core/js | |
parent | 14314584ba88ed8d8a7c8486b61c6677a14271f2 (diff) | |
parent | 4f5814c27bc43a8f10bd35f60bc3254697c50659 (diff) | |
download | nextcloud-server-82021b2b1bd6e6ae9c85564ba614797a1110e29c.tar.gz nextcloud-server-82021b2b1bd6e6ae9c85564ba614797a1110e29c.zip |
Merge pull request #5280 from nextcloud/shared-with-display-name
sharedWithDisplayName & sharedWithAvatar
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/sharedialogresharerinfoview.js | 13 | ||||
-rw-r--r-- | core/js/sharedialogshareelistview.js | 19 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 15 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogviewSpec.js | 36 |
4 files changed, 75 insertions, 8 deletions
diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js index 8afec33e7eb..f4bf9afa0b2 100644 --- a/core/js/sharedialogresharerinfoview.js +++ b/core/js/sharedialogresharerinfoview.js @@ -84,7 +84,18 @@ undefined, {escape: false} ); - } else { + } else if (this.model.getReshareType() === OC.Share.SHARE_TYPE_CIRCLE) { + sharedByText = t( + 'core', + 'Shared with you and {circle} by {owner}', + { + circle: this.model.getReshareWithDisplayName(), + owner: ownerDisplayName + }, + undefined, + {escape: false} + ); + } else { sharedByText = t( 'core', 'Shared with you by {owner}', diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 0ff4c36b712..53a65fcdf7a 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -25,7 +25,7 @@ '<ul id="shareWithList" class="shareWithList">' + '{{#each sharees}}' + '<li data-share-id="{{shareId}}" data-share-type="{{shareType}}" data-share-with="{{shareWith}}">' + - '<div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" data-displayname="{{shareWithDisplayName}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' + + '<div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" data-avatar="{{shareWithAvatar}}" data-displayname="{{shareWithDisplayName}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' + '<span class="username" title="{{shareWithTitle}}">{{shareWithDisplayName}}</span>' + '<span class="sharingOptionsGroup">' + '{{#if editPermissionPossible}}' + @@ -188,6 +188,7 @@ getShareeObject: function(shareIndex) { 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); @@ -216,6 +217,10 @@ shareWithTitle = shareWith + " (" + t('core', 'email') + ')'; } else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) { shareWithTitle = shareWith; + // Force "shareWith" in the template to a safe value, as the + // original "shareWith" returned by the model may contain + // problematic characters like "'". + shareWith = 'circle-' + shareIndex; } if (sharedBy !== oc_current_user) { @@ -243,10 +248,11 @@ hasDeletePermission: this.model.hasDeletePermission(shareIndex), shareWith: shareWith, shareWithDisplayName: shareWithDisplayName, + shareWithAvatar: shareWithAvatar, shareWithTitle: shareWithTitle, shareType: shareType, shareId: this.model.get('shares')[shareIndex].id, - modSeed: shareType !== OC.Share.SHARE_TYPE_USER && shareType !== OC.Share.SHARE_TYPE_CIRCLE, + modSeed: shareType !== OC.Share.SHARE_TYPE_USER && (shareType !== OC.Share.SHARE_TYPE_CIRCLE || shareWithAvatar), isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE, isRemoteGroupShare: shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP, isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL, @@ -357,9 +363,16 @@ this.$('.avatar').each(function () { var $this = $(this); + if ($this.hasClass('imageplaceholderseed')) { $this.css({width: 32, height: 32}); - $this.imageplaceholder($this.data('seed')); + if ($this.data('avatar')) { + $this.css('border-radius', '0%'); + $this.css('background', 'url(' + $this.data('avatar') + ') no-repeat'); + $this.css('background-size', '31px'); + } else { + $this.imageplaceholder($this.data('seed')); + } } else { // user, size, ie8fix, hidedefault, callback, displayname $this.avatar($this.data('username'), 32, undefined, undefined, undefined, $this.data('displayname')); diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index e7824aca33a..93feba9c889 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -43,6 +43,7 @@ * @property {string} token * @property {string} share_with * @property {string} share_with_displayname + * @property {string} share_with_avatar * @property {string} mail_send * @property {Date} expiration optional? * @property {number} stime optional? @@ -405,6 +406,20 @@ return share.share_with_displayname; }, + + /** + * @param shareIndex + * @returns {string} + */ + getShareWithAvatar: function(shareIndex) { + /** @type OC.Share.Types.ShareInfo **/ + var share = this.get('shares')[shareIndex]; + if(!_.isObject(share)) { + throw "Unknown Share"; + } + return share.share_with_avatar; + }, + /** * @param shareIndex * @returns {string} diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js index 83c89053202..5fd920a758c 100644 --- a/core/js/tests/specs/sharedialogviewSpec.js +++ b/core/js/tests/specs/sharedialogviewSpec.js @@ -427,7 +427,21 @@ describe('OC.Share.ShareDialogView', function() { share_type: OC.Share.SHARE_TYPE_REMOTE, share_with: 'foo@bar.com/baz', share_with_displayname: 'foo@bar.com/baz' - + },{ + id: 103, + item_source: 123, + permissions: 31, + share_type: OC.Share.SHARE_TYPE_CIRCLE, + share_with: 'circle-0', + share_with_displayname: 'Circle (Personal circle, user0)', + share_with_avatar: 'path/to/the/avatar' + },{ + id: 104, + item_source: 123, + permissions: 31, + share_type: OC.Share.SHARE_TYPE_CIRCLE, + share_with: 'circle-1', + share_with_displayname: 'Circle (Public circle, user0)', }] }); }); @@ -439,10 +453,10 @@ describe('OC.Share.ShareDialogView', function() { }); it('test correct function calls', function() { - expect(avatarStub.calledTwice).toEqual(true); + expect(avatarStub.calledThrice).toEqual(true); expect(placeholderStub.callCount).toEqual(4); - expect(dialog.$('.shareWithList').children().length).toEqual(3); - expect(dialog.$('.avatar').length).toEqual(4); + expect(dialog.$('.shareWithList').children().length).toEqual(5); + expect(dialog.$('.avatar').length).toEqual(6); }); it('test avatar owner', function() { @@ -469,6 +483,20 @@ describe('OC.Share.ShareDialogView', function() { expect(args.length).toEqual(1); expect(args[0]).toEqual('foo@bar.com/baz ' + OC.Share.SHARE_TYPE_REMOTE); }); + + it('test avatar for circle', function() { + var avatarElement = dialog.$('.avatar').eq(4); + expect(avatarElement.css('background')).toContain('path/to/the/avatar'); + }); + + it('test avatar for circle without avatar', function() { + var args = avatarStub.getCall(2).args; + expect(args.length).toEqual(6); + // Note that "data-username" is set to "circle-{shareIndex}", + // not to the "shareWith" field. + expect(args[0]).toEqual('circle-4'); + expect(args[5]).toEqual('Circle (Public circle, user0)'); + }); }); }); describe('get suggestions', function() { |