From 82b8c0c726343aa8bea9a2dc3f3e84d83a42de95 Mon Sep 17 00:00:00 2001 From: Eugen Ciur <eugen@papermerge.com> Date: Sun, 3 Oct 2021 06:57:15 +0200 Subject: [PATCH] automate add/form --- app/components/automates/add.hbs | 40 ++++++++++++++++++++++++++++++++ app/components/automates/add.js | 20 ++++++++++++++++ app/components/button/cancel.hbs | 15 ++++++++++++ app/components/button/cancel.js | 32 +++++++++++++++++++++++++ app/components/button/submit.hbs | 15 ++++++++++++ app/components/button/submit.js | 32 +++++++++++++++++++++++++ app/templates/automates/add.hbs | 4 +++- 7 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 app/components/automates/add.hbs create mode 100644 app/components/automates/add.js create mode 100644 app/components/button/cancel.hbs create mode 100644 app/components/button/cancel.js create mode 100644 app/components/button/submit.hbs create mode 100644 app/components/button/submit.js diff --git a/app/components/automates/add.hbs b/app/components/automates/add.hbs new file mode 100644 index 0000000..d550a2b --- /dev/null +++ b/app/components/automates/add.hbs @@ -0,0 +1,40 @@ +<div class="mb-3"> + <label for="name" class="form-label">Name</label> + <input type="email" class="form-control" id="name" placeholder="name@example.com" /> +</div> +<div class="mb-3"> + <label for="match" class="form-label">Match</label> + <input type="text" class="form-control" id="match" /> +</div> +<div class="mb-3"> + <label for="matching_algorithm" class="form-label">Matching Algorithm</label> + <select class="form-select" aria-label="Any"> + <option value="1" selected>Any</option> + <option value="2">All</option> + <option value="3">Literal</option> + <option value="4">Regular Expression</option> + </select> +</div> +<div class="mb-3"> + <input type="checkbox" class="form-control-checkbox" id="is_case_sensitive" /> + <label for="is_case_sensitive" class="form-label">Is case sensitive</label> +</div> +<div class="mb-3"> + <label for="tags" class="form-label">Tags</label> + <input type="text" class="form-control" id="tags" /> + <small class="form-text text-muted"> + These tags will be assigned to matched document. + </small> +</div> +<div class="mb-3"> + <label for="matching_algorithm" class="form-label">Destination Folder</label> + <select class="form-select"> + <option value="1">---</option> + <option value="2">My Documents</option> + <option value="3">Some Other Folder</option> + </select> +</div> +<div class="mb-3"> + <Button::Submit @onClick={{this.onSubmit}} /> + <Button::Cancel @route="automates"/> +</div> \ No newline at end of file diff --git a/app/components/automates/add.js b/app/components/automates/add.js new file mode 100644 index 0000000..5fe5503 --- /dev/null +++ b/app/components/automates/add.js @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; + + +class AddAutomateComponent extends Component { + /* + Component/Form to create new automate. + */ + + @service store; + + @action + onSubmit() { + } + +} + +export default AddAutomateComponent; \ No newline at end of file diff --git a/app/components/button/cancel.hbs b/app/components/button/cancel.hbs new file mode 100644 index 0000000..fcf9b96 --- /dev/null +++ b/app/components/button/cancel.hbs @@ -0,0 +1,15 @@ +{{#if @route}} + <LinkTo + @route={{@route}} + class="btn btn-light btn-flat"> + {{this.text}} + </LinkTo> +{{else}} + <button + class="btn btn-light btn-flat" + type="button" + {{on "click" @onClick}}> + <i class="bi bi-x mx-1"></i> + {{this.text}} + </button> +{{/if}} diff --git a/app/components/button/cancel.js b/app/components/button/cancel.js new file mode 100644 index 0000000..625e4c8 --- /dev/null +++ b/app/components/button/cancel.js @@ -0,0 +1,32 @@ +import Component from '@glimmer/component'; + + +class ButtonCancelComponent extends Component { + /* + "Cancel Button" component. Renders a button as either + html <a> tag or as <button>. + + Arguments: + @route - if `route` argument is provided, button will + be rendered as <a>. + @onClick - if `onClick` argument is provided - button + will be rendered as <button>. + @text - button's text. Default value is "Cancel". + + Examples: + + Render component as <button> with `onClick` handler: + + <Button::Cancel @onClick={{this.onCancel}} /> + + Render componet as <a> with given route: + + <Button::Cancel @route="automates" /> + */ + + get text() { + return this.args.text || "Cancel"; + } +} + +export default ButtonCancelComponent; \ No newline at end of file diff --git a/app/components/button/submit.hbs b/app/components/button/submit.hbs new file mode 100644 index 0000000..8e8f37a --- /dev/null +++ b/app/components/button/submit.hbs @@ -0,0 +1,15 @@ +{{#if @route}} + <LinkTo + @route={{@route}} + class="bi bi-check-lg"> + {{this.text}} + </LinkTo> +{{else}} + <button + class="btn btn-primary mx-2" + type="button" + {{on "click" @onClick}}> + <i class="bi bi-check-lg"></i> + {{this.text}} + </button> +{{/if}} diff --git a/app/components/button/submit.js b/app/components/button/submit.js new file mode 100644 index 0000000..8cc3c7a --- /dev/null +++ b/app/components/button/submit.js @@ -0,0 +1,32 @@ +import Component from '@glimmer/component'; + + +class ButtonSubmitComponent extends Component { + /* + "Submit Button" component. Renders a button as either + html <a> tag or as <button>. + + Arguments: + @route - if `route` argument is provided, button will + be rendered as <a>. + @onClick - if `onClick` argument is provided - button + will be rendered as <button>. + @text - button's text. Default value is "Submit". + + Examples: + + Render component as <button> with `onClick` handler: + + <Button::Submit @onClick={{this.onCancel}} /> + + Render componet as <a> with given route: + + <Button::Submit @route="automates" /> + */ + + get text() { + return this.args.text || "Submit"; + } +} + +export default ButtonSubmitComponent; \ No newline at end of file diff --git a/app/templates/automates/add.hbs b/app/templates/automates/add.hbs index 61cd364..b6889ce 100644 --- a/app/templates/automates/add.hbs +++ b/app/templates/automates/add.hbs @@ -1 +1,3 @@ -<h1>New Automate</h1> \ No newline at end of file +<h1>New Automate</h1> + +<Automates::Add /> \ No newline at end of file -- GitLab