diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html index 6c921d57f2..5f18045f81 100644 --- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html +++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html @@ -17,6 +17,7 @@ limitations under the License. + @@ -75,16 +76,12 @@ limitations under the License. url="[[_computeAutocompleteURL(change)]]" params="[[_computeAutocompleteParams(_inputVal)]]" on-response="_handleResponse"> -
diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js index 00fc12ec1e..275ab6f5e8 100644 --- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js +++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js @@ -161,7 +161,7 @@ this._autocompleteData = []; }, - _handleRemoveTap: function(e) { + _handleRemove: function(e) { e.preventDefault(); var target = Polymer.dom(e).rootTarget; var accountID = parseInt(target.getAttribute('data-account-id'), 10); diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_test.html b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_test.html index 898d32876d..eccc72e5cb 100644 --- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_test.html @@ -175,16 +175,19 @@ limitations under the License. ] }; flushAsynchronousOperations(); - var removeEls = - Polymer.dom(element.root).querySelectorAll('.reviewer > .remove'); - assert.equal(removeEls.length, 3); - Array.from(removeEls).forEach(function(el) { + var chips = + Polymer.dom(element.root).querySelectorAll('gr-account-chip'); + assert.equal(chips.length, 3); + Array.from(chips).forEach(function(el) { var accountID = parseInt(el.getAttribute('data-account-id'), 10); assert.ok(accountID); + + var buttonEl = el.$$('gr-button'); + assert.isNotNull(buttonEl); if (accountID == 2) { - assert.isTrue(el.hasAttribute('hidden')); + assert.isTrue(buttonEl.hasAttribute('hidden')); } else { - assert.isFalse(el.hasAttribute('hidden')); + assert.isFalse(buttonEl.hasAttribute('hidden')); } }); }); @@ -240,7 +243,6 @@ limitations under the License. element._inputVal = 'andyb'; server.respond(); - element._lastAutocompleteRequest.completes.then(function() { assert.isFalse(element.$$('.dropdown').hasAttribute('hidden')); var itemEls = Polymer.dom(element.root).querySelectorAll('.reviewer'); @@ -257,7 +259,7 @@ limitations under the License. var reviewerEls = Polymer.dom(element.root).querySelectorAll('.reviewer'); assert.equal(reviewerEls.length, 1); - MockInteractions.tap(element.$$('.reviewer > .remove')); + MockInteractions.tap(element.$$('.reviewer').$$('gr-button')); flushAsynchronousOperations(); assert.isTrue(element.disabled); server.respond(); diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html new file mode 100644 index 0000000000..f9ba529073 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js new file mode 100644 index 0000000000..4e32bc6807 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +(function() { + 'use strict'; + + Polymer({ + is: 'gr-account-chip', + + properties: { + account: Object, + removable: { + type: Boolean, + value: false, + }, + }, + + _handleRemoveTap: function(e) { + e.preventDefault(); + this.fire('remove', {account: this.account}, {bubbles: false}); + }, + }); +})();