Skip to content

Commit

Permalink
Fixed schema definition
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 30, 2021
1 parent e380361 commit af6e448
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CustomAttributeDefinition = {
return data;
}
const { attributeType } = data;
let { defaultValueBoolean, defaultValueString, ...parsed } = data;
let { defaultValueBoolean, ...parsed } = data;
if (attributeType === 'SELECTION_LIST') {
parsed = {
...parsed,
Expand All @@ -77,13 +77,6 @@ export const CustomAttributeDefinition = {
}
}

if (attributeType === 'STRING') {
parsed = {
...parsed,
defaultValue: defaultValueString
}
}

return parsed;
},

Expand All @@ -94,30 +87,28 @@ export const CustomAttributeDefinition = {
let { defaultValue, ...formatted } = changes;
const { attributeType } = changes;

if (attributeType === 'SELECTION_LIST') {
formatted = {
...formatted,
customAttrListDefinitions: formatted.customAttrListDefinitions.map(d => ({
value: d,
default: d === defaultValue
}))
}
}

if (attributeType === 'BOOLEAN') {
formatted = {
...formatted,
defaultValueBoolean: formatted.defaultValue === 'true' ? true : false,
invert: formatted.invert === 'true' ? true : false
// defaultValueBoolean: defaultValue === 'true' ? true : false
}
}

if (attributeType === 'STRING') {
formatted = {
...formatted,
defaultValueString: defaultValue
}
switch (attributeType) {
case 'SELECTION_LIST':
formatted = {
...formatted,
customAttrListDefinitions: formatted.customAttrListDefinitions.map(d => ({
value: d,
default: d === defaultValue
}))
}
break;
case 'BOOLEAN':
formatted = {
...formatted,
defaultValueBoolean: formatted.defaultValue === 'true' ? true : false,
invert: formatted.invert === 'true' ? true : false
}
break;
default:
formatted = {
...formatted,
defaultValue
}
}

return formatted;
Expand Down

0 comments on commit af6e448

Please sign in to comment.