Fix support for setting owner of group to a single user

Bug: Issue 9655
Change-Id: I3c9a7443e1fc1a4d70479c2f26c6a794612d03c7
(cherry picked from commit e74925fa8b)
This commit is contained in:
Paladox none 2018-10-05 23:17:03 +00:00
parent 1a882e7b0d
commit 3e05704f5b
3 changed files with 20 additions and 3 deletions

View File

@ -87,7 +87,9 @@ limitations under the License.
<fieldset>
<span class="value">
<gr-autocomplete
id="groupOwnerInput"
text="{{_groupConfig.owner}}"
value="{{_groupConfigOwner}}"
query="[[_query]]"
disabled="[[_computeGroupDisabled(_groupOwner, _isAdmin)]]">
</gr-autocomplete>

View File

@ -58,6 +58,7 @@
},
/** @type {?} */
_groupConfig: Object,
_groupConfigOwner: String,
_groupName: Object,
_groupOwner: {
type: Boolean,
@ -83,7 +84,7 @@
observers: [
'_handleConfigName(_groupConfig.name)',
'_handleConfigOwner(_groupConfig.owner)',
'_handleConfigOwner(_groupConfig.owner, _groupConfigOwner)',
'_handleConfigDescription(_groupConfig.description)',
'_handleConfigOptions(_groupConfig.options.visible_to_all)',
],
@ -143,8 +144,12 @@
},
_handleSaveOwner() {
let owner = this._groupConfig.owner;
if (this._groupConfigOwner) {
owner = decodeURIComponent(this._groupConfigOwner);
}
return this.$.restAPI.saveGroupOwner(this.groupId,
this._groupConfig.owner).then(config => {
owner).then(config => {
this._owner = false;
});
},
@ -202,7 +207,7 @@
if (!response.hasOwnProperty(key)) { continue; }
groups.push({
name: key,
value: response[key],
value: decodeURIComponent(response[key].id),
});
}
return groups;

View File

@ -86,6 +86,7 @@ limitations under the License.
element._groupConfig = {
name: groupName,
};
element._groupConfigOwner = 'testId';
element._groupName = groupName;
element._groupOwner = true;
@ -105,6 +106,8 @@ limitations under the License.
element.$.groupNameInput.text = groupName2;
element.$.groupOwnerInput.text = 'testId2';
assert.isFalse(button.hasAttribute('disabled'));
assert.isTrue(element.$.groupName.classList.contains('edited'));
@ -114,6 +117,13 @@ limitations under the License.
assert.equal(element._groupName, groupName2);
done();
});
element._handleSaveOwner().then(() => {
assert.isTrue(button.hasAttribute('disabled'));
assert.isFalse(element.$.Title.classList.contains('edited'));
assert.equal(element._groupConfigOwner, 'testId2');
done();
});
});
});