Skip to content

Commit

Permalink
Add skos:scopeNote and dct:source editing for terms
Browse files Browse the repository at this point in the history
  • Loading branch information
bindeali committed Sep 12, 2024
1 parent f5b5b9e commit 8a90416
Show file tree
Hide file tree
Showing 17 changed files with 522 additions and 582 deletions.
3 changes: 2 additions & 1 deletion src/config/ToastData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { AppSettings } from "./Variables";
export const ToastData: { [Key in keyof typeof enToast]: ToastType } = {
lookingForRelationshipsOrProperties: { repeatable: false },
diagramsClosedByDefault: { repeatable: false },
newFunctionEditTrope: { repeatable: false }
newFunctionEditTrope: { repeatable: false },
newFunctionDescriptionAndSources: { repeatable: false }
};

export type ToastType = {
Expand Down
4 changes: 3 additions & 1 deletion src/config/Variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Restriction } from "../datatypes/Restriction";
import { Representation } from "./Enum";
import * as joint from "jointjs";
import { Environment } from "./Environment";
import { Languages } from "./Languages";
import { LanguageObject, Languages } from "./Languages";

export type AlternativeLabel = { label: string; language: string };

Expand Down Expand Up @@ -88,6 +88,8 @@ export var WorkspaceTerms: {
subClassOf: string[];
restrictions: Restriction[];
topConcept: string | undefined;
descriptions: LanguageObject;
source: string;
};
} = {};

Expand Down
4 changes: 3 additions & 1 deletion src/function/FunctionCreateVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export function addVocabularyElement(
subClassOf: [],
restrictions: [],
topConcept: scheme,
source: "",
descriptions: initLanguageObject("")
};
}

