Skip to content

Commit

Permalink
fixing attribute form
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 23, 2021
1 parent 6b5ef7a commit 3a968af
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 21 deletions.
14 changes: 3 additions & 11 deletions ui/public/assets/schema/attribute/attribute.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,11 @@
"BOOLEAN"
]
},
"defaultValue": {
"defaultValueBoolean": {
"title": "label.entity-attribute-default",
"description": "tooltip.entity-attribute-default",
"type": "string",
"default": "true",
"enum": [
"true",
"false"
],
"enumNames": [
"True",
"False"
]
"type": "boolean",
"default": true
},
"persistValue": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/form/component/widgets/CheckboxWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CheckboxWidget = (props) => {
</span>
{schema.description && <InfoIcon value={schema.description} className="ml-2" />}
</span>}
checked={typeof value === "undefined" ? false : value}
checked={typeof value === "undefined" ? false : typeof value === 'boolean' ? value : value === 'true' ? true : false}
required={required}
disabled={disabled || readonly}
autoFocus={autofocus}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/form/component/widgets/RadioWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const RadioWidget = ({
const itemDisabled =
Array.isArray(enumDisabled) &&
enumDisabled.indexOf(option.value) !== -1;
const checked = option.value === value;
const checked = option.value.toString() === value.toString();

const radio = (
<Form.Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export const CustomAttributeDefinition = {
'attributeName',
'attributeFriendlyName',
'displayName',
'persistValue',
'persistType',
'helpText'
]
},
Expand All @@ -30,14 +28,20 @@ export const CustomAttributeDefinition = {
'defaultValue',
'defaultValueBoolean',
'defaultValueString',
'customAttrListDefinitions'
'customAttrListDefinitions',
'persistValue',
'persistType',
'invert'
]
}
]
},
defaultValueBoolean: {
'ui:widget': 'radio'
},
persistType: {
'ui:widget': 'hidden'
},
customAttrListDefinitions: {
'ui:field': 'StringListWithDefaultField',
'ui:title': 'label.entity-attribute-list-options',
Expand Down Expand Up @@ -100,7 +104,8 @@ export const CustomAttributeDefinition = {
if (attributeType === 'BOOLEAN') {
formatted = {
...formatted,
defaultValueBoolean: formatted.defaultValue === 'true' ? true : false
defaultValueBoolean: formatted.defaultValue === 'true' ? true : false,
invert: formatted.invert === 'true' ? true : false
}
}

Expand Down
1 change: 0 additions & 1 deletion ui/src/app/metadata/editor/MetadataAttributeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function MetadataAttributeEditor({ children }) {
</Form>
</div>
</div>
<pre>{JSON.stringify(errors, null, 4)}</pre>
</div>
);
}
2 changes: 1 addition & 1 deletion ui/src/app/metadata/view/MetadataAttributeEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function MetadataAttributeEdit() {
}

async function save(metadata) {
const resp = await put(``, definition.parser(metadata));
const resp = await put(`/${id}`, definition.parser(metadata));
if (response.ok) {
gotoDetail({ refresh: true });
} else {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/view/MetadataAttributeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export function MetadataAttributeList ({entities, onDelete}) {
<td>{attr.helpText}</td>
<td>{attr.defaultValue?.toString()}</td>
<td className="text-right">
<Link to={`../attributes/${attr.name}/edit`} className="btn btn-link text-primary">
<Link to={`../attributes/${attr.resourceId}/edit`} className="btn btn-link text-primary">
<FontAwesomeIcon icon={faEdit} size="lg" />
<span className="sr-only">
<Translate value="action.edit">Edit</Translate>
</span>
</Link>
<Button variant="link" className="text-danger" onClick={() => block(() => remove(attr.name))}>
<Button variant="link" className="text-danger" onClick={() => block(() => remove(attr.resourceId))}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
Expand Down

0 comments on commit 3a968af

Please sign in to comment.