From a650427b64dc58f990a8644b44b6317cb0f2d4a3 Mon Sep 17 00:00:00 2001 From: Sharad S <16229739+sharadsw@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:46:27 -0400 Subject: [PATCH 1/6] Revert "Hide CollectionObjectType on the frontend" --- .../js_src/lib/components/SchemaConfig/Fields.tsx | 10 +--------- .../components/SchemaConfig/TableUniquenessRules.tsx | 4 +--- .../js_src/lib/components/Toolbar/QueryTablesEdit.tsx | 6 +----- .../lib/components/WbPlanView/LineComponents.tsx | 3 +-- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Fields.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Fields.tsx index bbe118b1884..af860fcb76f 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Fields.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Fields.tsx @@ -66,15 +66,7 @@ export function SchemaConfigFields({ {relationships.length > 0 && ( - name !== 'collectionObjectType' - ) - : relationships - } - /> + )} diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/TableUniquenessRules.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/TableUniquenessRules.tsx index b2334201c4e..8b6d783d5ee 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/TableUniquenessRules.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/TableUniquenessRules.tsx @@ -71,9 +71,7 @@ export function TableUniquenessRules(): JSX.Element { (relationship) => (['many-to-one', 'one-to-one'] as RA).includes( relationship.type - ) && - !relationship.isVirtual && - relationship.name !== 'collectionObjectType' + ) && !relationship.isVirtual ), [table] ); diff --git a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx index 613975104d3..9f9b5dd3070 100644 --- a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx +++ b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx @@ -37,12 +37,8 @@ export function QueryTablesEdit({ /> ); } -/* - * TODO: temp fix, remove this, use to hide geo tables for COG until 9.8 release - * TODO: Revert #5236 to unhide COType - */ +// TODO: temp fix, remove this, use to hide geo tables for COG until 9.8 release export const HIDDEN_GEO_TABLES = new Set([ - 'CollectionObjectType', 'CollectionObjectGroup', 'CollectionObjectGroupJoin', 'CollectionObjectGroupType', diff --git a/specifyweb/frontend/js_src/lib/components/WbPlanView/LineComponents.tsx b/specifyweb/frontend/js_src/lib/components/WbPlanView/LineComponents.tsx index 433a4761b77..d4c7648c1e0 100644 --- a/specifyweb/frontend/js_src/lib/components/WbPlanView/LineComponents.tsx +++ b/specifyweb/frontend/js_src/lib/components/WbPlanView/LineComponents.tsx @@ -227,8 +227,7 @@ export function MappingElement({ fieldsData, ...props }: MappingElementProps): JSX.Element { - const { collectionObjectType, ...rest } = fieldsData; - const fieldGroups = Object.entries(rest).reduce< + const fieldGroups = Object.entries(fieldsData).reduce< R> >((fieldGroups, [fieldName, fieldData]) => { const groupName = getFieldGroupName( From ed78e55bbf06d47b9392bd3ec95e661bd5a91ef6 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Wed, 2 Oct 2024 16:51:00 -0400 Subject: [PATCH 2/6] unhide all geo tables --- .../js_src/lib/components/SchemaConfig/Tables.tsx | 3 --- .../js_src/lib/components/Toolbar/QueryTablesEdit.tsx | 9 +-------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Tables.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Tables.tsx index 276956a0286..1edf5436416 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Tables.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Tables.tsx @@ -21,7 +21,6 @@ import { Dialog } from '../Molecules/Dialog'; import { TableIcon } from '../Molecules/TableIcon'; import { hasTablePermission } from '../Permissions/helpers'; import { formatUrl } from '../Router/queryString'; -import { HIDDEN_GEO_TABLES } from '../Toolbar/QueryTablesEdit'; export function SchemaConfigTables(): JSX.Element { const { language = '' } = useParams(); @@ -127,8 +126,6 @@ export function TableList({ () => Object.values(genericTables) .filter((table) => filter(showHiddenTables, table)) - // TODO: temp fix, remove this, use to hide geo tables for COG until 9.8 release - .filter((table) => !HIDDEN_GEO_TABLES.has(table.name)) .sort(sortFunction(({ name }) => name)), [filter, showHiddenTables] ); diff --git a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx index 9f9b5dd3070..5e07f49b1cc 100644 --- a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx +++ b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesEdit.tsx @@ -37,12 +37,7 @@ export function QueryTablesEdit({ /> ); } -// TODO: temp fix, remove this, use to hide geo tables for COG until 9.8 release -export const HIDDEN_GEO_TABLES = new Set([ - 'CollectionObjectGroup', - 'CollectionObjectGroupJoin', - 'CollectionObjectGroupType', -]); + export function TablesListEdit({ isNoRestrictionMode, defaultTables, @@ -63,8 +58,6 @@ export function TablesListEdit({ .filter((table) => tablesFilter(isNoRestrictionMode, false, true, table, selectedValues) ) - // TODO: temp fix, remove this, use to hide geo tables for COG until 9.8 release - .filter((table) => !HIDDEN_GEO_TABLES.has(table.name)) .map(({ name, label }) => ({ name, label })); const handleChanged = (items: RA): void => From df9b36b634d8f99d21ebb49899ab57c972dcc83f Mon Sep 17 00:00:00 2001 From: Sharad S Date: Thu, 10 Oct 2024 14:38:39 -0400 Subject: [PATCH 3/6] Use relationship name as fallback --- .../js_src/lib/components/SchemaConfig/UniquenessRuleScope.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleScope.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleScope.tsx index dbcc94d0c71..e37f7e78178 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleScope.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleScope.tsx @@ -61,7 +61,7 @@ export function UniquenessRuleScope({ isDefault: false, isEnabled: true, isRelationship: true, - optionLabel: relationship.localization.name!, + optionLabel: relationship.localization.name ?? relationship.name, tableName: relationship.relatedTable.name, }, ]) From 6bf4886bac399f7a18abfb3ea9c72c61c7966335 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Fri, 11 Oct 2024 13:55:20 -0400 Subject: [PATCH 4/6] Use lowercase keys when generating schema localization --- specifyweb/context/schema_localization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specifyweb/context/schema_localization.py b/specifyweb/context/schema_localization.py index 4c1b422ecc2..2509a0ceba5 100644 --- a/specifyweb/context/schema_localization.py +++ b/specifyweb/context/schema_localization.py @@ -117,7 +117,7 @@ def get_schema_localization(collection, schematype, lang): cfields = ('format', 'ishidden', 'isuiformatter', 'picklistname', 'type', 'aggregator', 'defaultui', 'name', 'desc') containers = { - row[0]: dict(items={}, **{field: row[i+1] for i, field in enumerate(cfields)}) + row[0].lower(): dict(items={}, **{field: row[i+1] for i, field in enumerate(cfields)}) for row in cursor.fetchall() } @@ -172,7 +172,7 @@ def get_schema_localization(collection, schematype, lang): ifields = ('format', 'ishidden', 'isuiformatter', 'picklistname', 'type', 'isrequired', 'weblinkname', 'name', 'desc') for row in cursor.fetchall(): - containers[row[0]]['items'][row[1].lower()] = {field: row[i+2] for i, field in enumerate(ifields)} + containers[row[0].lower()]['items'][row[1].lower()] = {field: row[i+2] for i, field in enumerate(ifields)} return containers From 548cc70dbd4f337c992cf772d08670dd315364d5 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Fri, 11 Oct 2024 13:55:35 -0400 Subject: [PATCH 5/6] Make uniqueness field name always be readonly --- .../js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx index 287815056d8..9f5ff08ec32 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx @@ -84,7 +84,7 @@ export function UniquenessRuleRow({ name === field) ?? From 4558db242acb68729fbcc988597c41a7cc359f75 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Fri, 11 Oct 2024 17:59:12 +0000 Subject: [PATCH 6/6] Lint code with ESLint and Prettier Triggered by 548cc70dbd4f337c992cf772d08670dd315364d5 on branch refs/heads/revert-5236-issue-5222 --- .../js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx index 9f5ff08ec32..98f78b552e7 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/UniquenessRuleRow.tsx @@ -84,7 +84,7 @@ export function UniquenessRuleRow({ name === field) ??