From d8a4bbc281f623e7ded94e0b779aa67b52f736d6 Mon Sep 17 00:00:00 2001 From: bindeali <56399637+bindeali@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:45:24 +0200 Subject: [PATCH] =?UTF-8?q?Maz=C3=A1n=C3=AD=20vztah=C5=AF=20nefunguje.=20#?= =?UTF-8?q?534?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/modals/NewLinkModal.tsx | 13 +++++++------ src/function/FunctionElem.ts | 18 ++++++++++++++++++ src/function/FunctionLink.ts | 13 +++++-------- src/panels/modal/ModalRemoveTerm.tsx | 26 +++----------------------- 4 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/components/modals/NewLinkModal.tsx b/src/components/modals/NewLinkModal.tsx index f7a79dc2..4f8219c0 100644 --- a/src/components/modals/NewLinkModal.tsx +++ b/src/components/modals/NewLinkModal.tsx @@ -6,6 +6,7 @@ import { Locale } from "../../config/Locale"; import { AppSettings, Links, + WorkspaceElements, WorkspaceLinks, WorkspaceTerms, } from "../../config/Variables"; @@ -87,16 +88,16 @@ export default class NewLinkModal extends React.Component { .sort(); } else if (AppSettings.representation === Representation.COMPACT) { return Object.keys(WorkspaceTerms) - .filter((iri) => { - return ( + .filter( + (iri) => !isTermReadOnly(iri) && getActiveSourceConnections(iri).length === 0 && filterEquivalent( WorkspaceTerms[iri].types, parsePrefix("z-sgov-pojem", "typ-vztahu") - ) - ); - }) + ) && + WorkspaceElements[iri].active + ) .concat( Object.keys(Links).filter( (link) => @@ -113,7 +114,7 @@ export default class NewLinkModal extends React.Component { } render() { - let options = this.getLinks().sort(); + const options = this.getLinks(); return ( !WorkspaceVocabularies[vocab].readOnly) + .map((vocab) => WorkspaceVocabularies[vocab].graph); + return [ + ...deleteConcept(elem), + updateDeleteTriples( + elem, + Object.values(Diagrams).map((diag) => diag.graph), + true, + false, + false + ), + updateDeleteTriples(elem, writeGraphs, true, true, true) + ] +} diff --git a/src/function/FunctionLink.ts b/src/function/FunctionLink.ts index 974c6553..7fb2c4f2 100644 --- a/src/function/FunctionLink.ts +++ b/src/function/FunctionLink.ts @@ -29,6 +29,7 @@ import { getVocabularyFromScheme, } from "./FunctionGetVars"; import { mvp1IRI, mvp2IRI, setLabels, setLinkBoundary } from "./FunctionGraph"; +import { removeElement } from "./FunctionElem"; export function getOtherConnectionElementID( linkID: string, @@ -332,14 +333,10 @@ function deleteConnections(id: string): string[] { export function deleteLink(id: string): string[] { const queries: string[] = []; - const compactConn = Object.keys(WorkspaceLinks).find( - (link) => - WorkspaceLinks[link].active && - WorkspaceLinks[link].iri === WorkspaceLinks[id].source && - WorkspaceLinks[link].target === WorkspaceLinks[id].target - ); - if (compactConn) { - queries.push(...deleteConnections(compactConn)); + if (!(WorkspaceLinks[id].iri in Links) && + WorkspaceLinks[id].type === LinkType.DEFAULT && + WorkspaceLinks[id].active) { + queries.push(...removeElement(WorkspaceLinks[id].iri)); } const deleteLinks = getUnderlyingFullConnections(id as string); if (deleteLinks) { diff --git a/src/panels/modal/ModalRemoveTerm.tsx b/src/panels/modal/ModalRemoveTerm.tsx index 48efce7f..26c4610b 100644 --- a/src/panels/modal/ModalRemoveTerm.tsx +++ b/src/panels/modal/ModalRemoveTerm.tsx @@ -3,15 +3,9 @@ import { Button, Form, Modal, Spinner } from "react-bootstrap"; import TableList from "../../components/TableList"; import { Representation } from "../../config/Enum"; import { Locale } from "../../config/Locale"; -import { - AppSettings, - Diagrams, - WorkspaceVocabularies, -} from "../../config/Variables"; +import { AppSettings } from "../../config/Variables"; import { getCacheConnections } from "../../function/FunctionCache"; -import { removeFromFlexSearch } from "../../function/FunctionCreateVars"; -import { deleteConcept } from "../../function/FunctionEditVars"; -import { updateDeleteTriples } from "../../queries/update/UpdateMiscQueries"; +import { removeElement } from "../../function/FunctionElem"; import { CacheConnection } from "../../types/CacheConnection"; import ConnectionCache from "../detail/components/connections/ConnectionCache"; @@ -39,21 +33,7 @@ export default class ModalRemoveTerm extends React.Component { } save() { - removeFromFlexSearch(this.props.id); - const writeGraphs = Object.keys(WorkspaceVocabularies) - .filter((vocab) => !WorkspaceVocabularies[vocab].readOnly) - .map((vocab) => WorkspaceVocabularies[vocab].graph); - this.props.performTransaction( - ...deleteConcept(this.props.id), - updateDeleteTriples( - this.props.id, - Object.values(Diagrams).map((diag) => diag.graph), - true, - false, - false - ), - updateDeleteTriples(this.props.id, writeGraphs, true, true, true) - ); + this.props.performTransaction(...removeElement(this.props.id)); } getConnections() {