forked from CITKParus/P8-Panels
WEB APP: P8PGantt - поддержка пользовательских диалогов редактирования задачи
This commit is contained in:
parent
c6880b29ab
commit
6f55ac14da
@ -90,6 +90,32 @@ const STYLES = {
|
|||||||
//Проверка существования значения
|
//Проверка существования значения
|
||||||
const hasValue = value => typeof value !== "undefined" && value !== null && value !== "";
|
const hasValue = value => typeof value !== "undefined" && value !== null && value !== "";
|
||||||
|
|
||||||
|
//Формирование описания для легенды
|
||||||
|
const taskLegendDesc = ({ task, taskColors }) => {
|
||||||
|
if (Array.isArray(taskColors) && taskColors.length > 0) {
|
||||||
|
const colorDesc = taskColors.find(
|
||||||
|
color => task.bgColor === color.bgColor && task.textColor === color.textColor && task.bgProgressColor === color.bgProgressColor
|
||||||
|
);
|
||||||
|
if (colorDesc)
|
||||||
|
return {
|
||||||
|
text: colorDesc.desc,
|
||||||
|
style: {
|
||||||
|
...(colorDesc.bgProgressColor
|
||||||
|
? {
|
||||||
|
background: `linear-gradient(to right, ${colorDesc.bgProgressColor} ,${
|
||||||
|
colorDesc.bgColor ? colorDesc.bgColor : "transparent"
|
||||||
|
})`
|
||||||
|
}
|
||||||
|
: colorDesc.bgColor
|
||||||
|
? { backgroundColor: colorDesc.bgColor }
|
||||||
|
: {}),
|
||||||
|
...(colorDesc.textColor ? { color: colorDesc.textColor } : {})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
else return null;
|
||||||
|
} else return null;
|
||||||
|
};
|
||||||
|
|
||||||
//Редактор задачи
|
//Редактор задачи
|
||||||
const P8PGanttTaskEditor = ({
|
const P8PGanttTaskEditor = ({
|
||||||
task,
|
task,
|
||||||
@ -132,34 +158,17 @@ const P8PGanttTaskEditor = ({
|
|||||||
const handleProgressChanged = (e, newValue) => setState(prev => ({ ...prev, progress: newValue }));
|
const handleProgressChanged = (e, newValue) => setState(prev => ({ ...prev, progress: newValue }));
|
||||||
|
|
||||||
//Описание легенды для задачи
|
//Описание легенды для задачи
|
||||||
let legend = null;
|
const legendDesc = taskLegendDesc({ task, taskColors });
|
||||||
if (Array.isArray(taskColors)) {
|
let legend = legendDesc ? (
|
||||||
const colorDesc = taskColors.find(
|
|
||||||
color => task.bgColor === color.bgColor && task.textColor === color.textColor && task.bgProgressColor === color.bgProgressColor
|
|
||||||
);
|
|
||||||
if (colorDesc)
|
|
||||||
legend = (
|
|
||||||
<ListItemText
|
<ListItemText
|
||||||
secondaryTypographyProps={{
|
secondaryTypographyProps={{
|
||||||
p: 1,
|
p: 1,
|
||||||
sx: {
|
sx: legendDesc.style
|
||||||
...(colorDesc.bgProgressColor
|
|
||||||
? {
|
|
||||||
background: `linear-gradient(to right, ${colorDesc.bgProgressColor} ,${
|
|
||||||
colorDesc.bgColor ? colorDesc.bgColor : "transparent"
|
|
||||||
})}`
|
|
||||||
}
|
|
||||||
: colorDesc.bgColor
|
|
||||||
? { backgroundColor: colorDesc.bgColor }
|
|
||||||
: {}),
|
|
||||||
...(colorDesc.textColor ? { color: colorDesc.textColor } : {})
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
primary={legendCaption}
|
primary={legendCaption}
|
||||||
secondary={colorDesc.desc}
|
secondary={legendDesc.text}
|
||||||
/>
|
/>
|
||||||
);
|
) : null;
|
||||||
}
|
|
||||||
|
|
||||||
//Генерация содержимого
|
//Генерация содержимого
|
||||||
return (
|
return (
|
||||||
@ -480,4 +489,4 @@ P8PGantt.propTypes = {
|
|||||||
//Интерфейс модуля
|
//Интерфейс модуля
|
||||||
//----------------
|
//----------------
|
||||||
|
|
||||||
export { P8P_GANTT_TASK_SHAPE, P8P_GANTT_TASK_ATTRIBUTE_SHAPE, P8P_GANTT_TASK_COLOR_SHAPE, P8PGantt };
|
export { P8P_GANTT_TASK_SHAPE, P8P_GANTT_TASK_ATTRIBUTE_SHAPE, P8P_GANTT_TASK_COLOR_SHAPE, taskLegendDesc, P8PGantt };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user