From 1a90f99af58ce34a0fe94142bc22b1f3bb31be6b Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Sat, 9 Jul 2022 00:42:23 +0700 Subject: [PATCH] Tracker: fix issue status colors in the kanban view (#2231) Signed-off-by: Sergei Ogorelkov --- .../src/components/issues/Board.svelte | 217 ------------------ .../components/issues/IssueStatusIcon.svelte | 5 +- .../src/components/issues/KanbanView.svelte | 15 +- plugins/tracker-resources/src/utils.ts | 20 +- 4 files changed, 25 insertions(+), 232 deletions(-) delete mode 100644 plugins/tracker-resources/src/components/issues/Board.svelte diff --git a/plugins/tracker-resources/src/components/issues/Board.svelte b/plugins/tracker-resources/src/components/issues/Board.svelte deleted file mode 100644 index 1d24dcfdbb..0000000000 --- a/plugins/tracker-resources/src/components/issues/Board.svelte +++ /dev/null @@ -1,217 +0,0 @@ - - - -{#if currentTeam && states} - -
Board
- { - listProvider.update(evt.detail) - }} - on:obj-focus={(evt) => { - listProvider.updateFocus(evt.detail) - }} - selection={listProvider.current($focusStore)} - checked={$selectionStore ?? []} - on:check={(evt) => { - listProvider.updateSelection(evt.detail.docs, evt.detail.value) - }} - on:contextmenu={(evt) => showMenu(evt.detail.evt, evt.detail.objects)} - > - -
-
-
- - {state.title} - {count} -
-
-
-
-
-
- - {@const issue = toIssue(object)} -
{ - showPanel(tracker.component.EditIssue, object._id, object._class, 'content') - }} - > -
- - - {object.title} - -
-
- -
- -
-
-
- {#if issue && issueStatuses && issue.subIssues > 0} - - {/if} - - -
-
-
-
-{/if} - - diff --git a/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte b/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte index 25c0e2760b..b89cd2ca97 100644 --- a/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte +++ b/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte @@ -41,9 +41,10 @@ $: color = fill ?? (value.color !== undefined ? getPlatformColor(value.color) : undefined) ?? - (category !== undefined ? getPlatformColor(category.color) : undefined) + (category !== undefined ? getPlatformColor(category.color) : undefined) ?? + 'currentColor' -{#if icon !== undefined && color !== undefined} +{#if icon !== undefined} {/if} diff --git a/plugins/tracker-resources/src/components/issues/KanbanView.svelte b/plugins/tracker-resources/src/components/issues/KanbanView.svelte index 3569b1028c..2e3fd48195 100644 --- a/plugins/tracker-resources/src/components/issues/KanbanView.svelte +++ b/plugins/tracker-resources/src/components/issues/KanbanView.svelte @@ -26,9 +26,9 @@ IconAdd, showPanel, showPopup, - getPlatformColor, Loading, - tooltip + tooltip, + getPlatformColor } from '@anticrm/ui' import { focusStore, ListSelectionProvider, SelectDirection, selectionStore } from '@anticrm/view-resources' import ActionContext from '@anticrm/view-resources/src/components/ActionContext.svelte' @@ -40,7 +40,8 @@ getKanbanStatuses, getPriorityStates, issuesGroupBySorting, - issuesSortOrderMap + issuesSortOrderMap, + UNSET_COLOR } from '../../utils' import CreateIssue from '../CreateIssue.svelte' import ProjectEditor from '../projects/ProjectEditor.svelte' @@ -195,7 +196,13 @@
- + {#if state.icon} + + {/if} {state.title} {count}
diff --git a/plugins/tracker-resources/src/utils.ts b/plugins/tracker-resources/src/utils.ts index 5e00877545..cc4af15f7e 100644 --- a/plugins/tracker-resources/src/utils.ts +++ b/plugins/tracker-resources/src/utils.ts @@ -32,6 +32,8 @@ import { defaultPriorities, defaultProjectStatuses, issuePriorities } from './ty export * from './types' +export const UNSET_COLOR = -1 + export interface NavigationItem { id: string label: IntlString @@ -344,7 +346,7 @@ export async function getKanbanStatuses ( issues: Array> ): Promise { if (groupBy === IssuesGrouping.NoGrouping) { - return [{ _id: undefined, color: 0, title: await translate(tracker.string.NoGrouping, {}) }] + return [{ _id: undefined, color: UNSET_COLOR, title: await translate(tracker.string.NoGrouping, {}) }] } if (groupBy === IssuesGrouping.Priority) { const states = issues.reduce((result, issue) => { @@ -355,7 +357,7 @@ export async function getKanbanStatuses ( { _id: priority, title: issuePriorities[priority].label, - color: 0, + color: UNSET_COLOR, icon: issuePriorities[priority].icon } ] @@ -371,14 +373,14 @@ export async function getKanbanStatuses ( return issues.reduce((result, issue) => { const status = issue.$lookup?.status if (status === undefined || result.find(({ _id }) => _id === status._id) !== undefined) return result - const icon = '$lookup' in status ? status.$lookup?.category?.icon : undefined + const category = '$lookup' in status ? status.$lookup?.category : undefined return [ ...result, { _id: status._id, title: status.name, - color: status.color ?? 0, - icon + icon: category?.icon, + color: status.color ?? category?.color ?? UNSET_COLOR } ] }, []) @@ -392,7 +394,7 @@ export async function getKanbanStatuses ( { _id: issue.assignee, title: issue.$lookup?.assignee?.name ?? noAssignee, - color: 0, + color: UNSET_COLOR, icon: undefined } ] @@ -407,7 +409,7 @@ export async function getKanbanStatuses ( { _id: issue.project, title: issue.$lookup?.project?.label ?? noProject, - color: 0, + color: UNSET_COLOR, icon: undefined } ] @@ -420,7 +422,7 @@ export function getIssueStatusStates (issueStatuses: Array ({ _id: status._id, title: status.name, - color: status.color ?? status.$lookup?.category?.color ?? 0, + color: status.color ?? status.$lookup?.category?.color ?? UNSET_COLOR, icon: status.$lookup?.category?.icon ?? undefined })) } @@ -430,7 +432,7 @@ export async function getPriorityStates (): Promise { defaultPriorities.map(async (priority) => ({ _id: priority, title: await translate(issuePriorities[priority].label, {}), - color: 0, + color: UNSET_COLOR, icon: issuePriorities[priority].icon })) )