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 bb7b6b9a..0d7aa4ae 100644 --- a/addon/templates/users/edit.hbs +++ b/addon/templates/users/edit.hbs @@ -61,12 +61,12 @@ {{#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 fc7aef4c..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" @@ -30,7 +31,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..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" @@ -31,6 +32,7 @@ emeis: lastName: "Last Name" email: "E-Mail" phone: "Phone" + phone-placeholder: "+41 31 123 45 56" language: "Language" address: "Address" city: "City"