From 12924cb79c61a8405f5e6c2354e8de7da1bde40f Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 17 Jan 2024 15:18:10 +0700 Subject: [PATCH] UBERF-4957: Fix status colors (#4369) Signed-off-by: Andrey Sobolev --- .../components/state/StatesProjectEditor.svelte | 17 +++++++++-------- plugins/task/src/utils.ts | 7 ++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/task-resources/src/components/state/StatesProjectEditor.svelte b/plugins/task-resources/src/components/state/StatesProjectEditor.svelte index ce6642717f..494c92db93 100644 --- a/plugins/task-resources/src/components/state/StatesProjectEditor.svelte +++ b/plugins/task-resources/src/components/state/StatesProjectEditor.svelte @@ -31,7 +31,7 @@ showPopup, themeStore } from '@hcengineering/ui' - import { ColorsPopup, IconPicker, ObjectPresenter } from '@hcengineering/view-resources' + import { ColorsPopup, IconPicker, ObjectPresenter, statusStore } from '@hcengineering/view-resources' import { createEventDispatcher } from 'svelte' import task from '../../plugin' import StatusesPopup from './StatusesPopup.svelte' @@ -77,12 +77,12 @@ if (res == null) { return } - const targetColor = type.statuses.find((p) => p._id === state._id) - if (targetColor !== undefined) { + const targetColors = type.statuses.filter((p) => p._id === state._id) + for (const targetColor of targetColors) { targetColor.color = res - await client.update(type, { statuses: type.statuses }) - type = type } + await client.update(type, { statuses: type.statuses }) + type = type }) } @@ -174,11 +174,12 @@ const projectStatus = getProjectStatus(type, state, categoriesMap) showPopup(IconPicker, { icon: projectStatus?.icon, color: projectStatus?.color, icons }, el, async (result) => { if (result !== undefined && result !== null) { - const targetColor = type.statuses.find((p) => p._id === state._id) - if (targetColor !== undefined) { + const targetColors = type.statuses.filter((p) => p._id === state._id) + for (const targetColor of targetColors) { targetColor.color = result.color targetColor.icon = result.icon - console.log(result.color) + } + if (targetColors.length > 0) { await client.update(type, { statuses: type.statuses }) type = type } diff --git a/plugins/task/src/utils.ts b/plugins/task/src/utils.ts index db420b1aac..5f414e69cc 100644 --- a/plugins/task/src/utils.ts +++ b/plugins/task/src/utils.ts @@ -145,7 +145,12 @@ export function calculateStatuses ( taskTypes: Map, Data>, override: Array<{ taskTypeId: Ref, statuses: Array> }> ): ProjectStatus[] { - const stIds = new Map(projectType.statuses.map((p) => [p._id, p])) + const stIds = new Map, ProjectStatus>() + for (const s of projectType.statuses) { + if (!stIds.has(s._id)) { + stIds.set(s._id, s) + } + } const processed = new Set() const result: ProjectStatus[] = []