Expand Down Expand Up @@ -158,7 +160,7 @@ export function addDiagram(
index =
Object.keys(Diagrams).length > 0
? Object.values(Diagrams).reduce((a, b) => (a.index > b.index ? a : b))
.index + 1
.index + 1
: 0;
Diagrams[diagramID] = {
name: name,
Expand Down
1 change: 0 additions & 1 deletion src/function/FunctionElem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ export async function putElementsOnCanvas(
}
const iris: string[] = data.iri;
const ids: string[] = data.id.filter((id: string) => !graph.getCell(id));
debugger;
if (iris.length === 0 && ids.length === 0) {
console.warn(`Expected to receive valid IRI data, got
${dataToParse}
Expand Down
2 changes: 2 additions & 0 deletions src/locale/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const cs: { [Property in keyof typeof en]: string } = {
detailPanelPrefLabel: "Jméno",
detailPanelAltLabel: "Synonyma",
detailPanelInScheme: "Ve slovníku",
detailPanelSource: "Zdroj",
detailPanelDescription: "Popis",
detailPanelDefinition: "Definice",
detailPanelStereotype: "Stereotyp",
setCanvasLanguage: "Zobrazovaný jazyk slovníků",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/cstoast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ export const csToast: {
newFunctionEditTrope: {
header: "Nyní dostupné: úprava vlastností",
content: "V nové verzi OntoGrapheru můžete upravovat vlastnosti (jejich definice a synonyma) pojmů v detailu daného pojmu. Stačí v seznamu vlastností pojmu kliknout na Info ikonku, která se zobrazí při najetí myší na danou vlastnost."
},
newFunctionDescriptionAndSources: {
header: "Nyní dostupné: úprava zdrojů a popisů",
content: "V nové verzi OntoGrapheru nyní lze upravovat zdroje (dct:source) a popisy (skos:scopeNote) v detailu pojmů a vybraných vztahů."
}
};
2 changes: 2 additions & 0 deletions src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const en = {
detailPanelPrefLabel: "Label",
detailPanelAltLabel: "Synonyms",
detailPanelInScheme: "In vocabulary",
detailPanelSource: "Source",
detailPanelDescription: "Description",
detailPanelDefinition: "Definition",
detailPanelStereotype: "Stereotype",
setCanvasLanguage: "Displayed vocabulary language",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/entoast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ export const enToast: {
newFunctionEditTrope: {
header: "Trope editing now available",
content: "In the new version of OntoGrapher, you can edit tropes (their definitions and synonyms) within the detail panel of the parent term. In the list of tropes, click the info icon that shows when you point the mouse at a trope."
},
newFunctionDescriptionAndSources: {
header: "Description and source editing now available",
content: "In the new version of OntoGrapher, you can edit descriptions (skos:scopeNote) and sources (dct:source) within the detail panel of terms and connections."
}
};
1 change: 1 addition & 0 deletions src/main/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default class App extends React.Component<
});
this.handleWorkspaceReady();
callToast("newFunctionEditTrope");
callToast("newFunctionDescriptionAndSources");
};
if (Environment.debug && loadDebugData()) finishUp();
else
Expand Down
89 changes: 10 additions & 79 deletions src/panels/detail/components/LinkControls.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import _ from "lodash";
import React, { useRef, useState } from "react";
import { CloseButton } from "react-bootstrap";
import { LanguageSelector } from "../../../components/LanguageSelector";
import { LinkType, Representation } from "../../../config/Enum";
import { LanguageObject } from "../../../config/Languages";
import { Locale } from "../../../config/Locale";
import {
AlternativeLabel,
AppSettings,
CardinalityPool,
WorkspaceElements,
Expand All @@ -15,11 +12,7 @@ import {
WorkspaceVocabularies,
} from "../../../config/Variables";
import { Cardinality } from "../../../datatypes/Cardinality";
import {
getDisplayLabel,
getSelectedLabels,
} from "../../../function/FunctionDraw";
import { initLanguageObject } from "../../../function/FunctionEditVars";
import { getDisplayLabel } from "../../../function/FunctionDraw";
import {
getLabelOrBlank,
getLinkOrVocabElem,
Expand All @@ -32,9 +25,8 @@ import { graph } from "../../../graph/Graph";
import { updateTermConnections } from "../../../queries/update/UpdateConnectionQueries";
import { updateProjectElement } from "../../../queries/update/UpdateElementQueries";
import { updateProjectLink } from "../../../queries/update/UpdateLinkQueries";
import { IntrinsicTropeControls } from "./IntrinsicTropeControls";
import { DetailPanelAltLabels } from "./description/DetailPanelAltLabels";
import { DetailPanelCardinalities } from "./description/DetailPanelCardinalities";
import { DetailElementDescription } from "./element/DetailElementDescription";

interface Props {
id: string;
Expand All @@ -47,10 +39,6 @@ interface Props {
export const LinkControls: React.FC<Props> = (props: Props) => {
const [sourceCardinality, setSourceCardinality] = useState<string>("0");
const [targetCardinality, setTargetCardinality] = useState<string>("0");
const [inputAltLabels, setInputAltLabels] = useState<AlternativeLabel[]>([]);
const [selectedLabel, setSelectedLabel] = useState<LanguageObject>(
initLanguageObject("")
);
const [readOnly, setReadOnly] = useState<boolean>(false);
const [selectedLanguage, setSelectedLanguage] = useState<string>(
AppSettings.canvasLanguage
Expand Down Expand Up @@ -116,7 +104,6 @@ export const LinkControls: React.FC<Props> = (props: Props) => {
prevPropsID.current !== props.id
) {
prevPropsID.current = props.id;
const iri = WorkspaceLinks[props.id].iri;
const sourceCardinality = CardinalityPool.findIndex(
(card) =>
card.getString() ===
Expand All @@ -133,14 +120,6 @@ export const LinkControls: React.FC<Props> = (props: Props) => {
setTargetCardinality(
targetCardinality === -1 ? "0" : targetCardinality.toString(10)
);
setInputAltLabels(
iri in WorkspaceTerms ? WorkspaceTerms[iri].altLabels : []
);
setSelectedLabel(
iri in WorkspaceElements
? getSelectedLabels(iri, AppSettings.canvasLanguage)
: initLanguageObject("")
);
setReadOnly(isReadOnly(props.id));
}

Expand Down Expand Up @@ -206,62 +185,14 @@ export const LinkControls: React.FC<Props> = (props: Props) => {
}}
/>
{AppSettings.representation === Representation.COMPACT &&
WorkspaceLinks[props.id].type === LinkType.DEFAULT && (
<>
<h5>{Locale[AppSettings.interfaceLanguage].detailPanelAltLabel}</h5>
<DetailPanelAltLabels
altLabels={inputAltLabels}
selectedLabel={selectedLabel}
language={selectedLanguage}
readOnly={readOnly}
addAltLabel={(alt: AlternativeLabel) => {
const newAL = [...inputAltLabels, alt];
setInputAltLabels(newAL);
WorkspaceTerms[WorkspaceLinks[props.id].iri].altLabels = newAL;
save();
}}
id={WorkspaceLinks[props.id].iri}
selectDisplayLabel={(name, language) => {
const newSL = {
...selectedLabel,
[language]: name,
};
WorkspaceElements[WorkspaceLinks[props.id].iri].selectedLabel =
newSL;
setSelectedLabel(newSL);
save();
}}
deleteAltLabel={(alt: AlternativeLabel) => {
if (selectedLabel[selectedLanguage] === alt.label) {
const newSL = {
...selectedLabel,
[selectedLanguage]:
WorkspaceTerms[WorkspaceLinks[props.id].iri].labels[
selectedLanguage
],
};
WorkspaceElements[
WorkspaceLinks[props.id].iri
].selectedLabel = newSL;
setSelectedLabel(newSL);
}
const newAL = _.without(inputAltLabels, alt);
setInputAltLabels(newAL);
WorkspaceTerms[WorkspaceLinks[props.id].iri].altLabels = newAL;
save();
}}
/>
{WorkspaceLinks[props.id].iri in WorkspaceTerms && (
<IntrinsicTropeControls
performTransaction={props.performTransaction}
id={WorkspaceLinks[props.id].iri}
readOnly={readOnly}
projectLanguage={props.projectLanguage}
save={props.save}
linkID={props.id}
/>
)}
</>
WorkspaceLinks[props.id].type === LinkType.DEFAULT &&
props.id && (
<DetailElementDescription
id={WorkspaceLinks[props.id].iri}
performTransaction={props.performTransaction}
selectedLanguage={selectedLanguage}
save={save}
/>
)}
</>
);
Expand Down
Loading

0 comments on commit 8a90416

Please sign in to comment.