@progress/kendo-react-gantt
Version:
React Gantt enables the display of self-referencing tabular data with many features. KendoReact Gantt package
110 lines (109 loc) • 3.78 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as n from "react";
import { findByFieldValue as u, DropDownList as T } from "@progress/kendo-react-dropdowns";
import { Grid as k, GridToolbar as v, GridColumn as C } from "@progress/kendo-react-grid";
import { Button as D } from "@progress/kendo-react-buttons";
import { plusIcon as S, minusIcon as b } from "@progress/kendo-svg-icons";
import { classNames as E } from "@progress/kendo-react-common";
import { messages as M, editorAdd as I, editorRemove as L, editorDependencyNameLabel as N, editorDependencyTypeLabel as R } from "../messages/index.mjs";
import { useLocalization as F } from "@progress/kendo-react-intl";
import { orderBy as B, filterBy as G } from "@progress/kendo-data-query";
const P = (e, t, l, o) => {
const [i, d] = n.useState(e), r = n.useRef(null), c = (a) => {
o(t, "fromId", a.target.value.id);
}, f = () => {
if (l && !t.uid)
return l.id === t.id;
if (l && t.id === null)
return l.uid === t.uid;
}, y = n.useMemo(
() => u(e, "id", t.fromId),
[e, t.fromId]
), m = (a) => {
const s = G(e, a.filter);
d(s);
};
return /* @__PURE__ */ n.createElement("td", { ref: r, className: E(f() && "k-selected") }, /* @__PURE__ */ n.createElement(
T,
{
textField: "title",
data: i,
value: y,
onChange: c,
filterable: !0,
onFilterChange: m,
required: !0
}
));
}, w = (e, t, l, o) => {
const i = (c) => {
o(t, "type", c.target.value.type);
}, d = () => {
if (l && !t.uid)
return l.id === t.id;
if (l && t.id === null)
return l.uid === t.uid;
}, r = n.useMemo(() => u(e, "type", t.type), [e, t.type]);
return /* @__PURE__ */ n.createElement("td", { className: E(d() && "k-selected") }, /* @__PURE__ */ n.createElement(T, { textField: "name", data: e, value: r, onChange: i }));
}, K = (e) => {
var m;
const [t, l] = n.useState([]), o = F(), i = (a) => o.toLanguageString(a, M[a]), d = i(I), r = i(L), c = i(N), f = i(R), y = n.useMemo(() => {
const a = e.predecessors.map((s) => {
const g = u(e.flatTasks, "id", s.fromId), h = u(e.dependencyTypes, "type", s.type);
return {
...s,
taskTitle: g ? g.title : "",
typeName: h ? h.type : ""
};
});
return B(a, t);
}, [e.predecessors, e.dependencyTypes, e.flatTasks, t]);
return /* @__PURE__ */ n.createElement(
k,
{
data: y,
sort: t,
sortable: !0,
onRowClick: e.onSelectRow,
onSortChange: (a) => {
l(a.sort);
},
style: { height: "23em" }
},
/* @__PURE__ */ n.createElement(v, null, /* @__PURE__ */ n.createElement(D, { icon: "plus", svgIcon: S, onClick: e.addPredecessorsDependency }, d), /* @__PURE__ */ n.createElement(
D,
{
icon: "minus",
svgIcon: b,
onClick: e.deleteDependency,
disabled: ((m = e.selectedItem) == null ? void 0 : m.id) === void 0
},
r
)),
/* @__PURE__ */ n.createElement(
C,
{
field: "taskTitle",
title: c,
cell: (a) => P(e.flatTasks, a.dataItem, e.selectedItem, e.updateDependency)
}
),
/* @__PURE__ */ n.createElement(
C,
{
field: "typeName",
title: f,
cell: (a) => w(e.dependencyTypes, a.dataItem, e.selectedItem, e.updateDependency)
}
)
);
};
export {
K as GanttEditorPredecessors
};