Skip to content

Commit

Permalink
[Timeline]: made it more useful.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Jul 29, 2024
1 parent b1c4b5b commit 272eaa6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
35 changes: 19 additions & 16 deletions app/src/demo/tables/editableTable/ProjectTableDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,25 @@ export function ProjectTableDemo() {
const taskToInsert: Task = existingTask ? { ...existingTask, type: 'task' } : { id: lastId--, name: '', type: 'task' };
const task: Task = setTaskInsertPosition(taskToInsert, relativeTask, position, treeRef.current);

let parentTask = relativeTask;
if (position === 'inside' && relativeTask.type !== 'story') {
parentTask = { ...relativeTask, type: 'story' };
}

let prevParentTask = taskToInsert.parentId === null ? null : treeRef.current.getById(taskToInsert.parentId);
if (taskToInsert.parentId !== null && prevParentTask !== null && prevParentTask !== NOT_FOUND_RECORD && taskToInsert.parentId !== task.parentId) {
const children = treeRef.current.getItems(taskToInsert.parentId);
const isSomeNotMoved = children.ids.some((id) => id !== taskToInsert.id);
if (!isSomeNotMoved) {
prevParentTask = { ...prevParentTask, type: 'task' };
setValue((currentValue) => {
let parentTask = relativeTask;
if (position === 'inside' && relativeTask.type !== 'story') {
parentTask = { ...relativeTask, type: 'story' };
}

let prevParentTask = taskToInsert.parentId === null ? null : treeRef.current.getById(taskToInsert.parentId);
if (taskToInsert.parentId !== null && prevParentTask !== null && prevParentTask !== NOT_FOUND_RECORD && taskToInsert.parentId !== task.parentId) {
const children = treeRef.current.getItems(taskToInsert.parentId);
const isSomeNotMoved = children.ids.some((id) => id !== taskToInsert.id);
if (!isSomeNotMoved) {
prevParentTask = { ...prevParentTask, type: 'task' };
}
}
}

setValue((currentValue) => {
let currentItems = currentValue.items
.set(task.id, task)
.set(parentTask.id, parentTask);

if (prevParentTask !== null && prevParentTask !== NOT_FOUND_RECORD) {
currentItems = currentItems.set(prevParentTask.id, prevParentTask);
}
Expand All @@ -178,7 +179,9 @@ export function ProjectTableDemo() {
}, [setValue, dataTableFocusManager]);

const handleDrop = useCallback(
(params: DropParams<Task, Task>) => insertTask(params.position, params.dstData, params.srcData),
(params: DropParams<Task, Task>) => {
return insertTask(params.position, params.dstData, params.srcData);
},
[insertTask],
);

Expand Down Expand Up @@ -225,14 +228,14 @@ export function ProjectTableDemo() {

const selectedItem = useMemo(() => {
if (tableState.selectedId !== undefined) {
const item = treeRef.current.getById(tableState.selectedId);
const item = tree.getById(tableState.selectedId);
if (item === NOT_FOUND_RECORD) {
return undefined;
}
return item;
}
return undefined;
}, [tableState.selectedId]);
}, [tableState.selectedId, tree]);

const deleteSelectedItem = useCallback(() => {
if (selectedItem === undefined) return;
Expand Down
14 changes: 7 additions & 7 deletions app/src/demo/tables/editableTable/demoData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import { getOrderBetween } from '@epam/uui-core';
import { Task, Resource, Status } from './types';

const tasks: Partial<Task>[] = [
{ id: 1, name: 'Infrastructure', type: 'story', startDate: '2024-11-01T00:00:00.000Z', order: 'm', estimate: 54, status: '2', dueDate: '2024-12-12T21:59:59.999Z' },
{ id: 101, name: 'Devops', type: 'story', order: 'ys', parentId: 1, estimate: 47, startDate: '2024-11-01T00:00:00.000Z', status: '2', dueDate: '2024-12-12T21:59:59.999Z' },
{ id: 102, name: 'Frontend', type: 'story', order: 'yv', parentId: 1, estimate: 7, startDate: '2024-11-01T00:00:00.000Z', status: '2', dueDate: '2024-11-07T21:59:59.999Z' },
{ id: 10101, name: 'GIT Repository init', estimate: 2, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyx', parentId: 101, exactStartDate: '2024-11-01T00:00:00.000Z', dueDate: '2024-11-02T21:59:59.999Z' },
{ id: 10103, name: 'Test instances - Dev, QA, UAT', estimate: 5, startDate: '2024-11-01', assignee: 3, status: '2', type: 'task', order: 'yyyyyyyyym', parentId: 101, exactStartDate: '2024-11-01T00:00:00.000Z' },
{ id: 10102, name: 'CI - build code, publish artifacts', estimate: 6, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyy', parentId: 101, exactStartDate: '2024-11-03T00:00:00.000Z' },
{ id: 10104, name: 'API connection & secrets management', estimate: 30, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyys', parentId: 101, exactStartDate: '2024-11-09T00:00:00.000Z' },
{ id: 10105, name: 'Production instance', estimate: 4, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyyv', parentId: 101, exactStartDate: '2024-12-09T00:00:00.000Z' },
{ id: 10201, name: 'Init CRA project', estimate: 2, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyyyyyyyyx', parentId: 102, exactStartDate: '2024-11-01T00:00:00.000Z' },
{ id: 10202, name: 'Decide and document coding practices and processes', estimate: 5, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyyyyyyyyy', parentId: 102, exactStartDate: '2024-11-03T00:00:00.000Z' },
{ id: 301, name: 'Color palette', estimate: 2, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyv', parentId: 3, exactStartDate: '2024-11-08T00:00:00.000Z' },
Expand Down Expand Up @@ -40,17 +47,10 @@ const tasks: Partial<Task>[] = [
{ id: 60703, name: 'Sales report', estimate: 6, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyyyyyyyyyv', parentId: 607, exactStartDate: '2025-05-15T00:00:00.000Z' },
{ id: 60704, name: 'Marketing dashboard', estimate: 6, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyyyyyyyyyx', parentId: 607, exactStartDate: '2025-05-21T00:00:00.000Z' },
{ id: 60705, name: 'Categories list editor', estimate: 6, startDate: '2024-11-01', assignee: 1, status: '2', type: 'task', order: 'yyyyyyyyyyy', parentId: 607, exactStartDate: '2025-05-27T00:00:00.000Z' },
{ id: 10102, name: 'CI - build code, publish artifacts', estimate: 6, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyy', parentId: 101, exactStartDate: '2024-11-03T00:00:00.000Z' },
{ id: 10104, name: 'API connection & secrets management', estimate: 30, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyys', parentId: 101, exactStartDate: '2024-11-09T00:00:00.000Z' },
{ id: 10105, name: 'Production instance', estimate: 4, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yyyyyyyyyv', parentId: 101, exactStartDate: '2024-12-09T00:00:00.000Z' },
{ id: 201, name: 'Authentication', estimate: 5, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yx', parentId: 2, exactStartDate: '2024-12-13T00:00:00.000Z' },
{ id: 202, name: 'Integration with API', estimate: 5, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yy', parentId: 2, exactStartDate: '2024-12-18T00:00:00.000Z' },
{ id: 203, name: 'Routing', estimate: 5, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yym', parentId: 2, exactStartDate: '2024-12-23T00:00:00.000Z' },
{ id: 204, name: 'Localization', estimate: 5, startDate: '2024-11-01', assignee: 2, status: '2', type: 'task', order: 'yys', parentId: 2, exactStartDate: '2024-12-28T00:00:00.000Z' },
{ id: 10103, name: 'Test instances - Dev, QA, UAT', estimate: 5, startDate: '2024-11-01', assignee: 3, status: '2', type: 'task', order: 'yyyyyyyyym', parentId: 101, exactStartDate: '2024-11-01T00:00:00.000Z' },
{ id: 1, name: 'Infrastructure', type: 'story', startDate: '2024-11-01T00:00:00.000Z', order: 'm', estimate: 54, status: '2', dueDate: '2024-12-12T21:59:59.999Z' },
{ id: 101, name: 'Devops', type: 'story', order: 'ys', parentId: 1, estimate: 47, startDate: '2024-11-01T00:00:00.000Z', status: '2', dueDate: '2024-12-12T21:59:59.999Z' },
{ id: 102, name: 'Frontend', type: 'story', order: 'yv', parentId: 1, estimate: 7, startDate: '2024-11-01T00:00:00.000Z', status: '2', dueDate: '2024-11-07T21:59:59.999Z' },
{ id: 2, name: 'Shared services', type: 'story', order: 's', estimate: 20, startDate: '2024-12-13T00:00:00.000Z', status: '2', dueDate: '2025-01-01T21:59:59.999Z' },
{ id: 3, name: 'UUI Customization', type: 'story', order: 'v', estimate: 20, startDate: '2024-11-08T00:00:00.000Z', status: '2', dueDate: '2024-11-27T21:59:59.999Z' },
{ id: 4, name: 'Shared Components', type: 'story', order: 'x', estimate: 84, startDate: '2024-11-28T00:00:00.000Z', status: '2', dueDate: '2025-02-19T21:59:59.999Z' },
Expand Down
5 changes: 0 additions & 5 deletions app/src/demo/tables/editableTable/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ export const groupByAssigneesAndIndex = (tasks: Task[]) => {
return group;
}

if (task.assignee === undefined) {
return group;
}

if (!group[task.assignee]) {
group[task.assignee] = [];
}
Expand Down Expand Up @@ -436,7 +432,6 @@ export const scheduleTasks = (
) => {
const patchedTree = patch(updatedItemsMap);
const tasks: Task[] = getOrderedTasks(patchedTree, updatedItemsMap);

const group = groupByAssigneesAndIndex(tasks);

const getTask = (t: Task): SchedulingTask<number> => ({
Expand Down

0 comments on commit 272eaa6

Please sign in to comment.