From 9789ed1d843468e5e507b8863c612cbafcb46987 Mon Sep 17 00:00:00 2001 From: Jonas Metzener Date: Tue, 5 Dec 2023 16:06:43 +0100 Subject: [PATCH] fix(document): allow saving title by pressing enter --- addon/components/single-document-details.hbs | 34 ++++++++++--------- addon/components/single-document-details.js | 4 ++- .../single-document-details-test.js | 2 +- translations/de.yaml | 2 +- translations/en.yaml | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/addon/components/single-document-details.hbs b/addon/components/single-document-details.hbs index 12c08248..d1516bd2 100644 --- a/addon/components/single-document-details.hbs +++ b/addon/components/single-document-details.hbs @@ -24,22 +24,24 @@ {{set-style color=@document.category.color}} /> {{#if this.editTitle}} - - +
+ + +
{{else}} {{@document.title}} {{/if}} diff --git a/addon/components/single-document-details.js b/addon/components/single-document-details.js index afd43c22..b2e89af3 100644 --- a/addon/components/single-document-details.js +++ b/addon/components/single-document-details.js @@ -63,7 +63,9 @@ export default class SingleDocumentDetailsComponent extends DocumentCard { this.documents.enableShortcuts(); } - @restartableTask *saveDocument() { + @restartableTask *saveDocument(event) { + event?.preventDefault(); + try { yield this.args.document.save(); this.resetState(); diff --git a/tests/integration/components/single-document-details-test.js b/tests/integration/components/single-document-details-test.js index 1289c8a6..e4cd23c4 100644 --- a/tests/integration/components/single-document-details-test.js +++ b/tests/integration/components/single-document-details-test.js @@ -106,7 +106,7 @@ module("Integration | Component | single-document-details", function (hooks) { await fillIn("[data-test-title-input]", ""); assert.dom("[data-test-title-input]").hasValue(""); - assert.dom("[data-test-save]").hasClass("uk-disabled"); + assert.dom("[data-test-save]").isDisabled(); await fillIn("[data-test-title-input]", "edited"); assert.dom("[data-test-title-input]").hasValue("edited"); diff --git a/translations/de.yaml b/translations/de.yaml index 621173ec..d3f0d7bb 100644 --- a/translations/de.yaml +++ b/translations/de.yaml @@ -59,7 +59,7 @@ alexandria: document-date: "Dokumentendatum" metadata: "Metadaten" document-description: "Dokumentenbeschreibung" - name-placeholder: "Name..." + title-placeholder: "Titel..." version-history: "Versionsgeschichte" add-description: "Beschreibung hinzufügen" add-date: "Datum hinzufügen" diff --git a/translations/en.yaml b/translations/en.yaml index ea8fab20..f4260628 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -59,7 +59,7 @@ alexandria: document-date: "Document date" metadata: "Metadata" document-description: "Document description" - name-placeholder: "Name..." + title-placeholder: "Title..." version-history: "Version history" add-description: "Add description" add-date: "Add date"