Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
[#4/feature] Move gender and yes/no options to i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
wilcorrea committed Mar 29, 2019
1 parent f13c44c commit c8a65e3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/app/Prototype/Prototype/FieldIs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { yesNo } from 'src/domains/Common/options'

/**
* @typedef {FieldIs}
*/
export default {
/**
* @param {Object} options
Expand Down Expand Up @@ -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 })
Expand Down
17 changes: 12 additions & 5 deletions src/domains/Common/options.js
Original file line number Diff line number Diff line change
@@ -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' }
]
2 changes: 1 addition & 1 deletion src/domains/Example/Test/Prototype/TestWithHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
4 changes: 0 additions & 4 deletions src/domains/Example/Test/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export default {
gender: 'Gender',
description: 'Description'
},
gender: {
male: 'Male',
female: 'Female'
},
active: {
label: 'if checked will hide "Description"'
},
Expand Down
10 changes: 10 additions & 0 deletions src/i18n/en-us/prototype/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ export default {
},
components: {
},
options: {
gender: {
male: 'Male',
female: 'Female'
},
yesNo: {
yes: 'Yes',
no: 'No'
}
},
operations: {
create: {
success: 'Record created successfully'
Expand Down

0 comments on commit c8a65e3

Please sign in to comment.