From 5b600010139837baff9948965363a8265ecca6de Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 21 Nov 2023 16:40:58 +0300 Subject: [PATCH] task priority --- .../Modal/Tracker/ModalTicket/ModalTicket.jsx | 61 +++++++ .../Tracker/ModalTicket/modalTicket.scss | 58 +++++++ .../TicketFullScreen/TicketFullScreen.jsx | 150 +++++++++++++----- .../Tracker/TrackerModal/TrackerModal.jsx | 48 +++++- .../Tracker/TrackerModal/trackerModal.scss | 51 ++++++ src/pages/ProjectTracker/ProjectTracker.js | 19 +++ src/pages/Tracker/tracker.scss | 30 ++++ 7 files changed, 372 insertions(+), 45 deletions(-) diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index 8a142760..f076e7e6 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -75,6 +75,7 @@ export const ModalTiсket = ({ const [dropListOpen, setDropListOpen] = useState(false); const [dropListMembersOpen, setDropListMembersOpen] = useState(false); const [executor, setExecutor] = useState(task.executor); + const [taskPriority, setTaskPriority] = useState(task.execution_priority) const [members, setMembers] = useState(task.taskUsers); const [taskTags, setTaskTags] = useState(task.mark); const [users, setUsers] = useState([]); @@ -94,6 +95,7 @@ export const ModalTiсket = ({ const profileInfo = useSelector(getProfileInfo); const [acceptModalOpen, setAcceptModalOpen] = useState(false); const [selectTagsOpen, setSelectTagsOpen] = useState(false); + const [selectPriorityOpen, setSelectPriorityOpen] = useState(false) const { showNotification } = useNotification(); const [commentSendDisable, setCommentSendDisable] = useState(false); @@ -115,6 +117,28 @@ export const ModalTiсket = ({ }); } + const priority = + { + 2: 'Высокий', + 1: 'Средний', + 0: 'Низкий' + } + + const priorityTypes = [ + { + name: 'Высокий', + key: 2 + }, + { + name: 'Средний', + key: 1 + }, + { + name: 'Низкий', + key: 0 + }, + ] + function archiveTask() { setAcceptModalOpen(true); } @@ -262,6 +286,19 @@ export const ModalTiсket = ({ }); } + function updateTaskPriority(key) { + setSelectPriorityOpen(false) + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: task.id, + execution_priority: key + }, + }).then(() => { + dispatch(setProjectBoardFetch(projectId)); + }); + } + function addMember(person) { apiRequest("/task/add-user-to-task", { method: "POST", @@ -969,6 +1006,30 @@ export const ModalTiсket = ({ )} +
+
setSelectPriorityOpen(!selectPriorityOpen)}> + {typeof taskPriority === "number" ? priority[taskPriority] : 'Выберете приоритет'} + arrow +
+ {selectPriorityOpen && +
+ {priorityTypes.map((item) => { + return
{ + setTaskPriority(item.key) + updateTaskPriority(item.key) + }} + >{item.name}
+ })} +
+ } +
{ const [startDate, setStartDate] = useState(null); const [uploadedFile, setUploadedFile] = useState(null); const [taskFiles, setTaskFiles] = useState([]); + const [taskPriority, setTaskPriority] = useState("") const [acceptModalOpen, setAcceptModalOpen] = useState(false); const [taskTags, setTaskTags] = useState([]); const [selectTagsOpen, setSelectTagsOpen] = useState(false); + const [selectPriorityOpen, setSelectPriorityOpen] = useState(false) const [correctProjectTags, setCorrectProjectTags] = useState([]); const { showNotification } = useNotification(); const [commentSendDisable, setCommentSendDisable] = useState(false); + const priority = { + 2: 'Высокий', + 1: 'Средний', + 0: 'Низкий' + } + + const priorityTypes = [ + { + name: 'Высокий', + key: 2 + }, + { + name: 'Средний', + key: 1 + }, + { + name: 'Низкий', + key: 0 + }, + ] + useEffect(() => { initListeners(); apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then( (taskInfo) => { setTaskInfo(taskInfo); setDeadLine(taskInfo.dead_line); + setTaskPriority(taskInfo.execution_priority) setStartDate( taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() ); @@ -484,6 +508,18 @@ export const TicketFullScreen = () => { setUploadedFile(null); } + function updateTaskPriority(key) { + setSelectPriorityOpen(false) + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + execution_priority: key + }, + }).then(() => { + }); + } + // function deleteFile(file) { // apiRequest("/file/detach", { // method: "DELETE", @@ -1103,65 +1139,91 @@ export const TicketFullScreen = () => { )}
- -
+
{taskTags.map((tag) => { return ( -
-

{tag.slug}

- delete deleteTagFromTask(tag.id)} - /> -
+
+

{tag.slug}

+ delete deleteTagFromTask(tag.id)} + /> +
); })}
setSelectTagsOpen(!selectTagsOpen)} + className="tags__select" + onClick={() => setSelectTagsOpen(!selectTagsOpen)} > Выберете тег arrow
{selectTagsOpen && ( -
- setSelectTagsOpen(false)} - className="tags__dropDown__close" - src={close} - alt="close" - /> - {correctProjectTags.map((tag) => { - return ( -
addTagToTask(tag.id)} - > -

{tag.slug}

- -
- ); - })} - {!Boolean(correctProjectTags.length) && ( -

Нет тегов

- )} -
+
+ setSelectTagsOpen(false)} + className="tags__dropDown__close" + src={close} + alt="close" + /> + {correctProjectTags.map((tag) => { + return ( +
addTagToTask(tag.id)} + > +

{tag.slug}

+ +
+ ); + })} + {!Boolean(correctProjectTags.length) && ( +

Нет тегов

+ )} +
)}
+
+ +
+
setSelectPriorityOpen(!selectPriorityOpen)}> + {typeof taskPriority === "number" ? priority[taskPriority] : 'Выберете приоритет'} + arrow +
+ {selectPriorityOpen && +
+ {priorityTypes.map((item) => { + return
{ + setTaskPriority(item.key) + updateTaskPriority(item.key) + }} + >{item.name}
+ })} +
+ } +
+
{ diff --git a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx index ff2a4073..14b793dd 100644 --- a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx +++ b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx @@ -32,7 +32,6 @@ import { getCorrectDate } from "@components/Calendar/calendarHelper"; import BaseButton from "@components/Common/BaseButton/BaseButton"; import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; -import arrowCreateTask from "assets/icons/arrows/arrowCreateTask.svg"; import arrowRight from "assets/icons/arrows/arrowRightCreateTask.svg"; import arrowDown from "assets/icons/arrows/selectArrow.png"; import close from "assets/icons/close.png"; @@ -82,6 +81,8 @@ export const TrackerModal = ({ const [correctProjectTags, setCorrectProjectTags] = useState([]); const [taskTags, setTaskTags] = useState([]); const [selectTagsOpen, setSelectTagsOpen] = useState(false); + const [selectedPriority, setSelectedPriority] = useState(null) + const [selectPriority, setSelectPriority] = useState(false) const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] = useState(false); const { showNotification } = useNotification(); @@ -89,6 +90,21 @@ export const TrackerModal = ({ const [datePickerOpen, setDatePickerOpen] = useState(false); const [startDate, setStartDate] = useState(new Date()); + const priority = [ + { + name: 'Высокий', + key: 2 + }, + { + name: 'Средний', + key: 1 + }, + { + name: 'Низкий', + key: 0 + }, + ] + function createTab() { if (!valueColumn) { showNotification({ show: true, text: "Введите название", type: "error" }); @@ -130,6 +146,7 @@ export const TrackerModal = ({ status: 1, user_id: localStorage.getItem("id"), column_id: selectedTab, + execution_priority: selectedPriority ? selectedPriority.key : '', priority: priorityTask, dead_line: deadLineDate ? getCorrectRequestDate(deadLineDate) : "", }, @@ -166,6 +183,7 @@ export const TrackerModal = ({ setValueTiket(""); setDescriptionTicket(""); setSelectedExecutorTask("Выберите исполнителя задачи"); + setSelectedPriority(null) }); } else { setActive(false); @@ -587,6 +605,34 @@ export const TrackerModal = ({
)}
+
+
setSelectPriority(!selectPriority)} + > + {selectedPriority ? `Приоритет: ${selectedPriority.name}` : 'Выберети приоритет'} + arrow +
+ {selectPriority && +
+ {priority.map((item) => { + return
{ + setSelectPriority(false) + setSelectedPriority(item) + }} + >{item.name}
+ })} +
+ } +
setSelectExecutorTaskOpen(!selectExecutorTaskOpen) diff --git a/src/components/Modal/Tracker/TrackerModal/trackerModal.scss b/src/components/Modal/Tracker/TrackerModal/trackerModal.scss index d8195de7..836324b7 100644 --- a/src/components/Modal/Tracker/TrackerModal/trackerModal.scss +++ b/src/components/Modal/Tracker/TrackerModal/trackerModal.scss @@ -520,6 +520,57 @@ } } + .select__priority { + position: relative; + + &__name { + color: #000; + width: 393px; + height: 47px; + font-size: 15px; + font-weight: 400; + line-height: normal; + cursor: pointer; + display: flex; + align-items: center; + justify-content: space-between; + padding: 9.5px 12px; + border-radius: 8px; + height: 47px; + border: 1px solid #e4e4e4; + margin-bottom: 10px; + } + + &__dropDown { + position: absolute; + border-radius: 8px; + padding: 9.5px 12px; + display: flex; + flex-direction: column; + row-gap: 5px; + width: 100%; + background: #f1f1f1; + z-index: 101; + + .dropdown__item { + font-size: 16px; + cursor: pointer; + + &:hover { + font-weight: 700; + } + } + } + + img { + transition: all 0.3s ease; + } + + .arrow--open { + transform: rotate(180deg); + } + } + .select__executor { background: #f1f1f1; width: 393px; diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index f3e42392..4552b6c9 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -90,6 +90,19 @@ export const ProjectTracker = () => { const loader = useSelector(getBoarderLoader); const { showNotification } = useNotification(); + const priority = + { + 2: 'Высокий', + 1: 'Средний', + 0: 'Низкий' + } + + const priorityClass = { + 2: 'high', + 1: 'middle', + 0: 'low' + } + useEffect(() => { dispatch(activeLoader()); dispatch(setProjectBoardFetch(projectId.id)); @@ -998,6 +1011,12 @@ export const ProjectTracker = () => { })}
)} + {typeof task.execution_priority === "number" && +
+

Приоритет:

+ {priority[task.execution_priority]} +
+ } {task.dead_line && (

Срок исполнения:

diff --git a/src/pages/Tracker/tracker.scss b/src/pages/Tracker/tracker.scss index 92942a87..80cfcb4a 100644 --- a/src/pages/Tracker/tracker.scss +++ b/src/pages/Tracker/tracker.scss @@ -1124,6 +1124,36 @@ } } + &__priority { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + + + p { + font-weight: 500; + font-size: 14px; + } + + span { + font-weight: 500; + font-size: 14px; + } + + .high { + color: red; + } + + .middle { + color: #cece00; + } + + .low { + color: green; + } + } + &__deadLine { display: flex; align-items: center;