diff --git a/packages/importer/src/importer/importer.ts b/packages/importer/src/importer/importer.ts index 571e6fc786c..a7483a07be4 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, diff --git a/plugins/task-resources/src/components/state/StatesProjectEditor.svelte b/plugins/task-resources/src/components/state/StatesProjectEditor.svelte index ac0793e3dbe..d0f2a62d3c7 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 @@