Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Properly reset controller of admin-user-index. (#6760)
- Loading branch information
Showing
5 changed files
with
105 additions
and
77 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/assets/javascripts/admin/components/admin-editable-field.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export default Ember.Component.extend({ | ||
tagName: "", | ||
|
||
buffer: "", | ||
editing: false, | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.set("editing", false); | ||
}, | ||
|
||
actions: { | ||
edit() { | ||
this.set("buffer", this.get("value")); | ||
this.toggleProperty("editing"); | ||
}, | ||
|
||
save() { | ||
// Action has to toggle 'editing' property. | ||
this.action(this.get("buffer")); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/assets/javascripts/admin/templates/components/admin-editable-field.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class='field'>{{i18n name}}</div> | ||
<div class='value'> | ||
{{#if editing}} | ||
{{text-field value=buffer autofocus="autofocus"}} | ||
{{else}} | ||
<span {{action "edit"}}>{{value}}</span> | ||
{{/if}} | ||
</div> | ||
<div class='controls'> | ||
{{#if editing}} | ||
{{d-button class="btn-default" action=(action "save") label="admin.user_fields.save"}} | ||
<a href {{action "edit"}}>{{i18n 'cancel'}}</a> | ||
{{else}} | ||
{{d-button class="btn-default" action=(action "edit") icon="pencil"}} | ||
{{/if}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { acceptance } from "helpers/qunit-helpers"; | ||
|
||
acceptance("Admin - User Index", { loggedIn: true }); | ||
|
||
QUnit.test("can edit username", async assert => { | ||
/* global server */ | ||
server.put("/users/sam/preferences/username", () => [ | ||
200, | ||
{ "Content-Type": "application/json" }, | ||
{ id: 2, username: "new-sam" } | ||
]); | ||
|
||
await visit("/admin/users/2/sam"); | ||
|
||
assert.equal( | ||
find(".display-row.username .value") | ||
.text() | ||
.trim(), | ||
"sam" | ||
); | ||
|
||
// Trying cancel. | ||
await click(".display-row.username button"); | ||
await fillIn(".display-row.username .value input", "new-sam"); | ||
await click(".display-row.username a"); | ||
assert.equal( | ||
find(".display-row.username .value") | ||
.text() | ||
.trim(), | ||
"sam" | ||
); | ||
|
||
// Doing edit. | ||
await click(".display-row.username button"); | ||
await fillIn(".display-row.username .value input", "new-sam"); | ||
await click(".display-row.username button"); | ||
assert.equal( | ||
find(".display-row.username .value") | ||
.text() | ||
.trim(), | ||
"new-sam" | ||
); | ||
}); |