From c8a65e37dc88a7d1b29c00992a66ed7d814e9835 Mon Sep 17 00:00:00 2001 From: William Correa Date: Thu, 28 Mar 2019 21:48:49 -0300 Subject: [PATCH] [#4/feature] Move gender and yes/no options to i18n --- src/app/Prototype/Prototype/FieldIs.js | 10 ++++++---- src/domains/Common/options.js | 17 ++++++++++++----- .../Example/Test/Prototype/TestWithHooks.js | 2 +- src/domains/Example/Test/en-us.js | 4 ---- src/i18n/en-us/prototype/index.js | 10 ++++++++++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/app/Prototype/Prototype/FieldIs.js b/src/app/Prototype/Prototype/FieldIs.js index a8da1c3..7ee9c28 100644 --- a/src/app/Prototype/Prototype/FieldIs.js +++ b/src/app/Prototype/Prototype/FieldIs.js @@ -1,3 +1,8 @@ +import { yesNo } from 'src/domains/Common/options' + +/** + * @typedef {FieldIs} + */ export default { /** * @param {Object} options @@ -90,10 +95,7 @@ export default { */ fieldIsRadio (options = undefined, attrs = {}) { if (!Array.isArray(options)) { - options = [ - { value: true, label: 'Yes' }, - { value: false, label: 'No' } - ] + options = yesNo } this.setComponent('radio') this.setAttrs({ ...attrs, options }) diff --git a/src/domains/Common/options.js b/src/domains/Common/options.js index c7af8bc..23e39ca 100644 --- a/src/domains/Common/options.js +++ b/src/domains/Common/options.js @@ -1,8 +1,15 @@ /** - * @param {string} domain - * @returns {Array} + * @type {Array} */ -export const gender = (domain) => [ - { value: 'male', label: `domains.${domain}.gender.male` }, - { value: 'female', label: `domains.${domain}.gender.female` } +export const gender = [ + { value: 'male', label: 'prototype.options.gender.male' }, + { value: 'female', label: 'prototype.options.gender.female' } +] + +/** + * @type {Array} + */ +export const yesNo = [ + { value: true, label: 'prototype.options.yesNo.yes' }, + { value: false, label: 'prototype.options.yesNo.no' } ] diff --git a/src/domains/Example/Test/Prototype/TestWithHooks.js b/src/domains/Example/Test/Prototype/TestWithHooks.js index bc1dd72..9e561e8 100644 --- a/src/domains/Example/Test/Prototype/TestWithHooks.js +++ b/src/domains/Example/Test/Prototype/TestWithHooks.js @@ -42,7 +42,7 @@ export default class TestWithHooks extends Test { }) this.field('gender') - .fieldIsRadio(gender(TestWithHooks.domain)) + .fieldIsRadio(gender) .fieldFormOrder(4, true) .fieldFormWidth(55) .fieldOn('input', function ({ $event }) { diff --git a/src/domains/Example/Test/en-us.js b/src/domains/Example/Test/en-us.js index 2e9d82e..3a452b6 100644 --- a/src/domains/Example/Test/en-us.js +++ b/src/domains/Example/Test/en-us.js @@ -15,10 +15,6 @@ export default { gender: 'Gender', description: 'Description' }, - gender: { - male: 'Male', - female: 'Female' - }, active: { label: 'if checked will hide "Description"' }, diff --git a/src/i18n/en-us/prototype/index.js b/src/i18n/en-us/prototype/index.js index 7d6c8fe..b9826bd 100644 --- a/src/i18n/en-us/prototype/index.js +++ b/src/i18n/en-us/prototype/index.js @@ -16,6 +16,16 @@ export default { }, components: { }, + options: { + gender: { + male: 'Male', + female: 'Female' + }, + yesNo: { + yes: 'Yes', + no: 'No' + } + }, operations: { create: { success: 'Record created successfully'