diff --git a/app/components/ui/form.hbs b/app/components/ui/form.hbs index de20abab..7bf9a49e 100644 --- a/app/components/ui/form.hbs +++ b/app/components/ui/form.hbs @@ -1,68 +1,70 @@ -
- - - - {{yield - (hash - Checkbox=(component - "ui/form/checkbox" - changeset=this.changeset - isInline=true - isWide=CQ.features.wide - onUpdate=this.updateChangeset - ) - Input=(component - "ui/form/input" - changeset=this.changeset - isWide=CQ.features.wide - onUpdate=this.updateChangeset - ) - Number=(component - "ui/form/number" - changeset=this.changeset - isWide=CQ.features.wide - onUpdate=this.updateChangeset - ) - Select=(component - "ui/form/select" - changeset=this.changeset - isWide=CQ.features.wide - onUpdate=this.updateChangeset - ) - Textarea=(component - "ui/form/textarea" - changeset=this.changeset - isWide=CQ.features.wide - onUpdate=this.updateChangeset - ) - ) +{{#let (unique-id) as |formId|}} + + aria-labelledby={{if @title (concat formId "-title")}} + data-test-form={{or @title ""}} + local-class="form" + {{autofocus}} + {{on "submit" this.submitForm}} + > + -
- -
- \ No newline at end of file + {{yield + (hash + Checkbox=(component + "ui/form/checkbox" + changeset=this.changeset + isInline=true + isWide=CQ.features.wide + onUpdate=this.updateChangeset + ) + Input=(component + "ui/form/input" + changeset=this.changeset + isWide=CQ.features.wide + onUpdate=this.updateChangeset + ) + Number=(component + "ui/form/number" + changeset=this.changeset + isWide=CQ.features.wide + onUpdate=this.updateChangeset + ) + Select=(component + "ui/form/select" + changeset=this.changeset + isWide=CQ.features.wide + onUpdate=this.updateChangeset + ) + Textarea=(component + "ui/form/textarea" + changeset=this.changeset + isWide=CQ.features.wide + onUpdate=this.updateChangeset + ) + ) + }} +
+ +
+ +
+ +{{/let}} \ No newline at end of file diff --git a/app/components/ui/form.js b/app/components/ui/form.js index 6e8449ba..c106bc59 100644 --- a/app/components/ui/form.js +++ b/app/components/ui/form.js @@ -1,11 +1,8 @@ import { action } from '@ember/object'; -import { guidFor } from '@ember/object/internals'; import Component from '@glimmer/component'; import { TrackedObject } from 'tracked-built-ins'; export default class UiFormComponent extends Component { - formId = guidFor(this); - changeset = new TrackedObject(this.args.data ?? {}); @action submitForm(event) { diff --git a/app/components/ui/form/field.hbs b/app/components/ui/form/field.hbs index 32dfac3f..524b0dd6 100644 --- a/app/components/ui/form/field.hbs +++ b/app/components/ui/form/field.hbs @@ -1,25 +1,27 @@ -
-
- {{yield (hash inputId=this.inputId) to="label"}} -
- -
- {{yield (hash inputId=this.inputId) to="field"}} -
+{{#let (unique-id) as |inputId|}} +
+
+ {{yield (hash inputId=inputId) to="label"}} +
- {{#if @errorMessage}} -
- {{@errorMessage}} +
+ {{yield (hash inputId=inputId) to="field"}}
- {{/if}} -
\ No newline at end of file + + {{#if @errorMessage}} +
+ {{@errorMessage}} +
+ {{/if}} +
+{{/let}} \ No newline at end of file diff --git a/app/components/ui/form/field.js b/app/components/ui/form/field.js deleted file mode 100644 index 02fd2a74..00000000 --- a/app/components/ui/form/field.js +++ /dev/null @@ -1,6 +0,0 @@ -import { guidFor } from '@ember/object/internals'; -import Component from '@glimmer/component'; - -export default class UiFormFieldComponent extends Component { - inputId = guidFor(this); -}