Merge pull request #109 from apuc/select-priority-column

Select priority column
This commit is contained in:
NikoM1k 2023-06-27 18:36:42 +03:00 committed by GitHub
commit 73bcd58d05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 257 additions and 43 deletions

View File

@ -335,7 +335,9 @@ export const ModalTiсket = ({
}, [members]); }, [members]);
function copyProjectLink() { function copyProjectLink() {
navigator.clipboard.writeText(`https://itguild.info/tracker/project/${projectId}`) navigator.clipboard.writeText(
`https://itguild.info/tracker/project/${projectId}`
);
} }
return ( return (

View File

@ -211,7 +211,9 @@ export const TicketFullScreen = () => {
}; };
function copyTicketLink() { function copyTicketLink() {
navigator.clipboard.writeText(`https://itguild.info/tracker/task/${taskInfo.id}`) navigator.clipboard.writeText(
`https://itguild.info/tracker/task/${taskInfo.id}`
);
} }
return ( return (

View File

@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { getProfileInfo } from "@redux/outstaffingSlice";
import { import {
addPersonToProject, addPersonToProject,
editColumnName, editColumnName,
@ -35,12 +36,14 @@ export const TrackerModal = ({
titleProject, titleProject,
projectId, projectId,
priorityTask, priorityTask,
projectUsers,
}) => { }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const projectBoard = useSelector(getProjectBoard); const projectBoard = useSelector(getProjectBoard);
const columnName = useSelector(getColumnName); const columnName = useSelector(getColumnName);
const columnId = useSelector(getColumnId); const columnId = useSelector(getColumnId);
const columnPriority = useSelector(getColumnPriority); const columnPriority = useSelector(getColumnPriority);
const profileInfo = useSelector(getProfileInfo);
const modalType = useSelector(getValueModalType); const modalType = useSelector(getValueModalType);
const [projectName, setProjectName] = useState(defautlInput); const [projectName, setProjectName] = useState(defautlInput);
@ -51,8 +54,16 @@ export const TrackerModal = ({
const [workers, setWorkers] = useState([]); const [workers, setWorkers] = useState([]);
const [selectWorkersOpen, setSelectWorkersOpen] = useState(false); const [selectWorkersOpen, setSelectWorkersOpen] = useState(false);
const [selectedWorker, setSelectedWorker] = useState(null); const [selectedWorker, setSelectedWorker] = useState(null);
const [selectColumnPriority, setSelectColumnPriority] = useState('Выберите приоритет колонки') const [selectColumnPriority, setSelectColumnPriority] = useState(
const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] = useState(false) "Выберите приоритет колонки"
);
const [selectedExecutorTask, setSelectedExecutorTask] = useState(
"Выберите исполнителя задачи"
);
const [selectExecutorTaskOpen, setSelectExecutorTaskOpen] = useState(false);
const [correctProjectUsers, setCorrectProjectUsers] = useState([]);
const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] =
useState(false);
function createTab() { function createTab() {
if (!valueColumn) { if (!valueColumn) {
@ -91,13 +102,28 @@ export const TrackerModal = ({
column_id: selectedTab, column_id: selectedTab,
priority: priorityTask, priority: priorityTask,
}, },
}).then((res) => {
if (selectedExecutorTask.user_id) {
apiRequest("/task/update-task", {
method: "PUT",
data: {
task_id: res.id,
executor_id: selectedExecutorTask.user_id,
},
}).then(() => { }).then(() => {
dispatch(setProjectBoardFetch(projectBoard.id)); dispatch(setProjectBoardFetch(projectBoard.id));
});
setActive(false); setActive(false);
setValueTiket(""); setValueTiket("");
setDescriptionTicket(""); setDescriptionTicket("");
setSelectedExecutorTask("Выберите исполнителя задачи");
});
} else {
setActive(false);
setValueTiket("");
setDescriptionTicket("");
dispatch(setProjectBoardFetch(projectBoard.id));
}
});
} }
function editProject() { function editProject() {
@ -211,6 +237,26 @@ export const TrackerModal = ({
); );
}) })
: ""; : "";
if (
localStorage.getItem("role_status") !== "18" &&
projectUsers &&
Boolean(
!projectUsers.find((item) => item.user_id === profileInfo.id_user)
)
) {
setCorrectProjectUsers([
...projectUsers,
{
user: {
avatar: profileInfo.photo,
fio: profileInfo.fio,
},
user_id: profileInfo.id_user,
},
]);
} else {
setCorrectProjectUsers(projectUsers);
}
}, [active]); }, [active]);
return ( return (
@ -280,7 +326,7 @@ export const TrackerModal = ({
</div> </div>
)} )}
{modalType === "createTiketProject" && ( {modalType === "createTiketProject" && (
<div> <>
<div className="title-project"> <div className="title-project">
<h4>Введите название и описание задачи</h4> <h4>Введите название и описание задачи</h4>
<div className="input-container"> <div className="input-container">
@ -299,11 +345,59 @@ export const TrackerModal = ({
placeholder="Описание задачи" placeholder="Описание задачи"
/> />
</div> </div>
<div
onClick={() => setSelectExecutorTaskOpen(!selectExecutorTaskOpen)}
className={
selectExecutorTaskOpen
? "select__executor select__executor--open"
: "select__executor"
}
>
<div className="selected__executor">
{selectedExecutorTask.user_id ? (
<>
<span>{selectedExecutorTask.user.fio}</span>
<img
className="avatar"
src={urlForLocal(selectedExecutorTask.user.avatar)}
alt="avatar"
/>
</>
) : (
<span>{selectedExecutorTask}</span>
)}
</div>
<img className="arrow" src={arrowDown} alt="arrow" />
{selectExecutorTaskOpen && (
<div className="select__executor__dropDown">
{correctProjectUsers.length ? (
correctProjectUsers.map((person) => {
return (
<div
onClick={() => setSelectedExecutorTask(person)}
className="executor"
key={person.user_id}
>
<span>{person.user.fio}</span>
<img
className="avatar"
src={urlForLocal(person.user.avatar)}
alt="avatar"
/>
</div>
);
})
) : (
<span>Нет пользователей</span>
)}
</div>
)}
</div>
</div> </div>
<BaseButton styles={"button-add"} onClick={createTiket}> <BaseButton styles={"button-add"} onClick={createTiket}>
Создать Создать
</BaseButton> </BaseButton>
</div> </>
)} )}
{modalType === "editProject" && ( {modalType === "editProject" && (
<div> <div>
@ -386,19 +480,35 @@ export const TrackerModal = ({
/> />
</div> </div>
<h4>Приоритет колонки</h4> <h4>Приоритет колонки</h4>
<div className='select-priority' onClick={() => setSelectColumnPriorityOpen(!selectColumnPriorityOpen)}> <div
className={
selectColumnPriorityOpen
? "select-priority select-priority--open"
: "select-priority"
}
onClick={() =>
setSelectColumnPriorityOpen(!selectColumnPriorityOpen)
}
>
<span>{selectColumnPriority}</span> <span>{selectColumnPriority}</span>
<img src={arrowDown} alt='arrow' /> <img src={arrowDown} alt="arrow" />
{selectColumnPriorityOpen && {selectColumnPriorityOpen && (
<div className='select-priority__dropDown'> <div className="select-priority__dropDown">
{projectBoard.columns.map((column, index) => { {projectBoard.columns.map((column, index) => {
return <span key={column.id} onClick={() => { return (
setSelectColumnPriority(index + 1) <span
dispatch(setColumnPriority(index + 1)) key={column.id}
}}>{index + 1}</span> onClick={() => {
setSelectColumnPriority(index + 1);
dispatch(setColumnPriority(index + 1));
}}
>
{index + 1}
</span>
);
})} })}
</div> </div>
} )}
</div> </div>
{/*<div className="input-container">*/} {/*<div className="input-container">*/}
{/* <input*/} {/* <input*/}

View File

@ -48,6 +48,7 @@
img { img {
width: 15px; width: 15px;
height: 15px; height: 15px;
transition: all 0.3s ease;
} }
&__dropDown { &__dropDown {
@ -68,6 +69,12 @@
} }
} }
} }
&--open {
img {
transform: rotate(180deg);
}
}
} }
.input-container { .input-container {
@ -75,13 +82,83 @@
height: 35px; height: 35px;
background: #ffffff; background: #ffffff;
border-radius: 8px; border-radius: 8px;
margin: 12px 0; margin: 5px 0;
input::-webkit-inner-spin-button { input::-webkit-inner-spin-button {
-webkit-appearance: none; -webkit-appearance: none;
} }
} }
.select__executor {
width: 287px;
background: white;
border-radius: 8px;
margin: 5px 0;
display: flex;
justify-content: space-between;
align-items: center;
padding: 9.5px 12px;
font-size: 14px;
cursor: pointer;
position: relative;
.arrow {
transition: all 0.3s ease;
width: 16px;
height: 16px;
}
&--open {
.arrow {
transform: rotate(180deg);
}
}
.selected__executor {
display: flex;
align-items: center;
span {
max-width: 205px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
img {
margin-left: 15px;
}
}
.avatar {
width: 20px;
height: 20px;
}
&__dropDown {
position: absolute;
background: white;
border-radius: 8px;
top: 50px;
left: 0;
width: 100%;
padding: 9.5px 12px;
display: flex;
flex-direction: column;
row-gap: 10px;
.executor {
display: flex;
justify-content: space-between;
&:hover {
span {
font-weight: 600;
}
}
}
}
}
h4 { h4 {
font-weight: 500; font-weight: 500;
font-size: 22px; font-size: 22px;

View File

@ -53,7 +53,9 @@ export const ProjectTiket = ({ project, index }) => {
} }
function copyProjectLink() { function copyProjectLink() {
navigator.clipboard.writeText(`https://itguild.info/tracker/project/${project.id}`) navigator.clipboard.writeText(
`https://itguild.info/tracker/project/${project.id}`
);
} }
return ( return (

View File

@ -291,6 +291,7 @@ export const ProjectTracker = () => {
setActive={setModalAdd} setActive={setModalAdd}
selectedTab={selectedTab} selectedTab={selectedTab}
priorityTask={priorityTask} priorityTask={priorityTask}
projectUsers={projectBoard.projectUsers}
/> />
{loader && <Loader style="green" />} {loader && <Loader style="green" />}
@ -324,12 +325,26 @@ export const ProjectTracker = () => {
<span className="countPersons"> <span className="countPersons">
{projectBoard.projectUsers?.length} {projectBoard.projectUsers?.length}
</span> </span>
<div className='projectPersons'> <div className="projectPersons">
{projectBoard.projectUsers?.length && {projectBoard.projectUsers?.length &&
projectBoard.projectUsers.slice(0, projectBoard.length > 3 ? 3 : projectBoard.length).map((person) => { projectBoard.projectUsers
return <img key={person.user_id} src={person.user?.avatar ? urlForLocal(person.user.avatar) : avatarMok} alt='avatar' /> .slice(
}) 0,
projectBoard.length > 3 ? 3 : projectBoard.length
)
.map((person) => {
return (
<img
key={person.user_id}
src={
person.user?.avatar
? urlForLocal(person.user.avatar)
: avatarMok
} }
alt="avatar"
/>
);
})}
</div> </div>
<span <span
className="addPerson" className="addPerson"
@ -524,15 +539,21 @@ export const ProjectTracker = () => {
className="tasks__board__item__description" className="tasks__board__item__description"
></p> ></p>
<div className="tasks__board__item__executor"> <div className="tasks__board__item__executor">
<span>{task.executor?.fio ? task.executor?.fio : 'Исполнитель не назначен'}</span> <span>
{task.executor?.avatar && {task.executor?.fio
? task.executor?.fio
: "Исполнитель не назначен"}
</span>
{task.executor?.avatar && (
<img <img
src={ src={
task.executor?.avatar ? urlForLocal(task.executor?.avatar) : avatarMok task.executor?.avatar
? urlForLocal(task.executor?.avatar)
: avatarMok
} }
alt="avatar" alt="avatar"
/> />
} )}
</div> </div>
<div className="tasks__board__item__info"> <div className="tasks__board__item__info">
<div className="tasks__board__item__info__more"> <div className="tasks__board__item__info__more">