/* Парус 8 - Панели мониторинга - УДП - Доски задач Панель мониторинга: Корневая панель доски задач */ //--------------------- //Подключение библиотек //--------------------- import React, { useState } from "react"; //Классы React import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; import { Stack, Card, CardHeader, CardContent, Typography, Box, Button, IconButton, Icon } from "@mui/material"; //Интерфейсные компоненты //import { Draggable } from "react-draggable"; //--------- //Константы //--------- const STYLES = { CONTAINER: { width: "100%", padding: 1 }, DEF_SIZE: { minWidth: "200px", minHeight: "100px" }, SETTINGS_BUTTON: { position: "absolute", right: 8, top: 8, color: theme => theme.palette.grey[500] } }; //----------- //Тело модуля //----------- //Корневая панель доски задач const ClntTaskBoard = () => { const [categories, setCategories] = useState([ { id: 1, name: "Новое" }, { id: 2, name: "Старое" } ]); const [tasks, setTasks] = useState([ { id: 1, name: "Задание1", category: 1 }, { id: 2, name: "Задание2", category: 1 }, { id: 3, name: "Задание3", category: 2 }, { id: 4, name: "Задание4", category: 2 } ]); const onDragEnd = result => { const { source, destination } = result; if (!destination) { return; } if (destination.droppableId === "Categories") { setCategories(categories); } else if (destination.droppableId !== source.droppableId) { setTasks(tasks => tasks.map(task => task.id === parseInt(result.draggableId) ? { ...task, category: parseInt(result.destination.droppableId) } : task ) ); } else { setTasks(tasks); } }; return (
{provided => (
{categories.map((category, index) => (
{provided => (
{ console.log("Опции типа"); }} > more_vert } title={category.name} subheader={ } sx={{ padding: 0 }} /> {tasks .filter(item => item.category === category.id) .map((item, index) => ( {provided => ( { console.log("Опции задачи"); }} > more_vert } title={ {item.id} {item.name} } sx={{ padding: 0 }} /> )} ))} {provided.placeholder}
)}
))}
{provided.placeholder}
)}
); }; //---------------- //Интерфейс модуля //---------------- export { ClntTaskBoard };