Skip to content

Commit

Permalink
Vlastnosti by měly mít barvu pozadí dle slovníku, ze kterého jsou #537
Browse files Browse the repository at this point in the history
  • Loading branch information
bindeali committed Sep 6, 2024
1 parent f76c32c commit b47d275
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/components/VocabularyBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ type Props = {
cancellable: boolean;
onCancel?: Function;
color: string;
small?: boolean;
};

export const VocabularyBadge: React.FC<Props> = (props: Props) => {
return (
<span className="chip" style={{ backgroundColor: props.color }}>
<span
className={"chip" + (props.small ? " small" : "")}
style={{ backgroundColor: props.color }}
>
{props.text}
&nbsp;
{props.cancellable && props.onCancel && (
Expand Down
29 changes: 14 additions & 15 deletions src/function/FunctionGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export function centerElementInView(id: string) {
paper.translate(0, 0);
paper.translate(
-elem.position().x * scale +
paper.getComputedSize().width / 2 -
elem.getBBox().width,
paper.getComputedSize().width / 2 -
elem.getBBox().width,
-elem.position().y * scale +
paper.getComputedSize().height / 2 -
elem.getBBox().height
paper.getComputedSize().height / 2 -
elem.getBBox().height
);
updateDiagramPosition(AppSettings.selectedDiagram);
}
Expand Down Expand Up @@ -416,8 +416,7 @@ export function setRepresentation(
) {
const cell = g.getCell(id);
if (cell) {
WorkspaceElements[id].hidden[diag] = true;
cell.remove();
storeElement(cell);
del = true;
}
}
Expand Down Expand Up @@ -538,9 +537,9 @@ export function setupLink(
if (restoreConnectionPosition) {
WorkspaceLinks[link].vertices[AppSettings.selectedDiagram].length > 0
? setLinkVertices(
lnk,
WorkspaceLinks[link].vertices[AppSettings.selectedDiagram]
)
lnk,
WorkspaceLinks[link].vertices[AppSettings.selectedDiagram]
)
: findLinkSelfLoop(lnk);
return undefined;
} else {
Expand Down Expand Up @@ -578,10 +577,10 @@ export function restoreHiddenElem(
(representation === Representation.FULL
? WorkspaceLinks[link].iri in Links
: !(WorkspaceLinks[link].iri in Links) ||
(WorkspaceLinks[link].iri in Links &&
Links[WorkspaceLinks[link].iri].inScheme.startsWith(
AppSettings.ontographerContext
)))
(WorkspaceLinks[link].iri in Links &&
Links[WorkspaceLinks[link].iri].inScheme.startsWith(
AppSettings.ontographerContext
)))
) {
const oldPos = setupLink(link, restoreSimpleConnectionPosition, g);
if (oldPos)
Expand Down Expand Up @@ -620,9 +619,9 @@ export function restoreHiddenElem(
if (
WorkspaceElements[relID].position[AppSettings.selectedDiagram] &&
WorkspaceElements[relID].position[AppSettings.selectedDiagram].x !==
0 &&
0 &&
WorkspaceElements[relID].position[AppSettings.selectedDiagram].y !==
0 &&
0 &&
restoreFullConnectionPosition
) {
relationship.position(
Expand Down
16 changes: 16 additions & 0 deletions src/panels/detail/components/IntrinsicTropeControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Button, Form, OverlayTrigger, Tooltip } from "react-bootstrap";
import { Locale } from "../../../config/Locale";
import {
AppSettings,
WorkspaceElements,
WorkspaceLinks,
WorkspaceTerms,
WorkspaceVocabularies,
} from "../../../config/Variables";
import {
getListClassNamesObject,
Expand All @@ -15,6 +17,7 @@ import {
import {
getIntrinsicTropeTypeIDs,
getLabelOrBlank,
getVocabularyLabel,
} from "../../../function/FunctionGetVars";
import { deleteLink } from "../../../function/FunctionLink";
import { ModalAddTrope } from "./element/ModalAddTrope";
Expand All @@ -23,6 +26,7 @@ import { setLabels } from "../../../function/FunctionGraph";
import { graph } from "../../../graph/Graph";
import { addToSelection } from "../../../function/FunctionDiagram";
import InfoIcon from "@mui/icons-material/Info";
import { VocabularyBadge } from "../../../components/VocabularyBadge";

interface Props {
performTransaction: (...queries: string[]) => void;
Expand Down Expand Up @@ -75,6 +79,18 @@ export const IntrinsicTropeControls: React.FC<Props> = (props: Props) => {
>
<span>
{getLabelOrBlank(WorkspaceTerms[iri].labels, props.projectLanguage)}
&nbsp;
{WorkspaceElements[iri].vocabulary && (
<VocabularyBadge
text={getVocabularyLabel(WorkspaceElements[iri].vocabulary!)}
cancellable={false}
color={
WorkspaceVocabularies[WorkspaceElements[iri].vocabulary!]
.color
}
small={true}
/>
)}
</span>
<span
className={classNames("controls", {
Expand Down
17 changes: 17 additions & 0 deletions src/panels/detail/components/element/ModalAddTrope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
WorkspaceElements,
WorkspaceLinks,
WorkspaceTerms,
WorkspaceVocabularies,
} from "../../../../config/Variables";
import { CellColors } from "../../../../config/visual/CellColors";
import { createTerm } from "../../../../function/FunctionCreateElem";
Expand All @@ -34,11 +35,13 @@ import { filterEquivalent } from "../../../../function/FunctionEquivalents";
import {
getLabelOrBlank,
getVocabularyFromScheme,
getVocabularyLabel,
isTermReadOnly,
} from "../../../../function/FunctionGetVars";
import { saveNewLink } from "../../../../function/FunctionLink";
import { graph } from "../../../../graph/Graph";
import { updateProjectElementDiagram } from "../../../../queries/update/UpdateElementQueries";
import { VocabularyBadge } from "../../../../components/VocabularyBadge";

interface Props {
modalTropes: boolean;
Expand Down Expand Up @@ -234,6 +237,20 @@ export const ModalAddTrope: React.FC<Props> = (props: Props) => {
WorkspaceTerms[t].labels,
props.selectedLanguage
)}
&nbsp;
{WorkspaceElements[t].vocabulary && (
<VocabularyBadge
text={getVocabularyLabel(
WorkspaceElements[t].vocabulary!
)}
cancellable={false}
color={
WorkspaceVocabularies[
WorkspaceElements[t].vocabulary!
].color
}
/>
)}
</ListGroup.Item>
))}
</ListGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ body {
margin-right: 5px;
font-size: 1rem;
font-weight: 500;

&.small {
font-size: 0.8rem;
}
}

.wrap {
Expand Down

0 comments on commit b47d275

Please sign in to comment.