|
|
|
|
@@ -1,16 +1,22 @@
|
|
|
|
|
import { useCallback, useEffect, useMemo, useState, type FormEvent } from "react";
|
|
|
|
|
import { Edit3, Plus, RefreshCw, Save, XCircle } from "lucide-react";
|
|
|
|
|
import { useCallback, useEffect, useMemo, useRef, useState, type FormEvent } from "react";
|
|
|
|
|
import { Edit3, Plus, RefreshCw } from "lucide-react";
|
|
|
|
|
import {
|
|
|
|
|
AdminIconButton,
|
|
|
|
|
ApiError,
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
DataGrid,
|
|
|
|
|
Dialog,
|
|
|
|
|
DismissibleAlert,
|
|
|
|
|
ExplorerTree,
|
|
|
|
|
FormField,
|
|
|
|
|
IconButton,
|
|
|
|
|
LoadingFrame,
|
|
|
|
|
ModuleSubnav,
|
|
|
|
|
PageTitle,
|
|
|
|
|
StatusBadge,
|
|
|
|
|
TableActionGroup,
|
|
|
|
|
ToggleSwitch,
|
|
|
|
|
hasScope,
|
|
|
|
|
useUnsavedDraftGuard,
|
|
|
|
|
usePlatformUiCapabilities,
|
|
|
|
|
@@ -18,7 +24,6 @@ import {
|
|
|
|
|
type AuthInfo,
|
|
|
|
|
type DataGridColumn,
|
|
|
|
|
type ModuleSubnavGroup,
|
|
|
|
|
type OrganizationFunctionActionContribution,
|
|
|
|
|
type OrganizationFunctionActionsUiCapability
|
|
|
|
|
} from "@govoplan/core-webui";
|
|
|
|
|
import {
|
|
|
|
|
@@ -57,6 +62,7 @@ import {
|
|
|
|
|
|
|
|
|
|
export type OrganizationSection = "model" | "units" | "relations" | "functions";
|
|
|
|
|
type OrganizationsPageMode = "workspace" | "admin";
|
|
|
|
|
type OrganizationEditor = "unitType" | "structure" | "relationType" | "unit" | "relation" | "functionType" | "function";
|
|
|
|
|
|
|
|
|
|
type OrganizationsPageProps = {
|
|
|
|
|
settings: ApiSettings;
|
|
|
|
|
@@ -113,11 +119,26 @@ type FunctionDraft = SluggedDraft & {
|
|
|
|
|
act_in_place_allowed: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type ActiveItem = {
|
|
|
|
|
id: string;
|
|
|
|
|
is_active: boolean;
|
|
|
|
|
type OrganizationsInitialQuery = {
|
|
|
|
|
section: OrganizationSection | "";
|
|
|
|
|
unitId: string;
|
|
|
|
|
functionId: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function organizationSectionFromQuery(value: string | null): OrganizationSection | "" {
|
|
|
|
|
return value === "model" || value === "units" || value === "relations" || value === "functions" ? value : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function organizationsInitialQuery(): OrganizationsInitialQuery {
|
|
|
|
|
if (typeof window === "undefined") return { section: "", unitId: "", functionId: "" };
|
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
|
return {
|
|
|
|
|
section: organizationSectionFromQuery(params.get("section")),
|
|
|
|
|
unitId: params.get("unit_id") || "",
|
|
|
|
|
functionId: params.get("function_id") || ""
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const EMPTY_MODEL: OrganizationModel = {
|
|
|
|
|
unit_types: [],
|
|
|
|
|
structures: [],
|
|
|
|
|
@@ -275,27 +296,6 @@ function activeStatus(active: boolean): JSX.Element {
|
|
|
|
|
return <StatusBadge status={active ? "success" : "inactive"} label={active ? "i18n:govoplan-organizations.active.a733b809" : "i18n:govoplan-organizations.inactive.09af574c"} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ActiveToggleButton({ item, disabled, onToggle }: { item: ActiveItem; disabled: boolean; onToggle: () => void }) {
|
|
|
|
|
const label = item.is_active ? "i18n:govoplan-organizations.deactivate.46ab070d" : "i18n:govoplan-organizations.reactivate.58f2855d";
|
|
|
|
|
return (
|
|
|
|
|
<Button type="button" variant={item.is_active ? "secondary" : "primary"} disabled={disabled} onClick={onToggle} title={label}>
|
|
|
|
|
{label}
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function RowActions({ item, disabled, onEdit, onToggle, extra }: { item: ActiveItem; disabled: boolean; onEdit: () => void; onToggle: () => void; extra?: JSX.Element[] }) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-row-actions">
|
|
|
|
|
<Button type="button" variant="ghost" disabled={disabled} onClick={onEdit} title="i18n:govoplan-organizations.edit.7dce1220">
|
|
|
|
|
<Edit3 size={16} aria-hidden="true" /> i18n:govoplan-organizations.edit.7dce1220
|
|
|
|
|
</Button>
|
|
|
|
|
<ActiveToggleButton item={item} disabled={disabled} onToggle={onToggle} />
|
|
|
|
|
{extra}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SluggedFields({
|
|
|
|
|
draft,
|
|
|
|
|
onChange,
|
|
|
|
|
@@ -318,10 +318,14 @@ function SluggedFields({
|
|
|
|
|
<textarea rows={3} value={draft.description} disabled={disabled} onChange={(event) => onChange({ ...draft, description: event.target.value })} />
|
|
|
|
|
</FormField>
|
|
|
|
|
</div>
|
|
|
|
|
<label className="organizations-inline-check wide">
|
|
|
|
|
<input type="checkbox" checked={draft.is_active} disabled={disabled} onChange={(event) => onChange({ ...draft, is_active: event.target.checked })} />
|
|
|
|
|
<span>i18n:govoplan-organizations.active.a733b809</span>
|
|
|
|
|
</label>
|
|
|
|
|
<div className="wide">
|
|
|
|
|
<ToggleSwitch
|
|
|
|
|
checked={draft.is_active}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
onChange={(checked) => onChange({ ...draft, is_active: checked })}
|
|
|
|
|
label="i18n:govoplan-organizations.active.a733b809"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@@ -345,7 +349,10 @@ export default function OrganizationsPage({
|
|
|
|
|
}: OrganizationsPageProps) {
|
|
|
|
|
const sectionSet = useMemo(() => new Set(availableSections.length ? availableSections : ALL_SECTIONS), [availableSections]);
|
|
|
|
|
const firstAvailableSection = availableSections.find((section) => sectionSet.has(section)) ?? "model";
|
|
|
|
|
const [active, setActive] = useState<OrganizationSection>(sectionSet.has(initialSection) ? initialSection : firstAvailableSection);
|
|
|
|
|
const initialQuery = useMemo(() => organizationsInitialQuery(), []);
|
|
|
|
|
const requestedInitialSection = initialQuery.section && sectionSet.has(initialQuery.section) ? initialQuery.section : initialSection;
|
|
|
|
|
const [active, setActive] = useState<OrganizationSection>(sectionSet.has(requestedInitialSection) ? requestedInitialSection : firstAvailableSection);
|
|
|
|
|
const appliedInitialQueryRef = useRef(false);
|
|
|
|
|
const visibleSectionGroups = useMemo(() => sectionGroupsFor(sectionSet), [sectionSet]);
|
|
|
|
|
const [model, setModel] = useState<OrganizationModel>(EMPTY_MODEL);
|
|
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
@@ -367,6 +374,7 @@ export default function OrganizationsPage({
|
|
|
|
|
const [editingRelationId, setEditingRelationId] = useState<string | null>(null);
|
|
|
|
|
const [editingFunctionTypeId, setEditingFunctionTypeId] = useState<string | null>(null);
|
|
|
|
|
const [editingFunctionId, setEditingFunctionId] = useState<string | null>(null);
|
|
|
|
|
const [activeEditor, setActiveEditor] = useState<OrganizationEditor | null>(null);
|
|
|
|
|
const [selectedUnitId, setSelectedUnitId] = useState("");
|
|
|
|
|
const [changeRequestId, setChangeRequestId] = useState("");
|
|
|
|
|
const functionActionCapabilities = usePlatformUiCapabilities<OrganizationFunctionActionsUiCapability>("organizations.functionActions");
|
|
|
|
|
@@ -467,6 +475,8 @@ export default function OrganizationsPage({
|
|
|
|
|
setEditingRelationId(null);
|
|
|
|
|
setEditingFunctionTypeId(null);
|
|
|
|
|
setEditingFunctionId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
function rejectMissingName(): Promise<boolean> {
|
|
|
|
|
@@ -490,6 +500,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setUnitTypeDraft(emptySluggedDraft());
|
|
|
|
|
setEditingUnitTypeId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteModel, editingUnitTypeId, runAction, settings, unitTypeDraft, withChangeRequest]);
|
|
|
|
|
@@ -507,6 +519,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setStructureDraft(emptyStructureDraft());
|
|
|
|
|
setEditingStructureId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteModel, editingStructureId, runAction, settings, structureDraft, withChangeRequest]);
|
|
|
|
|
@@ -538,6 +552,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setRelationTypeDraft(emptyRelationTypeDraft());
|
|
|
|
|
setEditingRelationTypeId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteModel, editingRelationTypeId, relationTypeDraft, runAction, settings, withChangeRequest]);
|
|
|
|
|
@@ -563,6 +579,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setUnitDraft(emptyUnitDraft());
|
|
|
|
|
setEditingUnitId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteUnits, editingUnitId, runAction, settings, unitDraft, withChangeRequest]);
|
|
|
|
|
@@ -583,6 +601,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setRelationDraft(emptyRelationDraft());
|
|
|
|
|
setEditingRelationId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteUnits, editingRelationId, relationDraft, runAction, settings, withChangeRequest]);
|
|
|
|
|
@@ -610,6 +630,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setFunctionTypeDraft(emptyFunctionTypeDraft());
|
|
|
|
|
setEditingFunctionTypeId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteModel, editingFunctionTypeId, functionTypeDraft, runAction, settings, withChangeRequest]);
|
|
|
|
|
@@ -643,6 +665,8 @@ export default function OrganizationsPage({
|
|
|
|
|
if (ok) {
|
|
|
|
|
setFunctionDraft(emptyFunctionDraft());
|
|
|
|
|
setEditingFunctionId(null);
|
|
|
|
|
setActiveEditor(null);
|
|
|
|
|
setChangeRequestId("");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}, [canWriteFunctions, editingFunctionId, functionDraft, runAction, settings, withChangeRequest]);
|
|
|
|
|
@@ -681,44 +705,68 @@ export default function OrganizationsPage({
|
|
|
|
|
message: "i18n:govoplan-core.this_page_has_unsaved_changes_save_them_before_l.419a9d8b"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const toggleUnitType = useCallback((item: OrganizationUnitTypeItem) => {
|
|
|
|
|
void runAction(() => patchUnitType(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openUnitTypeCreate = useCallback(() => {
|
|
|
|
|
setEditingUnitTypeId(null);
|
|
|
|
|
setUnitTypeDraft(emptySluggedDraft());
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("unitType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleStructure = useCallback((item: OrganizationStructureItem) => {
|
|
|
|
|
void runAction(() => patchStructure(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openStructureCreate = useCallback(() => {
|
|
|
|
|
setEditingStructureId(null);
|
|
|
|
|
setStructureDraft(emptyStructureDraft());
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("structure");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleRelationType = useCallback((item: OrganizationRelationTypeItem) => {
|
|
|
|
|
void runAction(() => patchRelationType(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openRelationTypeCreate = useCallback(() => {
|
|
|
|
|
setEditingRelationTypeId(null);
|
|
|
|
|
setRelationTypeDraft(emptyRelationTypeDraft());
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("relationType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleUnit = useCallback((item: OrganizationUnitItem) => {
|
|
|
|
|
void runAction(() => patchUnit(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openUnitCreate = useCallback((parentId = "") => {
|
|
|
|
|
setEditingUnitId(null);
|
|
|
|
|
setUnitDraft({ ...emptyUnitDraft(), parent_id: parentId });
|
|
|
|
|
if (parentId) setSelectedUnitId(parentId);
|
|
|
|
|
setActive("units");
|
|
|
|
|
setActiveEditor("unit");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleRelation = useCallback((item: OrganizationRelationItem) => {
|
|
|
|
|
void runAction(() => patchRelation(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openRelationCreate = useCallback(() => {
|
|
|
|
|
setEditingRelationId(null);
|
|
|
|
|
setRelationDraft(emptyRelationDraft());
|
|
|
|
|
setActive("relations");
|
|
|
|
|
setActiveEditor("relation");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleFunctionType = useCallback((item: OrganizationFunctionTypeItem) => {
|
|
|
|
|
void runAction(() => patchFunctionType(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openFunctionTypeCreate = useCallback(() => {
|
|
|
|
|
setEditingFunctionTypeId(null);
|
|
|
|
|
setFunctionTypeDraft(emptyFunctionTypeDraft());
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("functionType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleFunction = useCallback((item: OrganizationFunctionItem) => {
|
|
|
|
|
void runAction(() => patchFunction(settings, item.id, withChangeRequest({ is_active: !item.is_active })));
|
|
|
|
|
}, [runAction, settings, withChangeRequest]);
|
|
|
|
|
const openFunctionCreate = useCallback((organizationUnitId = "") => {
|
|
|
|
|
setEditingFunctionId(null);
|
|
|
|
|
setFunctionDraft({ ...emptyFunctionDraft(), organization_unit_id: organizationUnitId || selectedUnitId });
|
|
|
|
|
setActive("functions");
|
|
|
|
|
setActiveEditor("function");
|
|
|
|
|
}, [selectedUnitId]);
|
|
|
|
|
|
|
|
|
|
const editUnitType = useCallback((item: OrganizationUnitTypeItem) => {
|
|
|
|
|
setEditingUnitTypeId(item.id);
|
|
|
|
|
setUnitTypeDraft(sluggedDraftFrom(item));
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("unitType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const editStructure = useCallback((item: OrganizationStructureItem) => {
|
|
|
|
|
setEditingStructureId(item.id);
|
|
|
|
|
setStructureDraft({ ...sluggedDraftFrom(item), structure_kind: item.structure_kind as OrganizationStructureKind });
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("structure");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const editRelationType = useCallback((item: OrganizationRelationTypeItem) => {
|
|
|
|
|
@@ -732,6 +780,7 @@ export default function OrganizationsPage({
|
|
|
|
|
allow_cycles: item.allow_cycles
|
|
|
|
|
});
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("relationType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const editUnit = useCallback((item: OrganizationUnitItem) => {
|
|
|
|
|
@@ -739,14 +788,12 @@ export default function OrganizationsPage({
|
|
|
|
|
setSelectedUnitId(item.id);
|
|
|
|
|
setUnitDraft({ ...sluggedDraftFrom(item), unit_type_id: item.unit_type_id ?? "", parent_id: item.parent_id ?? "" });
|
|
|
|
|
setActive("units");
|
|
|
|
|
setActiveEditor("unit");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const addSubunit = useCallback((item: OrganizationUnitItem) => {
|
|
|
|
|
setSelectedUnitId(item.id);
|
|
|
|
|
setEditingUnitId(null);
|
|
|
|
|
setUnitDraft({ ...emptyUnitDraft(), parent_id: item.id });
|
|
|
|
|
setActive("units");
|
|
|
|
|
}, []);
|
|
|
|
|
openUnitCreate(item.id);
|
|
|
|
|
}, [openUnitCreate]);
|
|
|
|
|
|
|
|
|
|
const editRelation = useCallback((item: OrganizationRelationItem) => {
|
|
|
|
|
setEditingRelationId(item.id);
|
|
|
|
|
@@ -758,6 +805,7 @@ export default function OrganizationsPage({
|
|
|
|
|
is_active: item.is_active
|
|
|
|
|
});
|
|
|
|
|
setActive("relations");
|
|
|
|
|
setActiveEditor("relation");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const editFunctionType = useCallback((item: OrganizationFunctionTypeItem) => {
|
|
|
|
|
@@ -769,6 +817,7 @@ export default function OrganizationsPage({
|
|
|
|
|
act_in_place_allowed: item.act_in_place_allowed
|
|
|
|
|
});
|
|
|
|
|
setActive("model");
|
|
|
|
|
setActiveEditor("functionType");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const editFunction = useCallback((item: OrganizationFunctionItem) => {
|
|
|
|
|
@@ -782,14 +831,39 @@ export default function OrganizationsPage({
|
|
|
|
|
act_in_place_allowed: item.act_in_place_allowed
|
|
|
|
|
});
|
|
|
|
|
setActive("functions");
|
|
|
|
|
setActiveEditor("function");
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (appliedInitialQueryRef.current || loading) return;
|
|
|
|
|
if (initialQuery.functionId) {
|
|
|
|
|
const item = functionById.get(initialQuery.functionId);
|
|
|
|
|
if (item) {
|
|
|
|
|
appliedInitialQueryRef.current = true;
|
|
|
|
|
editFunction(item);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (initialQuery.unitId) {
|
|
|
|
|
const item = unitById.get(initialQuery.unitId);
|
|
|
|
|
if (item) {
|
|
|
|
|
appliedInitialQueryRef.current = true;
|
|
|
|
|
editUnit(item);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (initialQuery.section && sectionSet.has(initialQuery.section)) {
|
|
|
|
|
appliedInitialQueryRef.current = true;
|
|
|
|
|
setActive(initialQuery.section);
|
|
|
|
|
}
|
|
|
|
|
}, [editFunction, editUnit, functionById, initialQuery, loading, sectionSet, unitById]);
|
|
|
|
|
|
|
|
|
|
const unitTypeColumns: DataGridColumn<OrganizationUnitTypeItem>[] = [
|
|
|
|
|
{ id: "name", header: "i18n:govoplan-organizations.name.709a2322", minWidth: 180, sortable: true, filterable: true, value: (row) => row.name },
|
|
|
|
|
{ id: "slug", header: "i18n:govoplan-organizations.slug.094da9b9", width: 160, sortable: true, filterable: true, value: (row) => row.slug },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "description", header: "i18n:govoplan-organizations.description.55f8ebc8", minWidth: 220, value: (row) => row.description ?? "" },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteModel || busy} onEdit={() => editUnitType(row)} onToggle={() => toggleUnitType(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteModel || busy, onClick: () => editUnitType(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const structureColumns: DataGridColumn<OrganizationStructureItem>[] = [
|
|
|
|
|
@@ -797,7 +871,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "kind", header: "i18n:govoplan-organizations.kind.794c9d9c", width: 140, sortable: true, filterable: true, value: (row) => row.structure_kind },
|
|
|
|
|
{ id: "slug", header: "i18n:govoplan-organizations.slug.094da9b9", width: 160, value: (row) => row.slug },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteModel || busy} onEdit={() => editStructure(row)} onToggle={() => toggleStructure(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteModel || busy, onClick: () => editStructure(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const relationTypeColumns: DataGridColumn<OrganizationRelationTypeItem>[] = [
|
|
|
|
|
@@ -807,7 +881,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "target", header: "i18n:govoplan-organizations.target_unit.a1507d86", minWidth: 170, render: (row) => optionalLabel(unitTypeById.get(row.target_unit_type_id || "")?.name) },
|
|
|
|
|
{ id: "hierarchical", header: "i18n:govoplan-organizations.hierarchical.8964f313", width: 130, render: (row) => activeStatus(row.is_hierarchical) },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteModel || busy} onEdit={() => editRelationType(row)} onToggle={() => toggleRelationType(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteModel || busy, onClick: () => editRelationType(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const unitColumns: DataGridColumn<OrganizationUnitItem>[] = [
|
|
|
|
|
@@ -816,7 +890,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "parent", header: "i18n:govoplan-organizations.parent_unit.1986c35e", minWidth: 180, render: (row) => optionalLabel(unitById.get(row.parent_id || "")?.name) },
|
|
|
|
|
{ id: "slug", header: "i18n:govoplan-organizations.slug.094da9b9", width: 160, value: (row) => row.slug },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteUnits || busy} onEdit={() => editUnit(row)} onToggle={() => toggleUnit(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteUnits || busy, onClick: () => editUnit(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const relationColumns: DataGridColumn<OrganizationRelationItem>[] = [
|
|
|
|
|
@@ -825,7 +899,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "source", header: "i18n:govoplan-organizations.source_unit.2fbd8baa", minWidth: 190, render: (row) => optionalLabel(unitById.get(row.source_unit_id)?.name) },
|
|
|
|
|
{ id: "target", header: "i18n:govoplan-organizations.target_unit.a1507d86", minWidth: 190, render: (row) => optionalLabel(unitById.get(row.target_unit_id)?.name) },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteUnits || busy} onEdit={() => editRelation(row)} onToggle={() => toggleRelation(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteUnits || busy, onClick: () => editRelation(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const functionTypeColumns: DataGridColumn<OrganizationFunctionTypeItem>[] = [
|
|
|
|
|
@@ -834,7 +908,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "delegable", header: "i18n:govoplan-organizations.delegable.b4f0137d", width: 120, render: (row) => activeStatus(row.delegable) },
|
|
|
|
|
{ id: "actInPlace", header: "i18n:govoplan-organizations.act_in_place.49b942bd", width: 140, render: (row) => activeStatus(row.act_in_place_allowed) },
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{ id: "actions", header: "", width: 220, sticky: "end", render: (row) => <RowActions item={row} disabled={!canWriteModel || busy} onEdit={() => editFunctionType(row)} onToggle={() => toggleFunctionType(row)} /> }
|
|
|
|
|
{ id: "actions", header: "i18n:govoplan-organizations.actions.c3cd636a", width: 72, sticky: "end", resizable: false, align: "right", render: (row) => <TableActionGroup actions={[{ id: "edit", label: "i18n:govoplan-organizations.edit.7dce1220", icon: <Edit3 size={16} aria-hidden="true" />, disabled: !canWriteModel || busy, onClick: () => editFunctionType(row) }]} /> }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const functionColumns: DataGridColumn<OrganizationFunctionItem>[] = [
|
|
|
|
|
@@ -845,31 +919,31 @@ export default function OrganizationsPage({
|
|
|
|
|
{ id: "status", header: "i18n:govoplan-organizations.status.bae7d5be", width: 120, render: (row) => activeStatus(row.is_active) },
|
|
|
|
|
{
|
|
|
|
|
id: "actions",
|
|
|
|
|
header: "",
|
|
|
|
|
width: functionActionContributions.length ? 340 : 220,
|
|
|
|
|
header: "i18n:govoplan-organizations.actions.c3cd636a",
|
|
|
|
|
width: 88 + (functionActionContributions.length * 40),
|
|
|
|
|
sticky: "end",
|
|
|
|
|
render: (row) => (
|
|
|
|
|
<RowActions
|
|
|
|
|
item={row}
|
|
|
|
|
disabled={!canWriteFunctions || busy}
|
|
|
|
|
onEdit={() => editFunction(row)}
|
|
|
|
|
onToggle={() => toggleFunction(row)}
|
|
|
|
|
extra={functionActionContributions.map((contribution) => (
|
|
|
|
|
<span className="organizations-contributed-action" key={contribution.id}>
|
|
|
|
|
{contribution.render({ settings, auth, function: row })}
|
|
|
|
|
</span>
|
|
|
|
|
))}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
resizable: false,
|
|
|
|
|
align: "right",
|
|
|
|
|
render: (row) => <TableActionGroup actions={[
|
|
|
|
|
{
|
|
|
|
|
id: "edit",
|
|
|
|
|
label: "i18n:govoplan-organizations.edit.7dce1220",
|
|
|
|
|
icon: <Edit3 size={16} aria-hidden="true" />,
|
|
|
|
|
disabled: !canWriteFunctions || busy,
|
|
|
|
|
onClick: () => editFunction(row)
|
|
|
|
|
},
|
|
|
|
|
...functionActionContributions.map((contribution) => ({
|
|
|
|
|
id: contribution.id,
|
|
|
|
|
label: contribution.label,
|
|
|
|
|
icon: contribution.icon,
|
|
|
|
|
onClick: () => contribution.onClick({ settings, auth, function: row })
|
|
|
|
|
}))
|
|
|
|
|
]} />
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const canWriteActive = active === "model" ? canWriteModel : active === "units" || active === "relations" ? canWriteUnits : canWriteFunctions;
|
|
|
|
|
|
|
|
|
|
function cancelEditButton(onCancel: () => void) {
|
|
|
|
|
return <Button type="button" variant="ghost" onClick={onCancel} disabled={busy}>i18n:govoplan-organizations.cancel_edit.309c2a6f</Button>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const content = (
|
|
|
|
|
<div className={`${mode === "workspace" ? "content-pad " : ""}organizations-page ${mode === "admin" ? "organizations-admin-page" : ""}`.trim()}>
|
|
|
|
|
<div className="page-heading split organizations-heading">
|
|
|
|
|
@@ -878,23 +952,9 @@ export default function OrganizationsPage({
|
|
|
|
|
<p>{description}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-toolbar">
|
|
|
|
|
<label className="organizations-change-request">
|
|
|
|
|
<span>i18n:govoplan-organizations.change_request_id.a6e7fd6b</span>
|
|
|
|
|
<input value={changeRequestId} onChange={(event) => setChangeRequestId(event.target.value)} placeholder="cfgreq-..." disabled={busy} />
|
|
|
|
|
</label>
|
|
|
|
|
<Button type="button" onClick={() => void loadModel()} disabled={loading || busy} title="i18n:govoplan-organizations.reload.cce71553">
|
|
|
|
|
<RefreshCw size={16} aria-hidden="true" /> i18n:govoplan-organizations.reload.cce71553
|
|
|
|
|
</Button>
|
|
|
|
|
{hasDirtyDraft && (
|
|
|
|
|
<>
|
|
|
|
|
<Button type="button" onClick={() => void saveDrafts()} disabled={busy} title="i18n:govoplan-organizations.save_drafts.606f9401">
|
|
|
|
|
<Save size={16} aria-hidden="true" /> i18n:govoplan-organizations.save_drafts.606f9401
|
|
|
|
|
</Button>
|
|
|
|
|
<Button type="button" variant="ghost" onClick={discardDrafts} disabled={busy} title="i18n:govoplan-organizations.discard_organization_drafts.766d5f46">
|
|
|
|
|
<XCircle size={16} aria-hidden="true" /> i18n:govoplan-organizations.discard_organization_drafts.766d5f46
|
|
|
|
|
</Button>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@@ -908,6 +968,7 @@ export default function OrganizationsPage({
|
|
|
|
|
{active === "relations" && renderRelationsSection()}
|
|
|
|
|
{active === "functions" && renderFunctionsSection()}
|
|
|
|
|
</LoadingFrame>
|
|
|
|
|
{renderEditorDialog()}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -925,42 +986,181 @@ export default function OrganizationsPage({
|
|
|
|
|
function renderModelSection() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-table-stack">
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.unit_types.c7afc174">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitUnitType(event)}>
|
|
|
|
|
<SluggedFields draft={unitTypeDraft} onChange={setUnitTypeDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteModel || busy}>{editingUnitTypeId ? "i18n:govoplan-organizations.update_unit_type.b96fc0ad" : "i18n:govoplan-organizations.add_unit_type.58f2c05a"}</Button>
|
|
|
|
|
{editingUnitTypeId && cancelEditButton(() => { setEditingUnitTypeId(null); setUnitTypeDraft(emptySluggedDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.unit_types.c7afc174">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.unit_types.c7afc174" actions={<AdminIconButton label="i18n:govoplan-organizations.add_unit_type.58f2c05a" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteModel || busy} onClick={openUnitTypeCreate} />}>
|
|
|
|
|
<DataGrid id="organizations-unit-types" rows={model.unit_types} columns={unitTypeColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_unit_types_found.c81fb2a7" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.structures.f9b7f3b4" actions={<AdminIconButton label="i18n:govoplan-organizations.add_structure.b722042a" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteModel || busy} onClick={openStructureCreate} />}>
|
|
|
|
|
<DataGrid id="organizations-structures" rows={model.structures} columns={structureColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_structures_found.20b382d0" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.relation_types.e5890528" actions={<AdminIconButton label="i18n:govoplan-organizations.add_relation_type.2ad19d03" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteModel || busy} onClick={openRelationTypeCreate} />}>
|
|
|
|
|
<DataGrid id="organizations-relation-types" rows={model.relation_types} columns={relationTypeColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_relation_types_found.6f90bb81" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.function_types.172c01fe" actions={<AdminIconButton label="i18n:govoplan-organizations.add_function_type.90d793f1" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteModel || busy} onClick={openFunctionTypeCreate} />}>
|
|
|
|
|
<DataGrid id="organizations-function-types" rows={model.function_types} columns={functionTypeColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_function_types_found.5eef31b1" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.structures.f9b7f3b4">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitStructure(event)}>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUnitsSection() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-table-stack">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.organization_tree.e5bfb195" actions={<AdminIconButton label="i18n:govoplan-organizations.add_root_unit.1ef8a9f5" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteUnits || busy} onClick={() => openUnitCreate()} />}>
|
|
|
|
|
<div className="explorer-tree-toolbar">
|
|
|
|
|
{selectedUnitId && <Button type="button" variant="ghost" disabled={busy} onClick={() => setSelectedUnitId("")}>i18n:govoplan-organizations.none.334c4a4c</Button>}
|
|
|
|
|
</div>
|
|
|
|
|
{model.units.length ? (
|
|
|
|
|
<ExplorerTree
|
|
|
|
|
nodes={unitsByParentId.get("") ?? []}
|
|
|
|
|
getNodeId={(unit) => unit.id}
|
|
|
|
|
getNodeLabel={(unit) => unit.name}
|
|
|
|
|
getNodeChildren={(unit) => unitsByParentId.get(unit.id) ?? []}
|
|
|
|
|
activeId={selectedUnitId}
|
|
|
|
|
collapsible={false}
|
|
|
|
|
depth={0}
|
|
|
|
|
className="explorer-tree-scroll-region"
|
|
|
|
|
getNodeWrapStyle={(_unit, context) => ({ paddingLeft: `${Math.min(context.depth * 18, 72)}px` })}
|
|
|
|
|
onOpen={(unit) => setSelectedUnitId(unit.id)}
|
|
|
|
|
renderNodeContent={(unit) => (
|
|
|
|
|
<span className="explorer-tree-node-content">
|
|
|
|
|
<strong>{unit.name}</strong>
|
|
|
|
|
<small>{unitTypeById.get(unit.unit_type_id || "")?.name ?? "i18n:govoplan-organizations.no_unit_type.73e799f5"}</small>
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
renderNodeActions={(unit) => (
|
|
|
|
|
<IconButton
|
|
|
|
|
label="i18n:govoplan-organizations.add_subunit.8256a8f7"
|
|
|
|
|
icon={<Plus size={16} aria-hidden="true" />}
|
|
|
|
|
variant="ghost"
|
|
|
|
|
disabled={!canWriteUnits || busy}
|
|
|
|
|
onClick={() => addSubunit(unit)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
) : <p className="muted small-note">i18n:govoplan-organizations.no_units_found.eea2dd0c</p>}
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.units.e14d0d92" actions={<AdminIconButton label="i18n:govoplan-organizations.add_unit.8fa12fb1" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteUnits || busy} onClick={() => openUnitCreate()} />}>
|
|
|
|
|
<DataGrid id="organizations-units" rows={model.units} columns={unitColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_units_found.eea2dd0c" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderRelationsSection() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-table-stack">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.relations.1c796711" actions={<AdminIconButton label="i18n:govoplan-organizations.add_relation.6b6e67ea" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteUnits || busy} onClick={openRelationCreate} />}>
|
|
|
|
|
<DataGrid id="organizations-relations" rows={model.relations} columns={relationColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_relations_found.4e75b11d" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFunctionsSection() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-table-stack">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.functions.805dc49b" actions={<AdminIconButton label="i18n:govoplan-organizations.add_function.6abafee0" icon={<Plus size={16} aria-hidden="true" />} variant="primary" disabled={!canWriteFunctions || busy} onClick={() => openFunctionCreate()} />}>
|
|
|
|
|
<DataGrid id="organizations-functions" rows={model.functions} columns={functionColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_functions_found.54e759a0" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderChangeRequestField() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="wide organizations-dialog-change-request">
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.change_request_id.a6e7fd6b">
|
|
|
|
|
<input value={changeRequestId} onChange={(event) => setChangeRequestId(event.target.value)} placeholder="cfgreq-..." disabled={busy} />
|
|
|
|
|
</FormField>
|
|
|
|
|
<p className="organizations-field-note">i18n:govoplan-organizations.change_request_id_help.0c119a5d</p>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function editorTitle(): string {
|
|
|
|
|
switch (activeEditor) {
|
|
|
|
|
case "unitType": return editingUnitTypeId ? "i18n:govoplan-organizations.update_unit_type.b96fc0ad" : "i18n:govoplan-organizations.add_unit_type.58f2c05a";
|
|
|
|
|
case "structure": return editingStructureId ? "i18n:govoplan-organizations.update_structure.b2e25446" : "i18n:govoplan-organizations.add_structure.b722042a";
|
|
|
|
|
case "relationType": return editingRelationTypeId ? "i18n:govoplan-organizations.update_relation_type.e6e7f30c" : "i18n:govoplan-organizations.add_relation_type.2ad19d03";
|
|
|
|
|
case "unit": return editingUnitId ? "i18n:govoplan-organizations.update_unit.67e2500f" : "i18n:govoplan-organizations.add_unit.8fa12fb1";
|
|
|
|
|
case "relation": return editingRelationId ? "i18n:govoplan-organizations.update_relation.4c44ce83" : "i18n:govoplan-organizations.add_relation.6b6e67ea";
|
|
|
|
|
case "functionType": return editingFunctionTypeId ? "i18n:govoplan-organizations.update_function_type.0b7e07d3" : "i18n:govoplan-organizations.add_function_type.90d793f1";
|
|
|
|
|
case "function": return editingFunctionId ? "i18n:govoplan-organizations.update_function.504f03e5" : "i18n:govoplan-organizations.add_function.6abafee0";
|
|
|
|
|
default: return "i18n:govoplan-organizations.organizations.220edf64";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function editorSubmitDisabled(): boolean {
|
|
|
|
|
if (busy || !activeEditor) return true;
|
|
|
|
|
if ((activeEditor === "unitType" || activeEditor === "structure" || activeEditor === "relationType" || activeEditor === "functionType") && !canWriteModel) return true;
|
|
|
|
|
if ((activeEditor === "unit" || activeEditor === "relation") && !canWriteUnits) return true;
|
|
|
|
|
if (activeEditor === "function" && !canWriteFunctions) return true;
|
|
|
|
|
if (activeEditor === "unitType") return !unitTypeDraft.name.trim();
|
|
|
|
|
if (activeEditor === "structure") return !structureDraft.name.trim();
|
|
|
|
|
if (activeEditor === "relationType") return !relationTypeDraft.name.trim();
|
|
|
|
|
if (activeEditor === "unit") return !unitDraft.name.trim();
|
|
|
|
|
if (activeEditor === "relation") return !relationDraft.structure_id || !relationDraft.relation_type_id || !relationDraft.source_unit_id || !relationDraft.target_unit_id;
|
|
|
|
|
if (activeEditor === "functionType") return !functionTypeDraft.name.trim();
|
|
|
|
|
if (activeEditor === "function") return !functionDraft.name.trim() || !functionDraft.organization_unit_id;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderEditorDialog() {
|
|
|
|
|
if (!activeEditor) return null;
|
|
|
|
|
const formId = `organizations-${activeEditor}-editor`;
|
|
|
|
|
const submit = activeEditor === "unitType" ? submitUnitType :
|
|
|
|
|
activeEditor === "structure" ? submitStructure :
|
|
|
|
|
activeEditor === "relationType" ? submitRelationType :
|
|
|
|
|
activeEditor === "unit" ? submitUnit :
|
|
|
|
|
activeEditor === "relation" ? submitRelation :
|
|
|
|
|
activeEditor === "functionType" ? submitFunctionType :
|
|
|
|
|
submitFunction;
|
|
|
|
|
return (
|
|
|
|
|
<Dialog
|
|
|
|
|
open={Boolean(activeEditor)}
|
|
|
|
|
title={editorTitle()}
|
|
|
|
|
onClose={() => !busy && discardDrafts()}
|
|
|
|
|
closeDisabled={busy}
|
|
|
|
|
className="admin-dialog admin-dialog-wide organizations-editor-dialog"
|
|
|
|
|
footer={(
|
|
|
|
|
<>
|
|
|
|
|
<Button type="button" onClick={discardDrafts} disabled={busy}>i18n:govoplan-organizations.cancel_edit.309c2a6f</Button>
|
|
|
|
|
<Button type="submit" form={formId} variant="primary" disabled={editorSubmitDisabled()}>{editorTitle()}</Button>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<form id={formId} className="admin-form-grid two-columns" onSubmit={(event) => void submit(event)}>
|
|
|
|
|
{renderEditorFields()}
|
|
|
|
|
</form>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderEditorFields() {
|
|
|
|
|
if (activeEditor === "unitType") {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={unitTypeDraft} onChange={setUnitTypeDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (activeEditor === "structure") {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={structureDraft} onChange={setStructureDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.kind.794c9d9c">
|
|
|
|
|
<select value={structureDraft.structure_kind} disabled={!canWriteModel || busy} onChange={(event) => setStructureDraft({ ...structureDraft, structure_kind: event.target.value as OrganizationStructureKind })}>
|
|
|
|
|
{STRUCTURE_KINDS.map((item) => <option key={item.value} value={item.value}>{item.label}</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteModel || busy}>{editingStructureId ? "i18n:govoplan-organizations.update_structure.b2e25446" : "i18n:govoplan-organizations.add_structure.b722042a"}</Button>
|
|
|
|
|
{editingStructureId && cancelEditButton(() => { setEditingStructureId(null); setStructureDraft(emptyStructureDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.structures.f9b7f3b4">
|
|
|
|
|
<DataGrid id="organizations-structures" rows={model.structures} columns={structureColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_structures_found.20b382d0" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.relation_types.e5890528">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitRelationType(event)}>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (activeEditor === "relationType") {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={relationTypeDraft} onChange={setRelationTypeDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.structure.7732fb0b">
|
|
|
|
|
<select value={relationTypeDraft.structure_id} disabled={!canWriteModel || busy} onChange={(event) => setRelationTypeDraft({ ...relationTypeDraft, structure_id: event.target.value })}>
|
|
|
|
|
@@ -981,88 +1181,16 @@ export default function OrganizationsPage({
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<div className="organizations-check-list">
|
|
|
|
|
<label><input type="checkbox" checked={relationTypeDraft.is_hierarchical} disabled={!canWriteModel || busy} onChange={(event) => setRelationTypeDraft({ ...relationTypeDraft, is_hierarchical: event.target.checked })} /> i18n:govoplan-organizations.hierarchical.8964f313</label>
|
|
|
|
|
<label><input type="checkbox" checked={relationTypeDraft.allow_cycles} disabled={!canWriteModel || busy} onChange={(event) => setRelationTypeDraft({ ...relationTypeDraft, allow_cycles: event.target.checked })} /> i18n:govoplan-organizations.allow_cycles.31327578</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteModel || busy}>{editingRelationTypeId ? "i18n:govoplan-organizations.update_relation_type.e6e7f30c" : "i18n:govoplan-organizations.add_relation_type.2ad19d03"}</Button>
|
|
|
|
|
{editingRelationTypeId && cancelEditButton(() => { setEditingRelationTypeId(null); setRelationTypeDraft(emptyRelationTypeDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.relation_types.e5890528">
|
|
|
|
|
<DataGrid id="organizations-relation-types" rows={model.relation_types} columns={relationTypeColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_relation_types_found.6f90bb81" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.function_types.172c01fe">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitFunctionType(event)}>
|
|
|
|
|
<SluggedFields draft={functionTypeDraft} onChange={setFunctionTypeDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.unit_type.9e62810d">
|
|
|
|
|
<select value={functionTypeDraft.organization_unit_type_id} disabled={!canWriteModel || busy} onChange={(event) => setFunctionTypeDraft({ ...functionTypeDraft, organization_unit_type_id: event.target.value })}>
|
|
|
|
|
<option value="">i18n:govoplan-organizations.none.334c4a4c</option>
|
|
|
|
|
{model.unit_types.map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<div className="organizations-check-list">
|
|
|
|
|
<label><input type="checkbox" checked={functionTypeDraft.delegable} disabled={!canWriteModel || busy} onChange={(event) => setFunctionTypeDraft({ ...functionTypeDraft, delegable: event.target.checked })} /> i18n:govoplan-organizations.delegable.b4f0137d</label>
|
|
|
|
|
<label><input type="checkbox" checked={functionTypeDraft.act_in_place_allowed} disabled={!canWriteModel || busy} onChange={(event) => setFunctionTypeDraft({ ...functionTypeDraft, act_in_place_allowed: event.target.checked })} /> i18n:govoplan-organizations.act_in_place.49b942bd</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteModel || busy}>{editingFunctionTypeId ? "i18n:govoplan-organizations.update_function_type.0b7e07d3" : "i18n:govoplan-organizations.add_function_type.90d793f1"}</Button>
|
|
|
|
|
{editingFunctionTypeId && cancelEditButton(() => { setEditingFunctionTypeId(null); setFunctionTypeDraft(emptyFunctionTypeDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.function_types.172c01fe">
|
|
|
|
|
<DataGrid id="organizations-function-types" rows={model.function_types} columns={functionTypeColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_function_types_found.5eef31b1" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
<ToggleSwitch checked={relationTypeDraft.is_hierarchical} disabled={!canWriteModel || busy} onChange={(checked) => setRelationTypeDraft({ ...relationTypeDraft, is_hierarchical: checked })} label="i18n:govoplan-organizations.hierarchical.8964f313" />
|
|
|
|
|
<ToggleSwitch checked={relationTypeDraft.allow_cycles} disabled={!canWriteModel || busy} onChange={(checked) => setRelationTypeDraft({ ...relationTypeDraft, allow_cycles: checked })} label="i18n:govoplan-organizations.allow_cycles.31327578" />
|
|
|
|
|
</div>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUnitTreeNodes(parentId = "", depth = 0, seen: ReadonlySet<string> = new Set()): JSX.Element[] {
|
|
|
|
|
return (unitsByParentId.get(parentId) ?? []).flatMap((unit) => {
|
|
|
|
|
if (seen.has(unit.id)) return [];
|
|
|
|
|
const nextSeen = new Set(seen);
|
|
|
|
|
nextSeen.add(unit.id);
|
|
|
|
|
return [
|
|
|
|
|
<div className="organizations-tree-row" key={unit.id}>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className={`organizations-tree-node ${selectedUnitId === unit.id ? "active" : ""}`.trim()}
|
|
|
|
|
style={{ paddingLeft: `${10 + depth * 18}px` }}
|
|
|
|
|
onClick={() => setSelectedUnitId(unit.id)}
|
|
|
|
|
>
|
|
|
|
|
<strong>{unit.name}</strong>
|
|
|
|
|
<span>{unitTypeById.get(unit.unit_type_id || "")?.name ?? "i18n:govoplan-organizations.no_unit_type.73e799f5"}</span>
|
|
|
|
|
</button>
|
|
|
|
|
<Button type="button" variant="ghost" disabled={!canWriteUnits || busy} onClick={() => addSubunit(unit)} title="i18n:govoplan-organizations.add_subunit.8256a8f7">
|
|
|
|
|
<Plus size={16} aria-hidden="true" /> i18n:govoplan-organizations.add_subunit.8256a8f7
|
|
|
|
|
</Button>
|
|
|
|
|
</div>,
|
|
|
|
|
...renderUnitTreeNodes(unit.id, depth + 1, nextSeen)
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUnitsSection() {
|
|
|
|
|
if (activeEditor === "unit") {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-editor-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.organization_tree.e5bfb195">
|
|
|
|
|
<div className="organizations-tree-toolbar">
|
|
|
|
|
<Button type="button" variant="secondary" disabled={!canWriteUnits || busy} onClick={() => { setEditingUnitId(null); setUnitDraft(emptyUnitDraft()); }} title="i18n:govoplan-organizations.add_root_unit.1ef8a9f5">
|
|
|
|
|
<Plus size={16} aria-hidden="true" /> i18n:govoplan-organizations.add_root_unit.1ef8a9f5
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-tree-list">
|
|
|
|
|
{model.units.length ? renderUnitTreeNodes() : <p className="muted small-note">i18n:govoplan-organizations.no_units_found.eea2dd0c</p>}
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
<div className="organizations-table-stack">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.add_unit.8fa12fb1">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitUnit(event)}>
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={unitDraft} onChange={setUnitDraft} disabled={!canWriteUnits || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.unit_type.9e62810d">
|
|
|
|
|
<select value={unitDraft.unit_type_id} disabled={!canWriteUnits || busy} onChange={(event) => setUnitDraft({ ...unitDraft, unit_type_id: event.target.value })}>
|
|
|
|
|
@@ -1081,25 +1209,13 @@ export default function OrganizationsPage({
|
|
|
|
|
i18n:govoplan-organizations.selected_parent.0e013d44 <strong>{unitById.get(unitDraft.parent_id)?.name ?? unitDraft.parent_id}</strong>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteUnits || busy}>{editingUnitId ? "i18n:govoplan-organizations.update_unit.67e2500f" : "i18n:govoplan-organizations.add_unit.8fa12fb1"}</Button>
|
|
|
|
|
{editingUnitId && cancelEditButton(() => { setEditingUnitId(null); setUnitDraft(emptyUnitDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.units.e14d0d92">
|
|
|
|
|
<DataGrid id="organizations-units" rows={model.units} columns={unitColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_units_found.eea2dd0c" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderRelationsSection() {
|
|
|
|
|
if (activeEditor === "relation") {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.add_relation.6b6e67ea">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitRelation(event)}>
|
|
|
|
|
<>
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.structure.7732fb0b">
|
|
|
|
|
<select value={relationDraft.structure_id} disabled={!canWriteUnits || busy} onChange={(event) => setRelationDraft({ ...relationDraft, structure_id: event.target.value })}>
|
|
|
|
|
<option value="">i18n:govoplan-organizations.select_structure.c10f551c</option>
|
|
|
|
|
@@ -1124,28 +1240,38 @@ export default function OrganizationsPage({
|
|
|
|
|
{model.units.map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<label className="organizations-inline-check wide">
|
|
|
|
|
<input type="checkbox" checked={relationDraft.is_active} disabled={!canWriteUnits || busy} onChange={(event) => setRelationDraft({ ...relationDraft, is_active: event.target.checked })} />
|
|
|
|
|
<span>i18n:govoplan-organizations.active.a733b809</span>
|
|
|
|
|
</label>
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteUnits || busy}>{editingRelationId ? "i18n:govoplan-organizations.update_relation.4c44ce83" : "i18n:govoplan-organizations.add_relation.6b6e67ea"}</Button>
|
|
|
|
|
{editingRelationId && cancelEditButton(() => { setEditingRelationId(null); setRelationDraft(emptyRelationDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.relations.1c796711">
|
|
|
|
|
<DataGrid id="organizations-relations" rows={model.relations} columns={relationColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_relations_found.4e75b11d" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
<div className="wide">
|
|
|
|
|
<ToggleSwitch
|
|
|
|
|
checked={relationDraft.is_active}
|
|
|
|
|
disabled={!canWriteUnits || busy}
|
|
|
|
|
onChange={(checked) => setRelationDraft({ ...relationDraft, is_active: checked })}
|
|
|
|
|
label="i18n:govoplan-organizations.active.a733b809"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderFunctionsSection() {
|
|
|
|
|
if (activeEditor === "functionType") {
|
|
|
|
|
return (
|
|
|
|
|
<div className="organizations-section-grid">
|
|
|
|
|
<Card title="i18n:govoplan-organizations.add_function.6abafee0">
|
|
|
|
|
<form className="organizations-form-grid" onSubmit={(event) => void submitFunction(event)}>
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={functionTypeDraft} onChange={setFunctionTypeDraft} disabled={!canWriteModel || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.unit_type.9e62810d">
|
|
|
|
|
<select value={functionTypeDraft.organization_unit_type_id} disabled={!canWriteModel || busy} onChange={(event) => setFunctionTypeDraft({ ...functionTypeDraft, organization_unit_type_id: event.target.value })}>
|
|
|
|
|
<option value="">i18n:govoplan-organizations.none.334c4a4c</option>
|
|
|
|
|
{model.unit_types.map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<div className="organizations-check-list">
|
|
|
|
|
<ToggleSwitch checked={functionTypeDraft.delegable} disabled={!canWriteModel || busy} onChange={(checked) => setFunctionTypeDraft({ ...functionTypeDraft, delegable: checked })} label="i18n:govoplan-organizations.delegable.b4f0137d" />
|
|
|
|
|
<ToggleSwitch checked={functionTypeDraft.act_in_place_allowed} disabled={!canWriteModel || busy} onChange={(checked) => setFunctionTypeDraft({ ...functionTypeDraft, act_in_place_allowed: checked })} label="i18n:govoplan-organizations.act_in_place.49b942bd" />
|
|
|
|
|
</div>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SluggedFields draft={functionDraft} onChange={setFunctionDraft} disabled={!canWriteFunctions || busy} />
|
|
|
|
|
<FormField label="i18n:govoplan-organizations.unit.8fe4d595">
|
|
|
|
|
<select value={functionDraft.organization_unit_id} disabled={!canWriteFunctions || busy} onChange={(event) => setFunctionDraft({ ...functionDraft, organization_unit_id: event.target.value })}>
|
|
|
|
|
@@ -1160,19 +1286,11 @@ export default function OrganizationsPage({
|
|
|
|
|
</select>
|
|
|
|
|
</FormField>
|
|
|
|
|
<div className="organizations-check-list">
|
|
|
|
|
<label><input type="checkbox" checked={functionDraft.delegable} disabled={!canWriteFunctions || busy} onChange={(event) => setFunctionDraft({ ...functionDraft, delegable: event.target.checked })} /> i18n:govoplan-organizations.delegable.b4f0137d</label>
|
|
|
|
|
<label><input type="checkbox" checked={functionDraft.act_in_place_allowed} disabled={!canWriteFunctions || busy} onChange={(event) => setFunctionDraft({ ...functionDraft, act_in_place_allowed: event.target.checked })} /> i18n:govoplan-organizations.act_in_place.49b942bd</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="organizations-form-actions wide">
|
|
|
|
|
<Button type="submit" variant="primary" disabled={!canWriteFunctions || busy}>{editingFunctionId ? "i18n:govoplan-organizations.update_function.504f03e5" : "i18n:govoplan-organizations.add_function.6abafee0"}</Button>
|
|
|
|
|
{editingFunctionId && cancelEditButton(() => { setEditingFunctionId(null); setFunctionDraft(emptyFunctionDraft()); })}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card title="i18n:govoplan-organizations.functions.805dc49b">
|
|
|
|
|
<DataGrid id="organizations-functions" rows={model.functions} columns={functionColumns} getRowKey={(row) => row.id} emptyText="i18n:govoplan-organizations.no_functions_found.54e759a0" initialFit="container" />
|
|
|
|
|
</Card>
|
|
|
|
|
<ToggleSwitch checked={functionDraft.delegable} disabled={!canWriteFunctions || busy} onChange={(checked) => setFunctionDraft({ ...functionDraft, delegable: checked })} label="i18n:govoplan-organizations.delegable.b4f0137d" />
|
|
|
|
|
<ToggleSwitch checked={functionDraft.act_in_place_allowed} disabled={!canWriteFunctions || busy} onChange={(checked) => setFunctionDraft({ ...functionDraft, act_in_place_allowed: checked })} label="i18n:govoplan-organizations.act_in_place.49b942bd" />
|
|
|
|
|
</div>
|
|
|
|
|
{renderChangeRequestField()}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|