From 8cb8eb1b4f9179d86dfcd7e57263eb15ed92d240 Mon Sep 17 00:00:00 2001 From: Adam Mertel <12932677+adammertel@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:41:37 +0100 Subject: [PATCH] 2370 when new reference is added jump as active to reference part not new reference (#2470) * Fix entity labels reference * Add focus style to suggester * Make reference value autofocus when resource is filled * Make the prop value active after type is selected * Remove status from test dataset --- .../components/basic/Suggester/Suggester.tsx | 3 +- .../basic/Suggester/SuggesterStyles.tsx | 9 + .../EntityReferenceTableResource.tsx | 1 + .../EntityReferenceTableRow.tsx | 4 +- .../PropGroupRow/PropGroupRowValue.tsx | 1 + packages/database/datasets/test/entities.json | 394 ++++++++---------- 6 files changed, 199 insertions(+), 213 deletions(-) diff --git a/packages/client/src/components/basic/Suggester/Suggester.tsx b/packages/client/src/components/basic/Suggester/Suggester.tsx index 680906c8d..1b107044d 100644 --- a/packages/client/src/components/basic/Suggester/Suggester.tsx +++ b/packages/client/src/components/basic/Suggester/Suggester.tsx @@ -282,6 +282,7 @@ export const Suggester: React.FC = ({ = ({ setSelected(-1); }} onEnterPressFn={handleEnterPress} - autoFocus={categories.length === 1 && autoFocus} + autoFocus={categories.length === 1 || autoFocus} disabled={disabled} /> {typed.length > 0 && ( diff --git a/packages/client/src/components/basic/Suggester/SuggesterStyles.tsx b/packages/client/src/components/basic/Suggester/SuggesterStyles.tsx index 1df4ffcf9..20c4ec653 100644 --- a/packages/client/src/components/basic/Suggester/SuggesterStyles.tsx +++ b/packages/client/src/components/basic/Suggester/SuggesterStyles.tsx @@ -5,12 +5,21 @@ import { space2, space4 } from "Theme/constants"; interface StyledSuggester { $marginTop?: boolean; $fullWidth?: boolean; + $isFocused?: boolean; } export const StyledSuggester = styled.div` position: relative; display: ${({ $fullWidth }) => ($fullWidth ? "flex" : "inline-flex")}; margin-top: ${({ $marginTop }) => ($marginTop ? space2 : 0)}; + + input[type="text"] { + border-width: ${({ $isFocused }) => ($isFocused ? "2px" : "1px")}; + } + .react-select__control { + border-width: ${({ $isFocused }) => + $isFocused ? "2px !important" : "1px"}; + } `; interface Column {} diff --git a/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableResource.tsx b/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableResource.tsx index a196bfe7a..f339ecea5 100644 --- a/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableResource.tsx +++ b/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableResource.tsx @@ -83,6 +83,7 @@ export const EntityReferenceTableResource: React.FC< territoryParentId={territoryParentId} disabled={disabled} initTyped={initResourceTyped} + autoFocus={reference.resource !== ""} /> )} diff --git a/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableRow.tsx b/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableRow.tsx index cdeace773..29f16a81e 100644 --- a/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableRow.tsx +++ b/packages/client/src/pages/Main/containers/EntityReferenceTable/EntityReferenceTableRow.tsx @@ -170,10 +170,10 @@ export const EntityReferenceTableRow: React.FC = ({ "http" ) ? normalizeURL(resourceEntity.data.partValueBaseURL) + - valueEntity.label + valueEntity.labels[0] : "//" + normalizeURL(resourceEntity.data.partValueBaseURL) + - valueEntity.label; + valueEntity.labels[0]; window.open(url, "_blank"); }} /> diff --git a/packages/client/src/pages/Main/containers/PropGroup/PropGroupRow/PropGroupRowValue.tsx b/packages/client/src/pages/Main/containers/PropGroup/PropGroupRow/PropGroupRowValue.tsx index ac53171ac..37d6ea6c7 100644 --- a/packages/client/src/pages/Main/containers/PropGroup/PropGroupRow/PropGroupRowValue.tsx +++ b/packages/client/src/pages/Main/containers/PropGroup/PropGroupRow/PropGroupRowValue.tsx @@ -145,6 +145,7 @@ export const PropGroupRowValue: React.FC = ({ true ); }} + autoFocus={prop.type.entityId !== ""} placeholder="value" openDetailOnCreate={openDetailOnCreate} categoryTypes={classesPropValue} diff --git a/packages/database/datasets/test/entities.json b/packages/database/datasets/test/entities.json index 7d265e83c..e05b1047a 100644 --- a/packages/database/datasets/test/entities.json +++ b/packages/database/datasets/test/entities.json @@ -1,220 +1,194 @@ [ - { - "id": "0.07956077734737166", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 1" - ] + { + "id": "0.07956077734737166", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "0.14773065892513793", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 2" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 1"] + }, + { + "id": "0.14773065892513793", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "0.9198268479493097", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 3" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 2"] + }, + { + "id": "0.9198268479493097", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "0.36838502478796054", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 4" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 3"] + }, + { + "id": "0.36838502478796054", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "0.43562994650453146", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 5" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 4"] + }, + { + "id": "0.43562994650453146", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "0.9785122627887828", - "class": "A", - "status": "1", - "data": { - "status": "0", - "pos": "verb", - "valencies": { - "a1": "", - "a2": "", - "s": "" - }, - "entities": {} - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Action 6" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 5"] + }, + { + "id": "0.9785122627887828", + "class": "A", + "status": "1", + "data": { + "pos": "verb", + "valencies": { + "a1": "", + "a2": "", + "s": "" + }, + "entities": {} }, - { - "id": "T0", - "class": "T", - "status": "1", - "data": { - "parent": false - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Territory root" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Action 6"] + }, + { + "id": "T0", + "class": "T", + "status": "1", + "data": { + "parent": false }, - { - "id": "0.6803061625862785", - "class": "S", - "status": "1", - "data": { - "text": "", - "actions": [], - "actants": [], - "tags": [], - "territory": { - "territoryId": "T0", - "order": -1 - } - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Statement 1" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Territory root"] + }, + { + "id": "0.6803061625862785", + "class": "S", + "status": "1", + "data": { + "text": "", + "actions": [], + "actants": [], + "tags": [], + "territory": { + "territoryId": "T0", + "order": -1 + } }, - { - "id": "0.2806822650387928", - "class": "S", - "status": "1", - "data": { - "text": "", - "actions": [], - "actants": [], - "tags": [], - "territory": { - "territoryId": "T0", - "order": -1 - } - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Statement 2" - ] + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Statement 1"] + }, + { + "id": "0.2806822650387928", + "class": "S", + "status": "1", + "data": { + "text": "", + "actions": [], + "actants": [], + "tags": [], + "territory": { + "territoryId": "T0", + "order": -1 + } }, - { - "id": "0.8586537029736159", - "class": "R", - "status": "1", - "data": { - "url": "", - "partValueLabel": "", - "partValueBaseURL": "" - }, - "detail": "", - "language": "", - "notes": [], - "props": [], - "references": [], - "labels": [ - "Resource 1" - ] - } -] \ No newline at end of file + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Statement 2"] + }, + { + "id": "0.8586537029736159", + "class": "R", + "status": "1", + "data": { + "url": "", + "partValueLabel": "", + "partValueBaseURL": "" + }, + "detail": "", + "language": "", + "notes": [], + "props": [], + "references": [], + "labels": ["Resource 1"] + } +]