diff --git a/.github/workflows/production-ci-cd-pipeline.yml b/.github/workflows/production-ci-cd-pipeline.yml index 955e43a37..1829b0c94 100644 --- a/.github/workflows/production-ci-cd-pipeline.yml +++ b/.github/workflows/production-ci-cd-pipeline.yml @@ -18,7 +18,7 @@ jobs: deploy_and_build: name: Build and deploy runs-on: ubuntu-latest - environment: prod + environment: staging steps: - name: Install ssh keys diff --git a/mapping_workbench/backend/conceptual_mapping_rule/services/api.py b/mapping_workbench/backend/conceptual_mapping_rule/services/api.py index 7bb1b5394..e5d12a06e 100644 --- a/mapping_workbench/backend/conceptual_mapping_rule/services/api.py +++ b/mapping_workbench/backend/conceptual_mapping_rule/services/api.py @@ -8,10 +8,11 @@ from mapping_workbench.backend.conceptual_mapping_rule.models.entity import ConceptualMappingRule, \ ConceptualMappingRuleCreateIn, ConceptualMappingRuleUpdateIn, ConceptualMappingRuleOut, \ ConceptualMappingRuleTermsValidity -from mapping_workbench.backend.core.models.base_entity import BaseEntityFiltersSchema +from mapping_workbench.backend.core.models.base_entity import BaseEntityFiltersSchema, BaseEntity from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException from mapping_workbench.backend.core.services.request import request_update_data, request_create_data, \ api_entity_is_found, pagination_params, prepare_search_param +from mapping_workbench.backend.fields_registry.models.field_registry import StructuralElement from mapping_workbench.backend.ontology.services.terms import check_content_terms_validity from mapping_workbench.backend.user.models.user import User @@ -40,8 +41,9 @@ async def list_conceptual_mapping_rules(filters: dict = None, page: int = None, for item in items: if item.source_structural_element: item.source_structural_element = await item.source_structural_element.fetch() - item.source_structural_element_sdk_element_id = item.source_structural_element.sdk_element_id - item.source_structural_element_absolute_xpath = item.source_structural_element.absolute_xpath + if isinstance(item.source_structural_element, StructuralElement): + item.source_structural_element_sdk_element_id = item.source_structural_element.sdk_element_id + item.source_structural_element_absolute_xpath = item.source_structural_element.absolute_xpath total_count: int = await ConceptualMappingRule.find(query_filters).count() return items, total_count @@ -51,6 +53,10 @@ async def create_conceptual_mapping_rule(data: ConceptualMappingRuleCreateIn, user: User) -> ConceptualMappingRuleOut: create_data = await rule_validated_data(request_create_data(data, user=user)) create_data[ConceptualMappingRule.source_structural_element] = data.source_structural_element.to_ref().id + if ConceptualMappingRule.refers_to_mapping_package_ids in create_data: + create_data[ConceptualMappingRule.refers_to_mapping_package_ids] = [ + PydanticObjectId(package_id) for package_id in create_data[ConceptualMappingRule.refers_to_mapping_package_ids] + ] conceptual_mapping_rule: ConceptualMappingRule = \ ConceptualMappingRule( **create_data diff --git a/mapping_workbench/backend/resource_collection/models/entity.py b/mapping_workbench/backend/resource_collection/models/entity.py index a9562d271..c6e0a099e 100644 --- a/mapping_workbench/backend/resource_collection/models/entity.py +++ b/mapping_workbench/backend/resource_collection/models/entity.py @@ -5,6 +5,8 @@ from beanie import Link from pymongo import IndexModel +from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \ + BaseMappingPackagesResourceSchemaTrait from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection, \ FileResourceIn @@ -31,7 +33,7 @@ class ResourceCollectionState(ObjectState): file_resources: Optional[List[ResourceFileState]] = [] -class ResourceCollection(FileResourceCollection, StatefulObjectABC): +class ResourceCollection(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC): file_resources: Optional[List[Link["ResourceFile"]]] = [] async def get_resource_files_states(self) -> List[ResourceFileState]: diff --git a/mapping_workbench/backend/resource_collection/services/api.py b/mapping_workbench/backend/resource_collection/services/api.py index fd4d96afa..70f3e0096 100644 --- a/mapping_workbench/backend/resource_collection/services/api.py +++ b/mapping_workbench/backend/resource_collection/services/api.py @@ -6,6 +6,7 @@ from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \ request_create_data, prepare_search_param, pagination_params +from mapping_workbench.backend.mapping_package.models.entity import MappingPackage from mapping_workbench.backend.resource_collection.models.entity import ResourceCollection, ResourceFile, \ ResourceFileUpdateIn, ResourceFileCreateIn from mapping_workbench.backend.user.models.user import User @@ -32,7 +33,19 @@ async def list_resource_collections(filters: dict = None, page: int = None, limi async def create_resource_collection(resource_collection: ResourceCollection, user: User) -> ResourceCollection: resource_collection.on_create(user=user) - return await resource_collection.create() + pkg_ids = resource_collection.refers_to_mapping_package_ids or [] + resource_collection.refers_to_mapping_package_ids = None + suite = await resource_collection.create() + + for pkg_id in pkg_ids: + mapping_package = await MappingPackage.get(pkg_id) + if mapping_package: + if not mapping_package.resource_collections: + mapping_package.resource_collections = [] + mapping_package.resource_collections.append(ResourceCollection.link_from_id(suite.id)) + await mapping_package.save() + + return suite async def update_resource_collection( diff --git a/mapping_workbench/backend/shacl_test_suite/models/entity.py b/mapping_workbench/backend/shacl_test_suite/models/entity.py index 3dd5b2afc..6be329d70 100644 --- a/mapping_workbench/backend/shacl_test_suite/models/entity.py +++ b/mapping_workbench/backend/shacl_test_suite/models/entity.py @@ -5,6 +5,8 @@ from beanie import Link, PydanticObjectId from pymongo import IndexModel +from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \ + BaseMappingPackagesResourceSchemaTrait from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection from mapping_workbench.backend.state_manager.models.state_object import ObjectState, StatefulObjectABC @@ -34,7 +36,7 @@ class SHACLTestSuiteState(ObjectState): shacl_test_states: Optional[List[SHACLTestState]] = [] -class SHACLTestSuite(FileResourceCollection, StatefulObjectABC): +class SHACLTestSuite(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC): file_resources: Optional[List[Link["SHACLTestFileResource"]]] = [] async def get_shacl_test_states(self) -> List[SHACLTestState]: diff --git a/mapping_workbench/backend/shacl_test_suite/services/api.py b/mapping_workbench/backend/shacl_test_suite/services/api.py index b237b91e9..921b54983 100644 --- a/mapping_workbench/backend/shacl_test_suite/services/api.py +++ b/mapping_workbench/backend/shacl_test_suite/services/api.py @@ -6,6 +6,7 @@ from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \ request_create_data, prepare_search_param, pagination_params +from mapping_workbench.backend.mapping_package.models.entity import MappingPackage from mapping_workbench.backend.shacl_test_suite.models.entity import SHACLTestSuite, SHACLTestFileResource from mapping_workbench.backend.shacl_test_suite.models.entity_api_response import SHACLTestFileResourceCreateIn, \ SHACLTestFileResourceUpdateIn @@ -32,7 +33,19 @@ async def list_shacl_test_suites(filters: dict = None, page: int = None, limit: async def create_shacl_test_suite(shacl_test_suite: SHACLTestSuite, user: User) -> SHACLTestSuite: shacl_test_suite.on_create(user=user) - return await shacl_test_suite.create() + pkg_ids = shacl_test_suite.refers_to_mapping_package_ids or [] + shacl_test_suite.refers_to_mapping_package_ids = None + suite = await shacl_test_suite.create() + + for pkg_id in pkg_ids: + mapping_package = await MappingPackage.get(pkg_id) + if mapping_package: + if not mapping_package.shacl_test_suites: + mapping_package.shacl_test_suites = [] + mapping_package.shacl_test_suites.append(SHACLTestSuite.link_from_id(suite.id)) + await mapping_package.save() + + return suite async def update_shacl_test_suite( diff --git a/mapping_workbench/backend/sparql_test_suite/models/entity.py b/mapping_workbench/backend/sparql_test_suite/models/entity.py index 2df94aab8..2448953d5 100644 --- a/mapping_workbench/backend/sparql_test_suite/models/entity.py +++ b/mapping_workbench/backend/sparql_test_suite/models/entity.py @@ -6,6 +6,8 @@ from pydantic import ConfigDict from pymongo import IndexModel +from mapping_workbench.backend.core.models.base_mapping_package_resource_entity import \ + BaseMappingPackagesResourceSchemaTrait from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity from mapping_workbench.backend.file_resource.models.file_resource import FileResource, FileResourceCollection, \ FileResourceIn @@ -52,7 +54,7 @@ class SPARQLTestSuiteState(ObjectState): sparql_test_states: Optional[List[SPARQLTestState]] = [] -class SPARQLTestSuite(FileResourceCollection, StatefulObjectABC): +class SPARQLTestSuite(FileResourceCollection, BaseMappingPackagesResourceSchemaTrait, StatefulObjectABC): type: Optional[SPARQLQueryValidationType] = None file_resources: Optional[List[Link["SPARQLTestFileResource"]]] = [] diff --git a/mapping_workbench/backend/sparql_test_suite/services/api.py b/mapping_workbench/backend/sparql_test_suite/services/api.py index d8ca32d39..f177f7160 100644 --- a/mapping_workbench/backend/sparql_test_suite/services/api.py +++ b/mapping_workbench/backend/sparql_test_suite/services/api.py @@ -6,6 +6,7 @@ from mapping_workbench.backend.core.services.exceptions import ResourceNotFoundException from mapping_workbench.backend.core.services.request import request_update_data, api_entity_is_found, \ request_create_data, prepare_search_param, pagination_params +from mapping_workbench.backend.mapping_package.models.entity import MappingPackage from mapping_workbench.backend.project.models.entity import Project from mapping_workbench.backend.sparql_test_suite.models.entity import SPARQLTestSuite, SPARQLTestFileResource, \ SPARQLTestFileResourceUpdateIn, SPARQLTestFileResourceCreateIn @@ -32,7 +33,19 @@ async def list_sparql_test_suites(filters: dict = None, page: int = None, limit: async def create_sparql_test_suite(sparql_test_suite: SPARQLTestSuite, user: User) -> SPARQLTestSuite: sparql_test_suite.on_create(user=user) - return await sparql_test_suite.create() + pkg_ids = sparql_test_suite.refers_to_mapping_package_ids or [] + sparql_test_suite.refers_to_mapping_package_ids = None + suite = await sparql_test_suite.create() + + for pkg_id in pkg_ids: + mapping_package = await MappingPackage.get(pkg_id) + if mapping_package: + if not mapping_package.sparql_test_suites: + mapping_package.sparql_test_suites = [] + mapping_package.sparql_test_suites.append(SPARQLTestSuite.link_from_id(suite.id)) + await mapping_package.save() + + return suite async def update_sparql_test_suite( diff --git a/mapping_workbench/frontend/src/api/resource-collections/index.js b/mapping_workbench/frontend/src/api/resource-collections/index.js index 9f36bb41a..8e97c1bf0 100644 --- a/mapping_workbench/frontend/src/api/resource-collections/index.js +++ b/mapping_workbench/frontend/src/api/resource-collections/index.js @@ -16,6 +16,7 @@ class ResourceCollectionsApi extends FileCollectionsApi { constructor() { super("value_mapping_resources"); this.isProjectResource = true; + this.refersToMappingPackages = true; } async getValuesForSelector(request = {}) { diff --git a/mapping_workbench/frontend/src/api/shacl-test-suites/index.js b/mapping_workbench/frontend/src/api/shacl-test-suites/index.js index 9db72124c..e5493fad7 100644 --- a/mapping_workbench/frontend/src/api/shacl-test-suites/index.js +++ b/mapping_workbench/frontend/src/api/shacl-test-suites/index.js @@ -16,6 +16,7 @@ class SHACLTestSuitesApi extends FileCollectionsApi { constructor() { super("shacl_test_suites"); this.isProjectResource = true; + this.refersToMappingPackages = true; } async getValuesForSelector(request = {}) { diff --git a/mapping_workbench/frontend/src/api/sparql-test-suites/index.js b/mapping_workbench/frontend/src/api/sparql-test-suites/index.js index e488735b9..b64c5446c 100644 --- a/mapping_workbench/frontend/src/api/sparql-test-suites/index.js +++ b/mapping_workbench/frontend/src/api/sparql-test-suites/index.js @@ -29,6 +29,7 @@ class SPARQLTestSuitesApi extends FileCollectionsApi { super("sparql_test_suites"); this.isProjectResource = true; this.hasFileCollectionType = true; + this.refersToMappingPackages = true; } async getValuesForSelector(request = {}) { diff --git a/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/develop/index.js b/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/develop/index.js index c8f452669..3a08ef3fa 100644 --- a/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/develop/index.js +++ b/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/develop/index.js @@ -90,7 +90,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q})) + setState(prevState => ({...prevState, search: filters.q, page: 0})) } const handleFiltersChange = (filters) => { diff --git a/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/groups/index.js b/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/groups/index.js index b952522d9..611dfa317 100644 --- a/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/groups/index.js +++ b/mapping_workbench/frontend/src/pages/app/conceptual-mapping-rules/groups/index.js @@ -79,7 +79,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q})) + setState(prevState => ({...prevState, search: filters.q, page: 0})) } const handleFiltersChange = (filters) => { diff --git a/mapping_workbench/frontend/src/pages/app/detailed-view-cm/index.js b/mapping_workbench/frontend/src/pages/app/detailed-view-cm/index.js index 671b64a99..acfc3f681 100644 --- a/mapping_workbench/frontend/src/pages/app/detailed-view-cm/index.js +++ b/mapping_workbench/frontend/src/pages/app/detailed-view-cm/index.js @@ -79,7 +79,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q })) + setState(prevState => ({...prevState, search: filters.q, page: 0 })) } const handleFiltersChange = (filters) => { diff --git a/mapping_workbench/frontend/src/pages/app/fields-overview/index.js b/mapping_workbench/frontend/src/pages/app/fields-overview/index.js index 752d45b6e..02bb05f1b 100644 --- a/mapping_workbench/frontend/src/pages/app/fields-overview/index.js +++ b/mapping_workbench/frontend/src/pages/app/fields-overview/index.js @@ -75,7 +75,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q})) + setState(prevState => ({...prevState, search: filters.q, page: 0})) } const handleFiltersChange = filters => { diff --git a/mapping_workbench/frontend/src/pages/app/ontology-files/index.js b/mapping_workbench/frontend/src/pages/app/ontology-files/index.js index 9faa5b1f6..7e5a3ed25 100644 --- a/mapping_workbench/frontend/src/pages/app/ontology-files/index.js +++ b/mapping_workbench/frontend/src/pages/app/ontology-files/index.js @@ -87,7 +87,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters})) + setState(prevState => ({...prevState, search: filters, page: 0 })) } diff --git a/mapping_workbench/frontend/src/pages/app/projects/index.js b/mapping_workbench/frontend/src/pages/app/projects/index.js index afaae9e5d..e242d0040 100644 --- a/mapping_workbench/frontend/src/pages/app/projects/index.js +++ b/mapping_workbench/frontend/src/pages/app/projects/index.js @@ -81,7 +81,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q })) + setState(prevState => ({...prevState, search: filters.q, page: 0 })) } const handleFiltersChange = (filters) => { diff --git a/mapping_workbench/frontend/src/pages/app/schema-files/index.js b/mapping_workbench/frontend/src/pages/app/schema-files/index.js index 913004df2..d1b6ad834 100644 --- a/mapping_workbench/frontend/src/pages/app/schema-files/index.js +++ b/mapping_workbench/frontend/src/pages/app/schema-files/index.js @@ -86,7 +86,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters })) + setState(prevState => ({...prevState, search: filters, page: 0 })) } diff --git a/mapping_workbench/frontend/src/pages/app/tasks/index.js b/mapping_workbench/frontend/src/pages/app/tasks/index.js index 483aa468a..7e31be002 100644 --- a/mapping_workbench/frontend/src/pages/app/tasks/index.js +++ b/mapping_workbench/frontend/src/pages/app/tasks/index.js @@ -84,7 +84,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q })) + setState(prevState => ({...prevState, search: filters.q, page: 0 })) } diff --git a/mapping_workbench/frontend/src/pages/app/triple-map-fragments/index.js b/mapping_workbench/frontend/src/pages/app/triple-map-fragments/index.js index 98e8f6ad8..193859744 100644 --- a/mapping_workbench/frontend/src/pages/app/triple-map-fragments/index.js +++ b/mapping_workbench/frontend/src/pages/app/triple-map-fragments/index.js @@ -82,7 +82,7 @@ const useItemsSearch = (items) => { }) const handleSearchItems = (filters) => { - setState(prevState => ({...prevState, search: filters.q})) + setState(prevState => ({...prevState, search: filters.q, page: 0})) } const handleFiltersChange = filters => { diff --git a/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/develop/add-edit-drawer.js b/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/develop/add-edit-drawer.js index 71063598f..ec2dc28a2 100644 --- a/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/develop/add-edit-drawer.js +++ b/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/develop/add-edit-drawer.js @@ -1,4 +1,4 @@ -import {useEffect} from "react"; +import {useEffect, useState} from "react"; import Card from "@mui/material/Card"; import Stack from "@mui/material/Stack"; @@ -18,10 +18,19 @@ import AutocompleteCM from "./ontology_fragment_editor"; import {sessionApi} from "src/api/session"; import {FormTextField} from "src/components/app/form/text-field"; import {toastError, toastLoad, toastSuccess} from "src/components/app-toast"; +import Grid from "@mui/material/Unstable_Grid2"; +import {MappingPackageCheckboxList} from "../../mapping-package/components/mapping-package-checkbox-list"; +import Typography from "@mui/material/Typography"; +import Divider from "@mui/material/Divider"; const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, afterItemSave, ontologyFragments}) => { + const [mappingPackages, setMappingPackages] = useState([]); + + useEffect(() => { + setMappingPackages(item?.refers_to_mapping_package_ids || []) + }, [item]) const addItem = (requestValues, resetForm) => { const toastId = toastLoad('Adding item...') @@ -58,7 +67,7 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft 'target_class_path': item?.target_class_path || '', 'target_property_path': item?.target_property_path || '', 'autocomplete_cm': [], - 'autocomplete_cm_checked': true, + 'autocomplete_cm_checked': !item, }, validationSchema: Yup.object({ source_structural_element: Yup @@ -75,6 +84,7 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft const {autocomplete_cm, autocomplete_cm_checked, ...values} = initialValues values['project'] = sessionApi.getSessionProject(); values['source_structural_element'] = values['source_structural_element'] || null; + values['refers_to_mapping_package_ids'] = mappingPackages || null; if (item) { updateItem(values, resetForm) @@ -120,7 +130,6 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft return; } - return ( formik.setFieldValue('autocomplete_cm_checked', event.target.checked)} + onChange={(event) => formik.setFieldValue('autocomplete_cm_checked', event.target.checked)} /> } label="Use Ontology Fragment Editor" @@ -164,7 +173,6 @@ const AddEditDrawer = ({open, onClose, item, sectionApi, structuralElements, aft disabled={!formik.values.autocomplete_cm_checked} data={ontologyFragments} onSelect={handleAutocompleteChange} - required={formik.values.autocomplete_cm_checked} name='autocomplete_cm'/> + + + Mapping Packages + + + + + + + + diff --git a/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/edit-form.js b/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/edit-form.js index bf7e350e1..23be7db76 100644 --- a/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/edit-form.js +++ b/mapping_workbench/frontend/src/sections/app/conceptual-mapping-rule/edit-form.js @@ -504,7 +504,10 @@ export const EditForm = (props) => { spacing={3}> - + diff --git a/mapping_workbench/frontend/src/sections/app/file-manager/file-collection-edit-form.js b/mapping_workbench/frontend/src/sections/app/file-manager/file-collection-edit-form.js index af86de658..b35253fcc 100644 --- a/mapping_workbench/frontend/src/sections/app/file-manager/file-collection-edit-form.js +++ b/mapping_workbench/frontend/src/sections/app/file-manager/file-collection-edit-form.js @@ -20,6 +20,11 @@ import {FormTextField} from "../../../components/app/form/text-field"; import {FormTextArea} from "../../../components/app/form/text-area"; import {MappingPackageFormSelect} from "../mapping-package/components/mapping-package-form-select"; import {toastError, toastSuccess} from "../../../components/app-toast"; +import {ListSelectorSelect as ResourceListSelector} from "../../../components/app/list-selector/select"; +import {sparqlTestFileResourcesApi} from "../../../api/sparql-test-suites/file-resources"; +import {MappingPackageCheckboxList} from "../mapping-package/components/mapping-package-checkbox-list"; +import Divider from "@mui/material/Divider"; +import Typography from "@mui/material/Typography"; export const FileCollectionEditForm = (props) => { @@ -48,6 +53,10 @@ export const FileCollectionEditForm = (props) => { initialValues['mapping_package_id'] = item.mapping_package_id ?? ''; } + if (sectionApi.refersToMappingPackages && itemctx.isNew) { + initialValues['refers_to_mapping_package_ids'] = item.refers_to_mapping_package_ids ?? []; + } + switch (sectionApi.section) { case 'test_data_suites': customPathName = paths.app.test_data_suites.index; @@ -83,6 +92,9 @@ export const FileCollectionEditForm = (props) => { if (sectionApi.hasMappingPackage) { values['mapping_package_id'] = values['mapping_package_id'] || null; } + if (sectionApi.refersToMappingPackages && itemctx.isNew) { + values['refers_to_mapping_package_ids'] = values['refers_to_mapping_package_ids'] || null; + } if (itemctx.isNew) { response = await sectionApi.createItem(values); } else { @@ -171,6 +183,24 @@ export const FileCollectionEditForm = (props) => { + {sectionApi.refersToMappingPackages && itemctx.isNew && ( + + + + Mapping Packages + + + + + + + + )} diff --git a/mapping_workbench/frontend/src/sections/app/mapping-package/components/mapping-package-checkbox-list/index.js b/mapping_workbench/frontend/src/sections/app/mapping-package/components/mapping-package-checkbox-list/index.js index 850e5846c..f107f7f7c 100644 --- a/mapping_workbench/frontend/src/sections/app/mapping-package/components/mapping-package-checkbox-list/index.js +++ b/mapping_workbench/frontend/src/sections/app/mapping-package/components/mapping-package-checkbox-list/index.js @@ -13,7 +13,6 @@ const useMappingPackagesStore = (initProjectMappingPackages = []) => { const [state, setState] = useState({ items: initProjectMappingPackages || [] }); - const handleMappingPackagesGet = useCallback(async () => { try { let mappingPackages = initProjectMappingPackages; @@ -40,7 +39,12 @@ const useMappingPackagesStore = (initProjectMappingPackages = []) => { }; export const MappingPackageCheckboxList = (props) => { - const {mappingPackages = [], initProjectMappingPackages = null, ...other} = props; + const { + mappingPackages = [], + initProjectMappingPackages = null, + withDefaultPackage = false, + ...other + } = props; const [allChecked, setAllChecked] = useState(false); const [projectMappingPackages, setProjectMappingPackages] = useState([]); @@ -50,6 +54,15 @@ export const MappingPackageCheckboxList = (props) => { setProjectMappingPackages(mappingPackagesStore.items); }, [mappingPackagesStore]); + useEffect(() => { + if (withDefaultPackage) { + const defaultPackage = mappingPackagesStore.items.find(pkg => pkg.identifier === 'default'); + if (defaultPackage) { + mappingPackages.push(defaultPackage.id) + } + } + }, [mappingPackagesStore.items, withDefaultPackage]) + const handleAllMappingPackagesChange = useCallback((event) => { let _checked = event.target.checked; mappingPackages.length = 0;