Skip to content

Commit ffe96c1

Browse files
committed
feat: re-add typ-události
1 parent 2b8af5d commit ffe96c1

File tree

11 files changed

+104
-96
lines changed

11 files changed

+104
-96
lines changed

src/config/logic/RepresentationConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export var RepresentationConfig: {
77
visibleStereotypes: [
88
"https://slovník.gov.cz/základní/pojem/typ-objektu",
99
"https://slovník.gov.cz/veřejný-sektor/pojem/typ-subjektu-práva",
10+
"https://slovník.gov.cz/základní/pojem/typ-události",
1011
],
1112
},
1213
[Representation.FULL]: {
1314
visibleStereotypes: [
1415
"https://slovník.gov.cz/základní/pojem/typ-objektu",
1516
"https://slovník.gov.cz/veřejný-sektor/pojem/typ-subjektu-práva",
17+
"https://slovník.gov.cz/základní/pojem/typ-události",
1618
"https://slovník.gov.cz/základní/pojem/typ-vztahu",
1719
"https://slovník.gov.cz/základní/pojem/typ-vlastnosti",
1820
],

src/config/visual/Shapes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ export var Shapes: {
2020
body: "bodyBox",
2121
color: "#FFFFFF",
2222
},
23+
"https://slovník.gov.cz/základní/pojem/typ-události": {
24+
body: "bodyTrapezoid",
25+
color: "#FFFFFF",
26+
},
2327
default: { body: "bodyBox", color: "#FFFFFF" },
2428
};

src/function/FunctionDraw.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ import {
1414
clearSelection,
1515
removeFromSelection,
1616
} from "./FunctionDiagram";
17-
import { getStereotypeList, setElementShape } from "./FunctionEditVars";
17+
import {
18+
getStereotypeList,
19+
parsePrefix,
20+
setElementShape,
21+
} from "./FunctionEditVars";
1822
import {
1923
getElementShape,
2024
getIntrinsicTropeTypeIDs,
2125
getLabelOrBlank,
2226
} from "./FunctionGetVars";
27+
import { filterEquivalent } from "./FunctionEquivalents";
2328

