diff --git a/packages/presentation/src/components/ObjectPopup.svelte b/packages/presentation/src/components/ObjectPopup.svelte index 0336c98c05..6b98b80867 100644 --- a/packages/presentation/src/components/ObjectPopup.svelte +++ b/packages/presentation/src/components/ObjectPopup.svelte @@ -85,8 +85,6 @@ selectedObjects = Array.from(selectedElements) dispatch('update', selectedObjects) - - selectedElements = selectedElements } const client = getClient() diff --git a/plugins/tracker-assets/assets/icons.svg b/plugins/tracker-assets/assets/icons.svg index e6d6bb4a7c..520b4e699a 100644 --- a/plugins/tracker-assets/assets/icons.svg +++ b/plugins/tracker-assets/assets/icons.svg @@ -110,4 +110,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/tracker-assets/src/index.ts b/plugins/tracker-assets/src/index.ts index 722d58e518..90f8f97de6 100644 --- a/plugins/tracker-assets/src/index.ts +++ b/plugins/tracker-assets/src/index.ts @@ -49,7 +49,14 @@ loadMetadata(tracker.icon, { ProjectsList: `${icons}#list`, ProjectsTimeline: `${icons}#timeline`, - ProjectMembers: `${icons}#projectMembers` + ProjectMembers: `${icons}#projectMembers`, + + ProjectStatusBacklog: `${icons}#project-status-backlog`, + ProjectStatusPlanned: `${icons}#project-status-planned`, + ProjectStatusInProgress: `${icons}#project-status-in-progress`, + ProjectStatusPaused: `${icons}#project-status-paused`, + ProjectStatusCompleted: `${icons}#project-status-completed`, + ProjectStatusCanceled: `${icons}#project-status-canceled` }) addStringsLoader(trackerId, async (lang: string) => await import(`../lang/${lang}.json`)) diff --git a/plugins/tracker-resources/src/components/projects/NewProject.svelte b/plugins/tracker-resources/src/components/projects/NewProject.svelte index 75bc528914..65e0ec3ed7 100644 --- a/plugins/tracker-resources/src/components/projects/NewProject.svelte +++ b/plugins/tracker-resources/src/components/projects/NewProject.svelte @@ -31,7 +31,7 @@ label: '' as IntlString, description: '', icon: tracker.icon.Projects, - status: ProjectStatus.Planned, + status: ProjectStatus.Backlog, lead: null, members: [], comments: 0, diff --git a/plugins/tracker-resources/src/components/projects/ProjectMembersPresenter.svelte b/plugins/tracker-resources/src/components/projects/ProjectMembersPresenter.svelte index 18b9cce708..732d681700 100644 --- a/plugins/tracker-resources/src/components/projects/ProjectMembersPresenter.svelte +++ b/plugins/tracker-resources/src/components/projects/ProjectMembersPresenter.svelte @@ -41,7 +41,16 @@ return } - await client.update(value, { members: result }) + const memberToPull = value.members.filter((x) => !result.includes(x))[0] + const memberToPush = result.filter((x) => !value.members.includes(x))[0] + + if (memberToPull) { + await client.update(value, { $pull: { members: memberToPull } }) + } + + if (memberToPush) { + await client.update(value, { $push: { members: memberToPush } }) + } } const handleProjectMembersEditorOpened = async (event: MouseEvent) => { diff --git a/plugins/tracker-resources/src/components/projects/ProjectStatusSelector.svelte b/plugins/tracker-resources/src/components/projects/ProjectStatusSelector.svelte index 1fa283f1b5..a646256168 100644 --- a/plugins/tracker-resources/src/components/projects/ProjectStatusSelector.svelte +++ b/plugins/tracker-resources/src/components/projects/ProjectStatusSelector.svelte @@ -31,12 +31,12 @@ $: selectedStatusIcon = selectedProjectStatus ? projectStatusAssets[selectedProjectStatus].icon - : tracker.icon.CategoryBacklog + : tracker.icon.ProjectStatusBacklog $: selectedStatusLabel = shouldShowLabel ? selectedProjectStatus ? projectStatusAssets[selectedProjectStatus].label - : tracker.string.Planned + : tracker.string.Backlog : undefined $: statusesInfo = defaultProjectStatuses.map((s) => ({ id: s, ...projectStatusAssets[s] })) @@ -55,12 +55,12 @@ diff --git a/plugins/tracker-resources/src/components/projects/Projects.svelte b/plugins/tracker-resources/src/components/projects/Projects.svelte index 0cc02ed75f..1fda1bb264 100644 --- a/plugins/tracker-resources/src/components/projects/Projects.svelte +++ b/plugins/tracker-resources/src/components/projects/Projects.svelte @@ -21,6 +21,7 @@ import { Button, IconAdd, IconOptions, Label, showPopup } from '@anticrm/ui' import tracker from '../../plugin' + import { getIncludedProjectStatuses, ProjectsViewMode } from '../../utils' import NewProject from './NewProject.svelte' import ProjectsListBrowser from './ProjectsListBrowser.svelte' @@ -28,6 +29,7 @@ export let title: IntlString = tracker.string.AllProjects export let query: DocumentQuery = {} export let search: string = '' + export let mode: ProjectsViewMode = 'all' const ENTRIES_LIMIT = 200 const resultProjectsQuery = createQuery() @@ -40,8 +42,12 @@ let resultProjects: Project[] = [] + $: includedProjectStatuses = getIncludedProjectStatuses(mode) + $: includedProjectsQuery = { status: { $in: includedProjectStatuses } } + $: baseQuery = { space: currentSpace, + ...includedProjectsQuery, ...query } @@ -59,6 +65,14 @@ const showCreateDialog = async () => { showPopup(NewProject, { space: currentSpace, targetElement: null }, null) } + + const handleViewModeChanged = (newMode: ProjectsViewMode) => { + if (newMode === undefined || newMode === mode) { + return + } + + mode = newMode + } @@ -75,16 +89,40 @@ - + handleViewModeChanged('all')} + /> - + handleViewModeChanged('backlog')} + /> - + handleViewModeChanged('active')} + /> - + handleViewModeChanged('closed')} + /> @@ -108,7 +146,7 @@ - {}} /> + @@ -134,7 +172,7 @@ .header { min-height: 3.5rem; padding-left: 2.25rem; - padding-right: 0.5rem; + padding-right: 1.35rem; border-bottom: 1px solid var(--theme-button-border-hovered); } diff --git a/plugins/tracker-resources/src/utils.ts b/plugins/tracker-resources/src/utils.ts index 60d1c168cc..b79f30543b 100644 --- a/plugins/tracker-resources/src/utils.ts +++ b/plugins/tracker-resources/src/utils.ts @@ -115,6 +115,7 @@ export const getIssuesModificationDatePeriodTime = (period: IssuesDateModificati } export const defaultProjectStatuses = [ + ProjectStatus.Backlog, ProjectStatus.Planned, ProjectStatus.InProgress, ProjectStatus.Paused, @@ -122,13 +123,13 @@ export const defaultProjectStatuses = [ ProjectStatus.Canceled ] -// TODO: update icons export const projectStatusAssets: Record = { - [ProjectStatus.Planned]: { icon: tracker.icon.CategoryBacklog, label: tracker.string.Planned }, - [ProjectStatus.InProgress]: { icon: tracker.icon.CategoryStarted, label: tracker.string.InProgress }, - [ProjectStatus.Paused]: { icon: tracker.icon.CategoryUnstarted, label: tracker.string.Paused }, - [ProjectStatus.Completed]: { icon: tracker.icon.CategoryCompleted, label: tracker.string.Completed }, - [ProjectStatus.Canceled]: { icon: tracker.icon.CategoryCanceled, label: tracker.string.Canceled } + [ProjectStatus.Backlog]: { icon: tracker.icon.ProjectStatusBacklog, label: tracker.string.Backlog }, + [ProjectStatus.Planned]: { icon: tracker.icon.ProjectStatusPlanned, label: tracker.string.Planned }, + [ProjectStatus.InProgress]: { icon: tracker.icon.ProjectStatusInProgress, label: tracker.string.InProgress }, + [ProjectStatus.Paused]: { icon: tracker.icon.ProjectStatusPaused, label: tracker.string.Paused }, + [ProjectStatus.Completed]: { icon: tracker.icon.ProjectStatusCompleted, label: tracker.string.Completed }, + [ProjectStatus.Canceled]: { icon: tracker.icon.ProjectStatusCanceled, label: tracker.string.Canceled } } export const groupBy = (data: any, key: any): { [key: string]: any[] } => { @@ -255,3 +256,25 @@ export const getDueDateIconModifier = ( return 'warning' } } + +export type ProjectsViewMode = 'all' | 'backlog' | 'active' | 'closed' + +export const getIncludedProjectStatuses = (mode: ProjectsViewMode): ProjectStatus[] => { + switch (mode) { + case 'all': { + return defaultProjectStatuses + } + case 'active': { + return [ProjectStatus.Planned, ProjectStatus.InProgress, ProjectStatus.Paused] + } + case 'backlog': { + return [ProjectStatus.Backlog] + } + case 'closed': { + return [ProjectStatus.Completed, ProjectStatus.Canceled] + } + default: { + return [] + } + } +} diff --git a/plugins/tracker/src/index.ts b/plugins/tracker/src/index.ts index e1aac1592b..6d693f8758 100644 --- a/plugins/tracker/src/index.ts +++ b/plugins/tracker/src/index.ts @@ -137,6 +137,7 @@ export interface Document extends Doc { * @public */ export enum ProjectStatus { + Backlog, Planned, InProgress, Paused, @@ -230,6 +231,13 @@ export default plugin(trackerId, { ProjectsList: '' as Asset, ProjectsTimeline: '' as Asset, - ProjectMembers: '' as Asset + ProjectMembers: '' as Asset, + + ProjectStatusBacklog: '' as Asset, + ProjectStatusPlanned: '' as Asset, + ProjectStatusInProgress: '' as Asset, + ProjectStatusPaused: '' as Asset, + ProjectStatusCompleted: '' as Asset, + ProjectStatusCanceled: '' as Asset } })