From a72335c158f68939b42e4cdd7b97960c86a5a79c Mon Sep 17 00:00:00 2001 From: Falk Date: Wed, 8 Jun 2022 15:09:31 +0200 Subject: [PATCH 1/2] fix(user): change phone placeholder --- addon/templates/users/edit.hbs | 2 +- translations/de.yaml | 3 ++- translations/en.yaml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/templates/users/edit.hbs b/addon/templates/users/edit.hbs index bb7b6b9a..6cf56b0e 100644 --- a/addon/templates/users/edit.hbs +++ b/addon/templates/users/edit.hbs @@ -66,7 +66,7 @@ class="uk-input" type="tel" name="phone" - placeholder="{{t "emeis.users.headings.phone"}}..." + placeholder="{{t "emeis.users.headings.phone-placeholder"}}..." required={{includes "phone" this.requiredFields}} pattern="^[0-9()\-\s]+$" value={{@model.phone}} diff --git a/translations/de.yaml b/translations/de.yaml index fc7aef4c..3947d255 100644 --- a/translations/de.yaml +++ b/translations/de.yaml @@ -30,7 +30,8 @@ emeis: firstName: "Vorname" lastName: "Nachname" email: "E-Mail" - phone: "Telefonnummer" + phone: "Telefon" + phone-placeholder: "+41 31 123 45 56" language: "Sprache" address: "Adresse" city: "Stadt" diff --git a/translations/en.yaml b/translations/en.yaml index 65bef351..b4d3b69f 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -31,6 +31,7 @@ emeis: lastName: "Last Name" email: "E-Mail" phone: "Phone" + phone-placeholder: "+41 31 123 45 56" language: "Language" address: "Address" city: "City" From a9ad2deb0f65d99441737fcb49d9b8fde4716673 Mon Sep 17 00:00:00 2001 From: Falk Date: Thu, 16 Jun 2022 09:28:30 +0200 Subject: [PATCH 2/2] feat: mark optional fields Works for built in and custom meta fields. --- README.md | 11 +++++++++-- addon/components/edit-form/element.hbs | 3 +++ addon/components/meta-field.hbs | 6 ++++-- addon/templates/permissions/edit.hbs | 4 +++- addon/templates/roles/edit.hbs | 3 ++- addon/templates/scopes/edit.hbs | 6 +++--- addon/templates/users/edit.hbs | 14 +++++++------- tests/dummy/app/services/emeis-options.js | 3 +++ translations/de.yaml | 1 + translations/en.yaml | 1 + 10 files changed, 36 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 82d8794a..5f61ef0a 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,9 @@ export default class EmeisOptionsService extends Service { label: "My Input", // this could also be an ember-intl translation key type: "text", visible: true, - readOnly: false + readOnly: false, + required: false, //marks this field as optional + placeholder: "some.translation.key" //ember-intl translation key or plain string }, { slug: "test-input-2", @@ -146,7 +148,8 @@ export default class EmeisOptionsService extends Service { ], type: "choice", visible: () => true, - readOnly: false + readOnly: false, + required: true, //marks this field as required } ] } @@ -161,6 +164,10 @@ There are special options available for `options`, `type` and `visible` properti Defines the type of the output component and can either be a _text_ or a _choice_. +#### **required** - meta field + +Marks this field as optional or validates its presence in case it's set to `true`. Custom _choice_ fields may not be validated as required, tho. + #### **options** - meta field In combination with `type:"choice"` the options can be a list of options (`{value, label}`) or a (async) function which resolves to a list of options. diff --git a/addon/components/edit-form/element.hbs b/addon/components/edit-form/element.hbs index a2b2f811..593e72da 100644 --- a/addon/components/edit-form/element.hbs +++ b/addon/components/edit-form/element.hbs @@ -1,6 +1,9 @@
{{yield}} diff --git a/addon/components/meta-field.hbs b/addon/components/meta-field.hbs index dbaced46..01d017f7 100644 --- a/addon/components/meta-field.hbs +++ b/addon/components/meta-field.hbs @@ -1,5 +1,5 @@ {{#if this.visible.value}} - + {{#if (eq @field.type "choice")}} {{#if this.options.isRunning}} @@ -9,7 +9,7 @@ @options={{this.options.value}} @selected={{find-by "value" (get @model.metainfo @field.slug) this.options.value}} @onChange={{fn this.updateMetaField @field @model}} - @placeholder={{t @field.label}} + @placeholder={{optional-translate @field.placeholder}} @allowClear={{true}} @renderInPlace={{true}} as |option| @@ -25,6 +25,8 @@ type="text" value={{get @model.metainfo @field.slug}} disabled={{this.readOnly.value}} + required={{@field.required}} + placeholder={{optional-translate @field.placeholder}} {{on "input" (fn this.updateMetaField @field @model)}} > {{/if}} diff --git a/addon/templates/permissions/edit.hbs b/addon/templates/permissions/edit.hbs index c4a0dac8..e7fc5c2c 100644 --- a/addon/templates/permissions/edit.hbs +++ b/addon/templates/permissions/edit.hbs @@ -9,6 +9,7 @@ type="text" name="slug" pattern="^[-a-zA-Z0-9_]+$" + required disabled={{not @model.isNew}} value={{@model.slug}} /> @@ -46,7 +47,8 @@ @placeholder="{{t "emeis.permissions.headings.roles"}}..." @onChange={{set @model.roles}} @multiple="true" - required as |role| + required + as |role| > {{role.name}} diff --git a/addon/templates/roles/edit.hbs b/addon/templates/roles/edit.hbs index 34a4f6b8..543f30a2 100644 --- a/addon/templates/roles/edit.hbs +++ b/addon/templates/roles/edit.hbs @@ -3,12 +3,13 @@ {{t "emeis.form.back"}} - + diff --git a/addon/templates/scopes/edit.hbs b/addon/templates/scopes/edit.hbs index 8ca969a6..58c99e5f 100644 --- a/addon/templates/scopes/edit.hbs +++ b/addon/templates/scopes/edit.hbs @@ -21,7 +21,7 @@ /> - + - + {{#each this.metaFields as |field|}} - + {{/each}} diff --git a/addon/templates/users/edit.hbs b/addon/templates/users/edit.hbs index 6cf56b0e..0d7aa4ae 100644 --- a/addon/templates/users/edit.hbs +++ b/addon/templates/users/edit.hbs @@ -61,7 +61,7 @@ {{#if (includes "phone" this.visibleFields)}} - + + {{/if}} {{#if (includes "city" this.visibleFields)}} - + + + {{/each}} diff --git a/tests/dummy/app/services/emeis-options.js b/tests/dummy/app/services/emeis-options.js index 1e4418b5..45fa4eb2 100644 --- a/tests/dummy/app/services/emeis-options.js +++ b/tests/dummy/app/services/emeis-options.js @@ -34,6 +34,8 @@ export default class EmeisOptionsService extends Service { type: "text", visible: true, readOnly: false, + required: false, + placeholder: "emeis.options.meta.user.example", }, // { // slug: "user-meta-example-2", @@ -77,6 +79,7 @@ export default class EmeisOptionsService extends Service { }, visible: () => true, // boolean or function which evaluates to a boolean value readOnly: false, + required: false, }, { slug: "meta-example-2", diff --git a/translations/de.yaml b/translations/de.yaml index 3947d255..26a04be2 100644 --- a/translations/de.yaml +++ b/translations/de.yaml @@ -4,6 +4,7 @@ emeis: empty: "Keine Einträge gefunden..." loading: "Laden..." inactive: "Inaktiv" + optional: "optional" general-error: "Ein Problem ist aufgetretten. Bitte versuchen Sie es erneut." actions: "Aktionen" export: "Export" diff --git a/translations/en.yaml b/translations/en.yaml index b4d3b69f..a09681ac 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -4,6 +4,7 @@ emeis: empty: "No entries found..." loading: "Loading..." inactive: "Inactive" + optional: "optional" general-error: "A problem occured. Please try again." actions: "Actions" export: "Export"