diff --git a/ui/src/app/dashboard/component/Ordered.js b/ui/src/app/dashboard/component/Ordered.js index 76d713202..117e28eed 100644 --- a/ui/src/app/dashboard/component/Ordered.js +++ b/ui/src/app/dashboard/component/Ordered.js @@ -20,7 +20,7 @@ export const mergeOrderFn = (entities, order) => { return ordered; }; -export function Ordered ({path = '/MetadataResolvers', entities, children}) { +export function Ordered({ path = '/MetadataResolversPositionOrder', entities, children, prop = null}) { const orderEntities = (orderById, list) => { setOrdered(mergeOrderFn(list, orderById)); @@ -37,9 +37,11 @@ export function Ordered ({path = '/MetadataResolvers', entities, children}) { const [lastId, setLastId] = React.useState(null); async function changeOrder(resourceIds) { - await post(path, { - resourceIds - }); + await post(path, prop ? { + [prop]: resourceIds + } : [ + ...resourceIds + ]); if (response.ok) { loadOrder(); } @@ -60,7 +62,7 @@ export function Ordered ({path = '/MetadataResolvers', entities, children}) { async function loadOrder () { const o = await get(path); if (response.ok) { - const ids = o.resourceIds; + const ids = prop ? o.hasOwnProperty(prop) ? o[prop] : o : o; setOrder(ids); setFirstId(first(ids)); setLastId(last(ids)); diff --git a/ui/src/app/dashboard/container/ProvidersTab.js b/ui/src/app/dashboard/container/ProvidersTab.js index 7da1c306f..f5a2d719b 100644 --- a/ui/src/app/dashboard/container/ProvidersTab.js +++ b/ui/src/app/dashboard/container/ProvidersTab.js @@ -17,7 +17,7 @@ export function ProvidersTab () { const { get, response } = useMetadataEntities('provider'); async function loadProviders() { - const providers = await get('/') + const providers = await get('') if (response.ok) { setProviders(providers); } @@ -39,7 +39,7 @@ export function ProvidersTab () {
- + {(ordered, first, last, onOrderUp, onOrderDown) => {(searched) => { scroller.scrollTo(element, { @@ -85,7 +87,7 @@ export function MetadataOptions () {
-   +   Add Filter
@@ -97,7 +99,7 @@ export function MetadataOptions () { }
diff --git a/ui/src/app/metadata/component/properties/FilterTargetProperty.js b/ui/src/app/metadata/component/properties/FilterTargetProperty.js new file mode 100644 index 000000000..cc7490af8 --- /dev/null +++ b/ui/src/app/metadata/component/properties/FilterTargetProperty.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { ArrayProperty } from './ArrayProperty'; +import { PrimitiveProperty } from './PrimitiveProperty'; + +export function FilterTargetProperty ({ property, columns, onPreview }) { + return ( + <> + {property.properties.map((prop, idx) => + + { prop.type === 'array' ? + + : + + } + + )} + + ); +} \ No newline at end of file diff --git a/ui/src/app/metadata/component/properties/ObjectProperty.js b/ui/src/app/metadata/component/properties/ObjectProperty.js index 8494d24a7..a04e082d0 100644 --- a/ui/src/app/metadata/component/properties/ObjectProperty.js +++ b/ui/src/app/metadata/component/properties/ObjectProperty.js @@ -3,6 +3,7 @@ import React from 'react'; import { PrimitiveProperty } from './PrimitiveProperty'; import { ArrayProperty } from './ArrayProperty'; import Translate from '../../../i18n/components/translate'; +import { FilterTargetProperty } from './FilterTargetProperty'; export function ObjectProperty ({ property, columns, onPreview }) { const getProperty = (prop, idx) => { @@ -10,9 +11,19 @@ export function ObjectProperty ({ property, columns, onPreview }) { case 'array': return case 'object': + if (prop.widget && prop.widget.id && prop.widget.id === 'filter-target') { + console.log(prop); + } return - {prop.name &&
} - + {prop.widget && prop.widget.id && prop.widget.id === 'filter-target' ? + + : + + {prop.name &&
} + +
+ } +
default: return @@ -25,21 +36,3 @@ export function ObjectProperty ({ property, columns, onPreview }) { ); } - -/* - - - -
{{ prop.name | translate }}
- -
- -
- - - -*/ \ No newline at end of file diff --git a/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js index 7ff51a827..3c61e490b 100644 --- a/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js +++ b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js @@ -70,7 +70,7 @@ export const NameIDFilterEditor = { { id: 'options', label: 'label.options', - index: 1, + index: 2, initialValues: [], fields: [ 'removeExistingFormats', diff --git a/ui/src/app/metadata/domain/filter/component/MetadataFilterConfigurationListItem.js b/ui/src/app/metadata/domain/filter/component/MetadataFilterConfigurationListItem.js index e3f863f40..fe6938902 100644 --- a/ui/src/app/metadata/domain/filter/component/MetadataFilterConfigurationListItem.js +++ b/ui/src/app/metadata/domain/filter/component/MetadataFilterConfigurationListItem.js @@ -1,12 +1,35 @@ import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faArrowCircleDown, faArrowCircleUp } from '@fortawesome/free-solid-svg-icons'; +import { faArrowCircleDown, faArrowCircleUp, faChevronUp, faEdit, faTrash } from '@fortawesome/free-solid-svg-icons'; import { Translate } from '../../../../i18n/components/translate'; +import { Link } from 'react-router-dom'; +import { getDefinition } from '../../../domain/index'; +import { useMetadataSchema } from '../../../hooks/api'; +import { MetadataConfiguration } from '../../../component/MetadataConfiguration'; +import { useMetadataConfiguration } from '../../../hooks/configuration'; export function MetadataFilterConfigurationListItem ({ filter, isLast, isFirst, onOrderUp, onOrderDown, editable, onRemove, index }) { const [open, setOpen] = React.useState(false); + + const definition = React.useMemo(() => getDefinition(filter['@type'], ), [filter]); + + const { get, response } = useMetadataSchema(); + + const [schema, setSchema] = React.useState(); + + async function loadSchema(d) { + const source = await get(`/${d.schema}`) + if (response.ok) { + setSchema(source); + } + } + + /*eslint-disable react-hooks/exhaustive-deps*/ + React.useEffect(() => { loadSchema(definition) }, [definition]); + + const configuration = useMetadataConfiguration([filter], schema, definition); return (<>
@@ -31,37 +54,31 @@ export function MetadataFilterConfigurationListItem ({ filter, isLast, isFirst,
- - ); -} - -/* - -
-
-
-
- -   - Edit - - +
+
+ } + {configuration && } +
- - - - -*/ \ No newline at end of file + } + ); +} \ No newline at end of file diff --git a/ui/src/app/metadata/hooks/configuration.js b/ui/src/app/metadata/hooks/configuration.js index b65b72a0f..6efd0ef38 100644 --- a/ui/src/app/metadata/hooks/configuration.js +++ b/ui/src/app/metadata/hooks/configuration.js @@ -1,11 +1,10 @@ -import React from 'react'; - -import { MetadataDefinitionContext, MetadataSchemaContext } from '../hoc/MetadataSchema'; import { getConfigurationSections } from './schema'; -export function useMetadataConfiguration(models) { - const definition = React.useContext(MetadataDefinitionContext); - const schema = React.useContext(MetadataSchemaContext); +export function useMetadataConfiguration(models, schema, definition) { + + if (!models || !schema || !definition) { + return {}; + } const processed = definition.schemaPreprocessor ? definition.schemaPreprocessor(schema) : schema;