Automation (#4052)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-11-27 12:58:14 +06:00 committed by GitHub
parent 43e1e38af0
commit 63c24da02a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 10 deletions

View File

@ -71,8 +71,6 @@ export const DOMAIN_KANBAN = 'kanban' as Domain
/**
* @public
*
* No domain is specified, since pure Tasks could not exists
*/
@Model(task.class.Task, core.class.AttachedDoc, DOMAIN_TASK)
@UX(task.string.Task, task.icon.Task, task.string.Task)
@ -86,8 +84,8 @@ export class TTask extends TAttachedDoc implements Task {
@Hidden()
number!: number
// @Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee)
assignee!: Ref<Person> | null
@Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee)
assignee!: Ref<Person> | null
@Prop(TypeDate(), task.string.DueDate, { editor: task.component.DueDateEditor })
dueDate!: Timestamp | null

View File

@ -75,6 +75,8 @@
"StatusPopupTitle": "Create new status or edit name for existing",
"NameAlreadyExists": "This name already exists for this status type",
"ProjectType": "Project type",
"ProjectTypes": "Project types"
"ProjectTypes": "Project types",
"StatusChange": "Status changed",
"TaskCreated": "Task created"
}
}

View File

@ -75,6 +75,8 @@
"StatusPopupTitle": "Создание статуса и изменение имени существующего",
"NameAlreadyExists": "Данное имя уже используется другим статусом этого типа",
"ProjectType": "Тип проекта",
"ProjectTypes": "Типы проектов"
"ProjectTypes": "Типы проектов",
"StatusChange": "Статус изменен",
"TaskCreated": "Создана задача"
}
}

View File

@ -15,7 +15,7 @@
-->
<script lang="ts">
import core, { Attribute, IdMap, Ref, Status, StatusCategory, toIdMap } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import { ComponentExtensions, createQuery, getClient } from '@hcengineering/presentation'
import { ProjectType, ProjectTypeCategory } from '@hcengineering/task'
import {
CircleButton,
@ -158,6 +158,7 @@
{#if categoryEditor}
<Component is={categoryEditor} props={{ type }} />
{/if}
<ComponentExtensions extension={task.extensions.ProjectEditorExtension} props={{ type }} />
{#each categories as cat, i}
{@const states = groups.get(cat._id) ?? []}
{@const prevIndex = getPrevIndex(groups, cat._id)}

View File

@ -0,0 +1,86 @@
<!--
// Copyright © 2023 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import core, { IdMap, Ref, Status, StatusCategory, toIdMap } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { ProjectType } from '@hcengineering/task'
import {
ColorDefinition,
getColorNumberByText,
getPlatformColorDef,
resizeObserver,
themeStore
} from '@hcengineering/ui'
import { statusStore } from '@hcengineering/view-resources'
import { createEventDispatcher } from 'svelte'
import { typeStore } from '../..'
export let space: Ref<ProjectType>
$: states = type
? ($typeStore
.get(type._id)
?.statuses?.map((p) => $statusStore.byId.get(p._id))
.filter((p) => p !== undefined) as Status[]) ?? []
: []
const dispatch = createEventDispatcher()
function getColor (state: Status, type: ProjectType | undefined, categories: IdMap<StatusCategory>): ColorDefinition {
const category = state.category ? categories.get(state.category) : undefined
const targetColor = type?.statuses?.find((p) => p._id === state._id)?.color ?? state.color ?? category?.color
return getPlatformColorDef(targetColor ?? getColorNumberByText(state.name), $themeStore.dark)
}
let categories: IdMap<StatusCategory> = new Map()
const q = createQuery()
q.query(core.class.StatusCategory, {}, (res) => {
categories = toIdMap(res)
})
let type: ProjectType | undefined = undefined
type = $typeStore.get(space)
</script>
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
<div class="menu-space" />
<div class="scroll">
<div class="box">
{#each states as state}
{@const color = getColor(state, type, categories)}
<button
class="menu-item"
on:click={() => {
dispatch('close', state)
}}
>
<div class="color" style:background-color={color.color} />
<span class="label">{state.name}</span>
</button>
{/each}
</div>
</div>
<div class="menu-space" />
</div>
<style lang="scss">
.color {
flex-shrink: 0;
margin-right: 0.75rem;
width: 1rem;
height: 1rem;
border-radius: 0.25rem;
}
</style>

View File

@ -49,6 +49,7 @@ import ProjectEditor from './components/kanban/ProjectEditor.svelte'
import ProjectTypeSelector from './components/kanban/ProjectTypeSelector.svelte'
import StateEditor from './components/state/StateEditor.svelte'
import StatePresenter from './components/state/StatePresenter.svelte'
import TypeStatesPopup from './components/state/TypeStatesPopup.svelte'
import StateRefPresenter from './components/state/StateRefPresenter.svelte'
import TodoItemPresenter from './components/todos/TodoItemPresenter.svelte'
import TodoItemsPopup from './components/todos/TodoItemsPopup.svelte'
@ -56,7 +57,7 @@ import TodoStatePresenter from './components/todos/TodoStatePresenter.svelte'
import Todos from './components/todos/Todos.svelte'
export { default as AssigneePresenter } from './components/AssigneePresenter.svelte'
export { StateRefPresenter }
export { StateRefPresenter, StatePresenter, TypeStatesPopup }
async function editStatuses (object: Project, ev: Event): Promise<void> {
const client = getClient()

View File

@ -73,7 +73,9 @@ export default mergeIds(taskId, task, {
AllTime: '' as IntlString,
StatusName: '' as IntlString,
StatusPopupTitle: '' as IntlString,
NameAlreadyExists: '' as IntlString
NameAlreadyExists: '' as IntlString,
StatusChange: '' as IntlString,
TaskCreated: '' as IntlString
},
status: {
AssigneeRequired: '' as IntlString

View File

@ -30,7 +30,7 @@ import {
import { NotificationType } from '@hcengineering/notification'
import type { Asset, IntlString, Plugin } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform'
import type { AnyComponent } from '@hcengineering/ui'
import type { AnyComponent, ComponentExtensionId } from '@hcengineering/ui'
import { Action, ViewletDescriptor } from '@hcengineering/view'
/**
@ -216,6 +216,9 @@ const task = plugin(taskId, {
},
ids: {
AssigneedNotification: '' as Ref<NotificationType>
},
extensions: {
ProjectEditorExtension: '' as ComponentExtensionId
}
})