From 287b47c6935a589a7b9f416f6cf010c278730a22 Mon Sep 17 00:00:00 2001 From: Eugen Ciur <eugen@papermerge.com> Date: Sun, 31 Oct 2021 10:36:01 +0100 Subject: [PATCH] cancel action for new folder component --- app/components/modal/base.hbs | 4 ++-- app/components/modal/new_folder.hbs | 1 + app/components/modal/new_folder.js | 6 ++++++ app/controllers/authenticated/index.js | 10 +++++----- app/templates/authenticated/index.hbs | 6 +++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/components/modal/base.hbs b/app/components/modal/base.hbs index dd0e451..7cddfa3 100644 --- a/app/components/modal/base.hbs +++ b/app/components/modal/base.hbs @@ -12,8 +12,8 @@ <button type="button" class="btn btn-secondary" - data-bs-dismiss="modal">Cancel - </button> + data-bs-dismiss="modal" + {{on "click" @onCancel}}>Cancel</button> <button type="button" class="btn btn-primary" diff --git a/app/components/modal/new_folder.hbs b/app/components/modal/new_folder.hbs index 58c7af9..281d0cf 100644 --- a/app/components/modal/new_folder.hbs +++ b/app/components/modal/new_folder.hbs @@ -4,6 +4,7 @@ @actionTitle="Create" @onClose={{@onClose}} @onSubmit={{this.onSubmit}} + @onCancel={{this.onCancel}} ...attributes > <label for="folder-title" class="form-label">Folder title:</label> diff --git a/app/components/modal/new_folder.js b/app/components/modal/new_folder.js index 959912a..8a3897e 100644 --- a/app/components/modal/new_folder.js +++ b/app/components/modal/new_folder.js @@ -11,6 +11,12 @@ export default class NewFolderComponent extends Component { onSubmit() { console.log(`title=${this.title}`); this.args.onClose(); + this.title = ''; } + @action + onCancel() { + this.args.onClose(); + this.title = ''; + } } diff --git a/app/controllers/authenticated/index.js b/app/controllers/authenticated/index.js index 5baa155..443ccef 100644 --- a/app/controllers/authenticated/index.js +++ b/app/controllers/authenticated/index.js @@ -4,15 +4,15 @@ import { tracked } from "@glimmer/tracking"; export default class IndexController extends Controller { - @tracked show_new_folder = false; + @tracked show_new_folder_modal = false; @action - newFolder() { - this.show_new_folder = true; + openNewFolderModal() { + this.show_new_folder_modal = true; } @action - closeNewFolder() { - this.show_new_folder = false; + closeNewFolderModal() { + this.show_new_folder_modal = false; } } diff --git a/app/templates/authenticated/index.hbs b/app/templates/authenticated/index.hbs index e3ad06b..96cffdf 100644 --- a/app/templates/authenticated/index.hbs +++ b/app/templates/authenticated/index.hbs @@ -6,7 +6,7 @@ </button> <button class="btn btn-bordered btn-light btn-flat" - type="button" {{on "click" this.newFolder }}> + type="button" {{on "click" this.openNewFolderModal }}> <i class="fa fa-plus mr-1 text-success"></i> New Folder </button> @@ -16,5 +16,5 @@ Documents and Folders will be displayed here! <Modal::NewFolder id="new-folder" - @onClose={{this.closeNewFolder}} - {{show-when this.show_new_folder}} /> \ No newline at end of file + @onClose={{this.closeNewFolderModal}} + {{show-when this.show_new_folder_modal}} /> \ No newline at end of file -- GitLab