2429
export function getListClassNamesObject(arr: any[], i: number) {
2530
return {
@@ -51,12 +56,12 @@ export function getSelectedLabels(
5156
return WorkspaceElements[id].selectedLabel;
5257
}
5358

54-
// function isElementEventType(id: string) {
55-
// return filterEquivalent(
56-
// WorkspaceTerms[id].types,
57-
// parsePrefix("z-sgov-pojem", "typ-události")
58-
// );
59-
// }
59+
function isElementEventType(id: string) {
60+
return filterEquivalent(
61+
WorkspaceTerms[id].types,
62+
parsePrefix("z-sgov-pojem", "typ-události")
63+
);
64+
}
6065

6166
export function drawGraphElement(
6267
elem: joint.dia.Element,
@@ -83,7 +88,7 @@ export function drawGraphElement(
8388
);
8489
}
8590
elem.prop("attrs/labelAttrs/text", text.join("\n"));
86-
// if (isElementEventType(elem.id)) elem.prop("attrs/labelAttrs/x", 20);
91+
if (isElementEventType(elem.id)) elem.prop("attrs/labelAttrs/x", 20);
8792
const width =
8893
representation === Representation.COMPACT
8994
? Math.max(

src/function/FunctionEditVars.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,20 @@ export function setElementShape(
218218
].color,
219219
},
220220
});
221-
}
222-
// else if (
223-
// filterEquivalent(types, parsePrefix("z-sgov-pojem", "typ-události"))
224-
// ) {
225-
// elem.attr({
226-
// bodyTrapezoid: {
227-
// display: "block",
228-
// points: `20,0 ${width - 20},0 ${width},${height} 0,${height}`,
229-
// stroke: "black",
230-
// fill: WorkspaceVocabularies[
231-
// getVocabularyFromScheme(WorkspaceTerms[elem.id].inScheme)
232-
// ].color,
233-
// },
234-
// });
235-
// }
236-
else {
221+
} else if (
222+
filterEquivalent(types, parsePrefix("z-sgov-pojem", "typ-události"))
223+
) {
224+
elem.attr({
225+
bodyTrapezoid: {
226+
display: "block",
227+
points: `20,0 ${width - 20},0 ${width},${height} 0,${height}`,
228+
stroke: "black",
229+
fill: WorkspaceVocabularies[
230+
getVocabularyFromScheme(WorkspaceTerms[elem.id].inScheme)
231+
].color,
232+
},
233+
});
234+
} else {
237235
elem.attr({
238236
bodyBox: {
239237
display: "block",

src/main/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
updateContexts,
4545
} from "../interface/ContextInterface";
4646
import { getVocabulariesFromRemoteJSON } from "../interface/JSONInterface";
47+
import { dumpOFNVocabularies } from "../interface/OFNInterface";
4748
import {
4849
abortTransaction,
4950
processTransaction,
@@ -62,7 +63,6 @@ import {
6263
} from "../queries/update/UpdateDiagramQueries";
6364
import { MainView } from "./MainView";
6465
import { ToastService } from "./ToastService";
65-
import { dumpOFNVocabularies } from "../interface/OFNInterface";
6666

6767
interface DiagramAppProps {}
6868

src/panels/VocabularyPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export default class VocabularyPanel extends React.Component<Props, State> {
267267
if (this.state.shownElements[vocabulary][iri].length === 0) continue;
268268
vocabularyConcepts.push(
269269
<ConceptDivider
270-
key={iri}
270+
key={`div-${iri}`}
271271
iri={iri}
272272
items={this.state.shownElements[vocabulary][iri]}
273273
projectLanguage={this.props.projectLanguage}
@@ -277,7 +277,7 @@ export default class VocabularyPanel extends React.Component<Props, State> {
277277
for (const id of this.state.shownElements[vocabulary][iri]) {
278278
vocabularyConcepts.push(
279279
<VocabularyConcept
280-
key={id}
280+
key={`trm-${id}`}
281281
id={id}
282282
projectLanguage={this.props.projectLanguage}
283283
readOnly={WorkspaceVocabularies[vocabulary].readOnly}

src/panels/detail/components/element/DetailElementDescription.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ export class DetailElementDescription extends React.Component<Props, State> {
202202
}
203203

204204
isObjectType = (types: string[]) =>
205-
types.find((t) =>
206-
isEquivalent(t, parsePrefix("z-sgov-pojem", "typ-objektu"))
205+
types.find(
206+
(t) =>
207+
isEquivalent(t, parsePrefix("z-sgov-pojem", "typ-objektu")) ||
208+
// TODO: add typ-subjektu-práva to equivalents
209+
t === parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
207210
);
208211

209212
save() {

src/panels/menu/modal/export/ExportTermsCSV.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,28 @@ export async function exportTermsCSV(
100100
),
101101
])
102102
);
103-
// const eventOutputs = _.uniq(
104-
// exportTerms[term]
105-
// .concat(superClassAttributes)
106-
// .filter((r) =>
107-
// WorkspaceTerms[r].types.includes(
108-
// parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
109-
// )
110-
// )
111-
// ).map((link) =>
112-
// compile([
113-
// termLabel,
114-
// "",
115-
// "",
116-
// getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage),
117-
// WorkspaceTerms[link].definitions[exportLanguage],
118-
// link in sources ? sources[link] : "",
119-
// getLabelOrBlank(
120-
// Stereotypes[parsePrefix("v-sgov-pojem", "typ-subjektu-práva")].labels,
121-
// exportLanguage
122-
// ),
123-
// ])
124-
// );
103+
const eventOutputs = _.uniq(
104+
exportTerms[term]
105+
.concat(superClassAttributes)
106+
.filter((r) =>
107+
WorkspaceTerms[r].types.includes(
108+
parsePrefix("z-sgov-pojem", "typ-události")
109+
)
110+
)
111+
).map((link) =>
112+
compile([
113+
termLabel,
114+
"",
115+
"",
116+
getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage),
117+
WorkspaceTerms[link].definitions[exportLanguage],
118+
link in sources ? sources[link] : "",
119+
getLabelOrBlank(
120+
Stereotypes[parsePrefix("z-sgov-pojem", "typ-události")].labels,
121+
exportLanguage
122+
),
123+
])
124+
);
125125
const tropeOutputs = _.uniq(
126126
exportTerms[term]
127127
.concat(superClassAttributes)
@@ -145,7 +145,7 @@ export async function exportTermsCSV(
145145
])
146146
);
147147
output += termOutput + carriageReturn;
148-
// for (const o of eventOutputs) output += o + carriageReturn;
148+
for (const o of eventOutputs) output += o + carriageReturn;
149149
for (const o of tropeOutputs) output += o + carriageReturn;
150150
for (const o of relationshipOutputs) output += o + carriageReturn;
151151
if (termType === parsePrefix("z-sgov-pojem", "typ-vztahu")) {

src/panels/menu/modal/export/ExportTermsText.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@ export async function exportTermsText(
5858
bullet +
5959
getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage)
6060
);
61-
// const eventOutputs = exportTerms[term]
62-
// .concat(superClassAttributes)
63-
// .filter((r) =>
64-
// WorkspaceTerms[r].types.includes(
65-
// parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
66-
// )
67-
// )
68-
// .map(
69-
// (link) =>
70-
// tab +
71-
// bullet +
72-
// getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage)
73-
// );
61+
const eventOutputs = exportTerms[term]
62+
.concat(superClassAttributes)
63+
.filter((r) =>
64+
WorkspaceTerms[r].types.includes(
65+
parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
66+
)
67+
)
68+
.map(
69+
(link) =>
70+
tab +
71+
bullet +
72+
getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage)
73+
);
7474
const tropeOutputs = exportTerms[term]
7575
.concat(superClassAttributes)
7676
.filter((r) =>
@@ -85,7 +85,7 @@ export async function exportTermsText(
8585
getLabelOrBlank(WorkspaceTerms[link].labels, exportLanguage)
8686
);
8787
output += bullet + termLabel + carriageReturn;
88-
// for (const o of eventOutputs) output += o + carriageReturn;
88+
for (const o of eventOutputs) output += o + carriageReturn;
8989
for (const o of tropeOutputs) output += o + carriageReturn;
9090
for (const o of relationshipOutputs) output += o + carriageReturn;
9191
if (termType === parsePrefix("z-sgov-pojem", "typ-vztahu")) {

src/panels/menu/modal/export/FunctionExportTerms.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ export const exportFunctions: {
8181
) && getIntrinsicTropeTypeIDs(c).length === 0
8282
);
8383
// event types, but only those that don't have tropes
84-
// const simpleEvents = Object.keys(exportTerms).filter(
85-
// (t) =>
86-
// WorkspaceTerms[t].types.includes(
87-
// parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
88-
// ) && getIntrinsicTropeTypeIDs(t).length === 0
89-
// );
84+
const simpleEvents = Object.keys(exportTerms).filter(
85+
(t) =>
86+
WorkspaceTerms[t].types.includes(
87+
parsePrefix("v-sgov-pojem", "typ-subjektu-práva")
88+
) && getIntrinsicTropeTypeIDs(t).length === 0
89+
);
9090
// we don't treat code lists any differently for now
9191
Object.keys(exportTerms).forEach((t) => {
9292
const activeToConnections = getActiveSourceConnections(t);
@@ -97,21 +97,21 @@ export const exportFunctions: {
9797
simpleRelationships
9898
)
9999
);
100-
// exportTerms[t].push(
101-
// ...simpleEvents.filter(
102-
// (e) =>
103-
// activeToConnections.find((c) => WorkspaceLinks[c].target === e) ||
104-
// getActiveSourceConnections(e).find(
105-
// (c) => WorkspaceLinks[c].target === t
106-
// )
107-
// )
108-
// );
100+
exportTerms[t].push(
101+
...simpleEvents.filter(
102+
(e) =>
103+
activeToConnections.find((c) => WorkspaceLinks[c].target === e) ||
104+
getActiveSourceConnections(e).find(
105+
(c) => WorkspaceLinks[c].target === t
106+
)
107+
)
108+
);
109109
});
110110
exportTerms = _.fromPairs(
111111
Object.entries(exportTerms).filter(
112112
(t) =>
113113
!simpleRelationships.includes(t[0]) &&
114-
// !simpleEvents.includes(t[0]) &&
114+
!simpleEvents.includes(t[0]) &&
115115
(WorkspaceTerms[t[0]].types.includes(
116116
parsePrefix("z-sgov-pojem", "typ-objektu")
117117
) ||

0 commit comments

Comments
 (0)