-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto save alias input
- Loading branch information
Showing
5 changed files
with
14 additions
and
54 deletions.
There are no files selected for viewing
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
28 changes: 7 additions & 21 deletions
28
packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.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 |
---|---|---|
@@ -1,21 +1,7 @@ | ||
<div class="uk-inline"> | ||
<button | ||
data-test-delete-field | ||
type="button" | ||
class="uk-form-icon uk-form-icon-flip" | ||
uk-icon="check" | ||
hidden={{not this.hasChanged}} | ||
name={{t "caluma.analytics.edit.delete-field"}} | ||
{{on "click" this.trimAndSave}} | ||
> | ||
<span hidden>{{t "caluma.analytics.edit.delete-field"}}</span> | ||
</button> | ||
|
||
<input | ||
data-test-field-alias-input | ||
aria-label={{t "caluma.analytics.edit.display-title"}} | ||
class="uk-input {{if this.hasChanged 'uk-form-success'}}" | ||
value={{this.value}} | ||
{{on "input" (perform this.debounceInput)}} | ||
/> | ||
</div> | ||
<input | ||
data-test-field-alias-input | ||
aria-label={{t "caluma.analytics.edit.display-title"}} | ||
class="uk-input" | ||
value={{@value}} | ||
{{on "input" (perform this.debounceInput)}} | ||
/> |
22 changes: 2 additions & 20 deletions
22
packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.js
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 |
---|---|---|
@@ -1,28 +1,10 @@ | ||
import { action } from "@ember/object"; | ||
import Component from "@glimmer/component"; | ||
import { tracked } from "@glimmer/tracking"; | ||
import { restartableTask, timeout } from "ember-concurrency"; | ||
|
||
export default class CaFieldSelectorListCaFieldAliasInputComponent extends Component { | ||
@tracked _value = null; | ||
|
||
get value() { | ||
return this._value ?? this.args.value; | ||
} | ||
|
||
get hasChanged() { | ||
return this._value !== null && this._value !== this.args.value; | ||
} | ||
|
||
@action | ||
async trimAndSave() { | ||
await this.args.onSave(this._value); | ||
this._value = null; | ||
} | ||
|
||
@restartableTask | ||
*debounceInput(event) { | ||
yield timeout(200); | ||
this._value = event.target.value; | ||
yield timeout(500); | ||
yield this.args.onInput(event.target.value); | ||
} | ||
} |
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