Skip to content

Commit

Permalink
Mazání vztahů nefunguje. #534
Browse files Browse the repository at this point in the history
  • Loading branch information
bindeali committed Sep 13, 2024
1 parent aede1e8 commit d8a4bbc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
13 changes: 7 additions & 6 deletions src/components/modals/NewLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Locale } from "../../config/Locale";
import {
AppSettings,
Links,
WorkspaceElements,
WorkspaceLinks,
WorkspaceTerms,
} from "../../config/Variables";
Expand Down Expand Up @@ -87,16 +88,16 @@ export default class NewLinkModal extends React.Component<Props, State> {
.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) =>
Expand All @@ -113,7 +114,7 @@ export default class NewLinkModal extends React.Component<Props, State> {
}

render() {
let options = this.getLinks().sort();
const options = this.getLinks();
return (
<Modal
centered
Expand Down
18 changes: 18 additions & 0 deletions src/function/FunctionElem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,21 @@ export function removeReadOnlyElement(elem: string): string[] {
),
];
}

export function removeElement(elem: string): string[] {
removeFromFlexSearch(elem);
const writeGraphs = Object.keys(WorkspaceVocabularies)
.filter((vocab) => !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)
]
}
13 changes: 5 additions & 8 deletions src/function/FunctionLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
getVocabularyFromScheme,
} from "./FunctionGetVars";
import { mvp1IRI, mvp2IRI, setLabels, setLinkBoundary } from "./FunctionGraph";
import { removeElement } from "./FunctionElem";

export function getOtherConnectionElementID(
linkID: string,
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 3 additions & 23 deletions src/panels/modal/ModalRemoveTerm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -39,21 +33,7 @@ export default class ModalRemoveTerm extends React.Component<Props, State> {
}

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() {
Expand Down

0 comments on commit d8a4bbc

Please sign in to comment.