From 998fcf243e6232f551f350e4da89d33f4f969292 Mon Sep 17 00:00:00 2001 From: guidojw <35309288+guidojw@users.noreply.github.com> Date: Tue, 17 Oct 2023 00:20:03 +0200 Subject: [PATCH] refactor(model-form): Glimmer RadioGroup and RadioButton --- app/components/model-form/file-input.ts | 2 +- app/components/model-form/radio-button.hbs | 1 + app/components/model-form/radio-button.js | 24 ---------- app/components/model-form/radio-group.hbs | 52 +++++++++++++--------- app/components/model-form/radio-group.js | 6 --- app/components/model-form/radio-group.ts | 3 ++ app/components/model-form/text-input.ts | 3 +- 7 files changed, 37 insertions(+), 54 deletions(-) create mode 100644 app/components/model-form/radio-button.hbs delete mode 100644 app/components/model-form/radio-button.js delete mode 100644 app/components/model-form/radio-group.js create mode 100644 app/components/model-form/radio-group.ts diff --git a/app/components/model-form/file-input.ts b/app/components/model-form/file-input.ts index 9281108a6..4098aac16 100644 --- a/app/components/model-form/file-input.ts +++ b/app/components/model-form/file-input.ts @@ -4,7 +4,7 @@ import type { UploadFile } from 'ember-file-upload'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -export interface FileInputSignature { +export interface FileInputSignature extends TextInputSignature { Args: TextInputSignature['Args'] & { validMimeTypes?: string[]; validExtensions?: string[]; diff --git a/app/components/model-form/radio-button.hbs b/app/components/model-form/radio-button.hbs new file mode 100644 index 000000000..12ebb78fc --- /dev/null +++ b/app/components/model-form/radio-button.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/components/model-form/radio-button.js b/app/components/model-form/radio-button.js deleted file mode 100644 index 9c24077d7..000000000 --- a/app/components/model-form/radio-button.js +++ /dev/null @@ -1,24 +0,0 @@ -import Component from '@ember/component'; -import { computed } from '@ember/object'; - -export default Component.extend({ - tagName: 'input', - type: 'radio', - groupValue: null, - attributeBindings: [ - 'checked', - 'disabled', - 'name', - 'required', - 'type', - 'value', - ], - checked: computed('groupValue', 'value', function () { - return this.groupValue === this.value; - }).readOnly(), - change() { - if (this.groupValue !== this.value) { - this.set('groupValue', this.value); - } - }, -}); diff --git a/app/components/model-form/radio-group.hbs b/app/components/model-form/radio-group.hbs index 2225baf80..e349f70b8 100644 --- a/app/components/model-form/radio-group.hbs +++ b/app/components/model-form/radio-group.hbs @@ -1,23 +1,31 @@ - -