Skip to content

Commit

Permalink
Merge a4d4f15 into 10c1fd7
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezequielpereyraa committed Aug 2, 2022
2 parents 10c1fd7 + a4d4f15 commit dcab14f
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 4 deletions.
Expand Up @@ -31,7 +31,8 @@ module.exports = {
{ type: 'number' }
]
},
label: { $ref: 'schemaDefinitions#/definitions/stringPrefix' }
label: { $ref: 'schemaDefinitions#/definitions/stringPrefix' },
groupName: { type: 'string' }
},
required: ['value', 'label'],
additionalProperties: false
Expand Down
Expand Up @@ -41,7 +41,8 @@ module.exports = {
},
required: ['label', 'value'],
additionalProperties: false
}
},
groupField: { type: 'string' }
},
required: ['endpoint'],
additionalProperties: false
Expand Down
2 changes: 2 additions & 0 deletions lib/schemas/browse/modules/filters/components/select.js
Expand Up @@ -14,9 +14,11 @@ module.exports = makeComponent({
icon: { type: 'string' },
preloadOptions: { type: 'boolean' },
responseProperty: { type: 'string' },
translateGroupLabel: { type: 'boolean' },
options: {
type: 'object',
properties: {
groupField: { type: 'string' },
scope: { enum: ['remote', 'local'] }
},
allOf: options,
Expand Down
1 change: 1 addition & 0 deletions lib/schemas/edit-new/modules/components/selects.js
Expand Up @@ -17,6 +17,7 @@ module.exports = makeComponent({
preloadOptions: { type: 'boolean' },
canCreate: { type: 'boolean' },
responseProperty: { type: 'string' },
translateGroupLabel: { type: 'boolean' },
targetField: {
oneOf: [
{ type: 'string' },
Expand Down
3 changes: 2 additions & 1 deletion lib/schemas/edit-new/modules/options/localOptions.js
Expand Up @@ -31,7 +31,8 @@ module.exports = {
{ type: 'number' }
]
},
label: { $ref: 'schemaDefinitions#/definitions/stringPrefix' }
label: { $ref: 'schemaDefinitions#/definitions/stringPrefix' },
groupName: { type: 'string' }
},
required: ['value', 'label'],
additionalProperties: false
Expand Down
3 changes: 2 additions & 1 deletion lib/schemas/edit-new/modules/options/remoteOptions.js
Expand Up @@ -39,7 +39,8 @@ module.exports = {
},
required: ['label', 'value'],
additionalProperties: false
}
},
groupField: { type: 'string' }
},
required: ['endpoint'],
additionalProperties: false
Expand Down
74 changes: 74 additions & 0 deletions tests/mocks/schemas/browse.json
Expand Up @@ -425,6 +425,35 @@
"icon": "iconName"
}
},
{
"name": "localSelectGroup",
"component": "Select",
"componentAttributes": {
"translateLabels": true,
"canClear": true,
"icon": "iconName",
"translateGroupLabel": true,
"options": {
"scope": "local",
"values": [
{
"label": "test",
"value": 1,
"groupName": "testGroup"
},
{
"label": "test2",
"value": 2,
"groupName": "testGroup"
},
{
"label": "test3",
"value": 3
}
]
}
}
},
{
"name": "localSelect",
"component": "Select",
Expand All @@ -443,6 +472,51 @@
}
}
},
{
"name": "remoteSelectGroup",
"component": "Select",
"componentAttributes": {
"translateLabels": true,
"preloadOptions": true,
"options": {
"scope": "remote",
"endpoint": {
"service": "sac",
"namespace": "claim-type",
"method": "list",
"resolve": false
},
"endpointParameters": [
{
"name": "status",
"target": "path",
"value": {
"static": 2
}
},
{
"name": "status",
"target": "query",
"value": {
"static": 1
}
}
],
"valuesMapper": {
"label": {
"template": "{0} {1} - ({2})",
"fields": [
"firstname",
"lastname",
"email"
]
},
"value": "id"
},
"groupField": "groupName"
}
}
},
{
"name": "remoteSelect",
"component": "Select",
Expand Down
47 changes: 47 additions & 0 deletions tests/mocks/schemas/edit.yml
Expand Up @@ -349,6 +349,53 @@ sections:
referenceValueType: static
referenceValue: null

- name: nameGroup
component: Select
componentAttributes:
translateLabels: true
labelFieldName: motiveName
translateGroupLabel: true
labelPrefix: common.status.
icon: iconName
options:
scope: local
valuesMapper:
label: name
value: id
values:
- label: active
value: 1
groupName: status
- label: inactive
value: 0
groupName: status
- label: pending
value: 2
validations:
- - name: required
- - name: maxLength
options:
length: 50
conditions:
enableWhen:
- - name: isEmpty
field: name
- name: isOneOf
field: someField
referenceValue:
- test1
- test2
- name: isDev
showWhen:
- - name: isNotEmpty
field:
- test
- name
- name: isNotEqualTo
field: name
referenceValueType: static
referenceValue: null

- name: description
component: Textarea
validations:
Expand Down
75 changes: 75 additions & 0 deletions tests/mocks/schemas/expected/browse.json
Expand Up @@ -459,6 +459,35 @@
"icon": "iconName"
}
},
{
"name": "localSelectGroup",
"component": "Select",
"componentAttributes": {
"translateLabels": true,
"canClear": true,
"icon": "iconName",
"translateGroupLabel": true,
"options": {
"scope": "local",
"values": [
{
"label": "test",
"value": 1,
"groupName": "testGroup"
},
{
"label": "test2",
"value": 2,
"groupName": "testGroup"
},
{
"label": "test3",
"value": 3
}
]
}
}
},
{
"name": "localSelect",
"component": "Select",
Expand All @@ -477,6 +506,52 @@
}
}
},
{
"name": "remoteSelectGroup",
"component": "Select",
"componentAttributes": {
"translateLabels": true,
"preloadOptions": true,
"options": {
"scope": "remote",
"searchParam": "filters[search]",
"endpoint": {
"service": "sac",
"namespace": "claim-type",
"method": "list",
"resolve": false
},
"endpointParameters": [
{
"name": "status",
"target": "path",
"value": {
"static": 2
}
},
{
"name": "status",
"target": "query",
"value": {
"static": 1
}
}
],
"valuesMapper": {
"label": {
"template": "{0} {1} - ({2})",
"fields": [
"firstname",
"lastname",
"email"
]
},
"value": "id"
},
"groupField": "groupName"
}
}
},
{
"name": "remoteSelect",
"component": "Select",
Expand Down
87 changes: 87 additions & 0 deletions tests/mocks/schemas/expected/edit.json
Expand Up @@ -560,6 +560,93 @@
]
}
},
{
"name": "nameGroup",
"component": "Select",
"componentAttributes": {
"translateLabels": true,
"labelFieldName": "motiveName",
"translateGroupLabel": true,
"labelPrefix": "common.status.",
"icon": "iconName",
"options": {
"scope": "local",
"valuesMapper": {
"label": "name",
"value": "id"
},
"values": [
{
"label": "active",
"value": 1,
"groupName": "status"
},
{
"label": "inactive",
"value": 0,
"groupName": "status"
},
{
"label": "pending",
"value": 2
}
]
}
},
"validations": [
[
{
"name": "required"
}
],
[
{
"name": "maxLength",
"options": {
"length": 50
}
}
]
],
"conditions": {
"enableWhen": [
[
{
"name": "isEmpty",
"field": "name"
},
{
"name": "isOneOf",
"field": "someField",
"referenceValue": [
"test1",
"test2"
]
},
{
"name": "isDev"
}
]
],
"showWhen": [
[
{
"name": "isNotEmpty",
"field": [
"test",
"name"
]
},
{
"name": "isNotEqualTo",
"field": "name",
"referenceValueType": "static",
"referenceValue": null
}
]
]
}
},
{
"name": "description",
"component": "Textarea",
Expand Down

0 comments on commit dcab14f

Please sign in to comment.