From abe47db0622734e6bf2b55b393214334e34f53f8 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Wed, 12 Oct 2022 11:00:01 -0700 Subject: [PATCH] added selector widget --- .../main/resources/i18n/messages.properties | 3 + ui/public/assets/schema/groups/group.json | 8 ++ ui/src/app/admin/Groups.js | 12 ++- ui/src/app/admin/component/GroupForm.js | 3 +- ui/src/app/admin/container/EditGroup.js | 3 +- ui/src/app/admin/container/NewGroup.js | 3 +- ui/src/app/admin/hooks.js | 9 +++ ui/src/app/form/component/index.js | 4 +- .../component/widgets/MultiSelectWidget.js | 79 +++++++++++++++++++ 9 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 ui/src/app/form/component/widgets/MultiSelectWidget.js diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index d020b1000..2c50bc6b8 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -510,6 +510,9 @@ label.compare-selected=Compare Selected label.restore-version=Restore Version ({ date }) label.group=Group +label.approvers-list=Approvers +tooltip.approvers-list=List of groups who are able to approve Metadata Sources. + label.saved=Saved label.by=By diff --git a/ui/public/assets/schema/groups/group.json b/ui/public/assets/schema/groups/group.json index 518293851..200ce4529 100644 --- a/ui/public/assets/schema/groups/group.json +++ b/ui/public/assets/schema/groups/group.json @@ -22,6 +22,14 @@ "title": "label.url-validation-regex", "description": "tooltip.url-validation-regex", "type": "string" + }, + "approversList": { + "title": "label.approvers-list", + "description": "tooltip.approvers-list", + "type": "array", + "items": { + "type": "string" + } } } } \ No newline at end of file diff --git a/ui/src/app/admin/Groups.js b/ui/src/app/admin/Groups.js index 8326f9cd1..1e1743d9c 100644 --- a/ui/src/app/admin/Groups.js +++ b/ui/src/app/admin/Groups.js @@ -20,10 +20,18 @@ export function Groups() { } /> - + + {(groups) => + + } + } /> - + + {(groups) => + + } + } /> diff --git a/ui/src/app/admin/component/GroupForm.js b/ui/src/app/admin/component/GroupForm.js index d4390d6d8..7c9cd7a59 100644 --- a/ui/src/app/admin/component/GroupForm.js +++ b/ui/src/app/admin/component/GroupForm.js @@ -8,7 +8,7 @@ import Translate from '../../i18n/components/translate'; import { useGroupUiSchema, useGroupUiValidator } from '../hooks'; import { FormContext, setFormDataAction, setFormErrorAction } from '../../form/FormManager'; -export function GroupForm ({group = {}, errors = [], loading = false, schema, onSave, onCancel}) { +export function GroupForm ({group = {}, errors = [], context = {}, loading = false, schema, onSave, onCancel}) { const { dispatch } = React.useContext(FormContext); const onChange = ({formData, errors}) => { @@ -42,6 +42,7 @@ export function GroupForm ({group = {}, errors = [], loading = false, schema, on
onChange(form)} validate={validator} diff --git a/ui/src/app/admin/container/EditGroup.js b/ui/src/app/admin/container/EditGroup.js index ad06368fb..175ac4e69 100644 --- a/ui/src/app/admin/container/EditGroup.js +++ b/ui/src/app/admin/container/EditGroup.js @@ -13,7 +13,7 @@ import { createNotificationAction, NotificationTypes, useNotificationDispatcher import { useTranslator } from '../../i18n/hooks'; import { BASE_PATH } from '../../App.constant'; -export function EditGroup() { +export function EditGroup({ groups }) { const { id } = useParams(); @@ -74,6 +74,7 @@ export function EditGroup() { {(data, errors) => <> { + // const inputType = (type || schema.type) === 'string' ? 'text' : `${type || schema.type}`; + + const opts = []; + + React.useEffect(() => console.log(formContext), [formContext]); + React.useEffect(() => console.log(props), [props]); + + const [touched, setTouched] = React.useState(false); + + const [multiSelections, setMultiSelections] = React.useState([]); + + return ( + + 0) ? "text-danger" : ""}`} htmlFor={`option-selector-${id}`}> + + + {(label || schema.title) && required ? : Item {id + 1}} + + {schema.description && } + + + {rawErrors?.length > 0 && touched && ( + + {rawErrors.map((error, i) => { + return ( + 0 ? 'sr-only' : ''}`}> + + {error} + + + ); + })} + + )} + + ); +}; + +export default MultiSelectWidget; \ No newline at end of file