Skip to content

Commit

Permalink
feat(document-details): add form to edit the document's description
Browse files Browse the repository at this point in the history
This uses the same idea/logic as the title edit form.
  • Loading branch information
fkm-adfinis committed Jan 14, 2021
1 parent 2313e02 commit 55f0973
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
43 changes: 43 additions & 0 deletions addon/components/document-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,49 @@
</span>
</span>

<p class="uk-flex">
{{#if this.editDescription}}
<textarea
class="uk-textarea"
{{on "input" this.updateDocumentDescription}}
>
{{~@document.description~}}
</textarea>
<div class="uk-flex uk-flex-column">
<a
class="uk-icon-button cursor-pointer"
href="#"
uk-icon="icon: check"
{{on "click" (perform this.saveDocument)}}
></a>
<a
href="#"
class="uk-icon-button cursor-pointer"
uk-icon="icon: close"
{{on "click" (set this.editDescription false)}}
></a>
</div>
{{else}}
{{#if @document.description}}
<a
class="uk-link-reset"
href="#"
{{on "click" (set this.editDescription true)}}
>
{{@document.description}}
</a>
{{else}}
<a
class="uk-link-reset"
href="#"
{{on "click" (set this.editDescription true)}}
>
{{t "alexandria.document-details.add-description"}}
</a>
{{/if}}
{{/if}}
</p>

<span class="document-meta">
<p data-test-created-at>
{{t
Expand Down
8 changes: 7 additions & 1 deletion addon/components/document-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class DocumentDetailsComponent extends DocumentCard {
@service tags;

@tracked editTitle = false;
@tracked editDescription = false;
@tracked validTitle = true;
@tracked matchingTags = [];

Expand All @@ -23,15 +24,20 @@ export default class DocumentDetailsComponent extends DocumentCard {
this.args.document.title = title;
}

@action updateDocumentDescription({ target: { value: description } }) {
this.args.document.description = description;
}

@action resetState() {
this.editTitle = false;
this.validTitle = true;
this.editDescription = false;
}

@restartableTask *saveDocument() {
try {
yield this.args.document.save();
this.editTitle = false;
this.resetState();
this.notification.success(this.intl.t("alexandria.success.update"));
} catch (error) {
this.notification.danger(this.intl.t("alexandria.errors.update"));
Expand Down
1 change: 1 addition & 0 deletions translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ alexandria:
created-at: "Erstellt am {date}"
name-placeholder: "Name..."
version-history: "Versionsgeschichte"
add-description: "Beschreibung hinzufügen"
replace: "Ersetzen"
tags:
title: "Tags"
Expand Down
1 change: 1 addition & 0 deletions translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ alexandria:
created-at: "Created on {date}"
name-placeholder: "Name..."
version-history: "Version history"
add-description: "Add description"
replace: "Replace"
tags:
title: "Tags"
Expand Down

0 comments on commit 55f0973

Please sign in to comment.