From cc3cb6d02734adeb024d1604129e1c9b21a75bff Mon Sep 17 00:00:00 2001 From: yelinz Date: Fri, 26 Aug 2022 09:24:38 +0200 Subject: [PATCH] fix(analytics): improve alias save auto save alias input --- .../components/ca-field-selector-list.hbs | 2 +- .../ca-field-alias-input.hbs | 28 +++++-------------- .../ca-field-alias-input.js | 22 ++------------- .../ca-field-alias-input-test.js | 14 ++-------- packages/analytics/translations/de.yaml | 2 +- 5 files changed, 14 insertions(+), 54 deletions(-) diff --git a/packages/analytics/addon/components/ca-field-selector-list.hbs b/packages/analytics/addon/components/ca-field-selector-list.hbs index 13d3bf7bb..87b62ff41 100644 --- a/packages/analytics/addon/components/ca-field-selector-list.hbs +++ b/packages/analytics/addon/components/ca-field-selector-list.hbs @@ -21,7 +21,7 @@ diff --git a/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.hbs b/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.hbs index 1ff1be014..6591db820 100644 --- a/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.hbs +++ b/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.hbs @@ -1,21 +1,7 @@ -
- - - -
\ No newline at end of file + \ No newline at end of file diff --git a/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.js b/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.js index b10ca8ea6..34f6cbb87 100644 --- a/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.js +++ b/packages/analytics/addon/components/ca-field-selector-list/ca-field-alias-input.js @@ -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); } } diff --git a/packages/analytics/tests/integration/components/ca-field-selector-list/ca-field-alias-input-test.js b/packages/analytics/tests/integration/components/ca-field-selector-list/ca-field-alias-input-test.js index 89b383c69..051d14c30 100644 --- a/packages/analytics/tests/integration/components/ca-field-selector-list/ca-field-alias-input-test.js +++ b/packages/analytics/tests/integration/components/ca-field-selector-list/ca-field-alias-input-test.js @@ -1,4 +1,4 @@ -import { render, fillIn, click } from "@ember/test-helpers"; +import { render, fillIn } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { setupIntl } from "ember-intl/test-support"; import { setupRenderingTest } from "ember-qunit"; @@ -11,7 +11,7 @@ module( setupIntl(hooks, ["en"]); test("it renders", async function (assert) { - assert.expect(7); + assert.expect(4); this.set("alias", "some-alias"); this.set("onSave", (newAlias) => { @@ -20,20 +20,12 @@ module( }); await render( - hbs`` + hbs`` ); - assert.dom("[data-test-delete-field]").isNotVisible(); assert.dom("[data-test-field-alias-input]").hasValue(this.alias); await fillIn("[data-test-field-alias-input]", "changed alias"); - assert.dom("[data-test-delete-field]").isVisible(); - assert - .dom("[data-test-delete-field]") - .hasText(this.intl.t("caluma.analytics.edit.delete-field")); - - await click("button[data-test-delete-field]"); - assert.verifySteps(["save"]); assert.dom("[data-test-field-alias-input]").hasValue("changed alias"); }); diff --git a/packages/analytics/translations/de.yaml b/packages/analytics/translations/de.yaml index 3f866634a..144b9e45b 100644 --- a/packages/analytics/translations/de.yaml +++ b/packages/analytics/translations/de.yaml @@ -15,7 +15,7 @@ caluma: create-error: Beim Erstellen ist ein Fehler aufgetreten. fetch-error: Beim Laden der Daten ist ein Fehler aufgetreten. filter-exists: Filter existiert bereits!! - field-saved: Feld gespeichert.. + field-saved: Feld gespeichert. list: list-title: Liste aller Auswertungen edit: Bearbeiten