Skip to content

Commit

Permalink
fix(document): allow saving title by pressing enter
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Dec 5, 2023
1 parent a302d26 commit 9789ed1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
34 changes: 18 additions & 16 deletions addon/components/single-document-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@
{{set-style color=@document.category.color}}
/>
{{#if this.editTitle}}
<input
class="uk-input uk-width-auto"
id="alexandria-details-title"
type="text"
placeholder={{t "alexandria.document-details.name-placeholder"}}
value={{@document.title}}
data-test-title-input
{{on "input" this.updateDocumentTitle}}
/>
<button
class="uk-icon-button uk-margin-small-left {{unless this.validTitle 'uk-disabled'}} cursor-pointer"
uk-icon="icon: check"
type="button"
data-test-save
{{on "click" (perform this.saveDocument)}}
></button>
<form {{on "submit" (perform this.saveDocument)}}>
<input
class="uk-input uk-width-auto {{unless this.validTitle "uk-form-danger"}}"
id="alexandria-details-title"
type="text"
placeholder={{t "alexandria.document-details.title-placeholder"}}
value={{@document.title}}
data-test-title-input
{{on "input" this.updateDocumentTitle}}
/>
<button
class="uk-icon-button uk-margin-small-left cursor-pointer"
disabled={{not this.validTitle}}
uk-icon="icon: check"
type="submit"
data-test-save
></button>
</form>
{{else}}
<span data-test-title>{{@document.title}}</span>
{{/if}}
Expand Down
4 changes: 3 additions & 1 deletion addon/components/single-document-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9789ed1

Please sign in to comment.