From f4067cf7caae92a9b039612e426d05eebf52218a Mon Sep 17 00:00:00 2001 From: Anna Khismatullina Date: Thu, 26 Dec 2024 16:12:54 +0700 Subject: [PATCH 1/2] Fix default status categories for imported project types Signed-off-by: Anna Khismatullina --- packages/importer/src/importer/importer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/importer/src/importer/importer.ts b/packages/importer/src/importer/importer.ts index 571e6fc786..a7483a07be 100644 --- a/packages/importer/src/importer/importer.ts +++ b/packages/importer/src/importer/importer.ts @@ -229,7 +229,13 @@ export class WorkspaceImporter { kind: 'both', name: taskType.name, ofClass: tracker.class.Issue, - statusCategories: [task.statusCategory.Active], + statusCategories: [ + task.statusCategory.UnStarted, + task.statusCategory.ToDo, + task.statusCategory.Active, + task.statusCategory.Won, + task.statusCategory.Lost + ], statusClass: tracker.class.IssueStatus, icon: tracker.icon.Issue, color: 0, From 6dec634cbe4965f6ac7b28a0548fef993352ca40 Mon Sep 17 00:00:00 2001 From: Anna Khismatullina Date: Wed, 25 Dec 2024 20:45:15 +0700 Subject: [PATCH 2/2] Ability to move task states between categories Signed-off-by: Anna Khismatullina --- .../state/StatesProjectEditor.svelte | 84 +++++++++++++++---- .../taskTypes/TaskTypeEditor.svelte | 9 ++ 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/plugins/task-resources/src/components/state/StatesProjectEditor.svelte b/plugins/task-resources/src/components/state/StatesProjectEditor.svelte index ac0793e3db..d0f2a62d3c 100644 --- a/plugins/task-resources/src/components/state/StatesProjectEditor.svelte +++ b/plugins/task-resources/src/components/state/StatesProjectEditor.svelte @@ -35,32 +35,73 @@ let dragState: Ref let opened: Ref | undefined - function dragswap (ev: MouseEvent, i: number): boolean { + function dragswap (ev: MouseEvent, i: number, targetCategory: Ref): boolean { if (readonly) return false const s = selected as number - if (i < s) { - return ev.offsetY < elements[i].offsetHeight / 2 - } else if (i > s) { - return ev.offsetY > elements[i].offsetHeight / 2 + const sourceState = states[s] + const sourceCategory = sourceState.category + + if (sourceCategory === targetCategory) { + if (i < s) { + return ev.offsetY < elements[i].offsetHeight / 2 + } else if (i > s) { + return ev.offsetY > elements[i].offsetHeight / 2 + } + } else { + return true } return false } - function dragover (ev: MouseEvent, i: number): void { + function dragover (ev: MouseEvent, i: number, targetCategory: Ref): void { if (readonly) return const s = selected as number - if (dragswap(ev, i)) { + + if (dragswap(ev, i, targetCategory)) { ;[states[i], states[s]] = [states[s], states[i]] selected = i } } - function onMove (to: number): void { + function moveState (i: number): void { + if (readonly || selected === undefined || i === selected) return + + // Get state to move + const stateToMove = states[selected] + + // Remove state from old position + states.splice(selected, 1) + + // Adjust target index if moving forward + const targetIndex = i > selected ? i - 1 : i + + // Insert state at new position + states.splice(targetIndex, 0, stateToMove) + + // Update selected index + selected = targetIndex + } + + function onMove (to: number, targetCategory: Ref): void { if (readonly) return - dispatch('move', { - stateID: dragState, - position: to - }) + + const state = $statusStore.byId.get(dragState) + + if (state !== undefined && state.category !== targetCategory) { + const newStates = states.filter((s) => s._id !== dragState) + newStates.splice(to, 0, state) + + dispatch('move', { + stateID: dragState, + position: to, + newCategory: targetCategory + }) + } else { + dispatch('move', { + stateID: dragState, + position: to + }) + } } let categories: StatusCategory[] = [] @@ -150,6 +191,21 @@