mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-30 21:45:01 +02:00
Tracker: move "IssueStatus" enum into model (#1449)
Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
@@ -14,11 +14,33 @@
|
||||
//
|
||||
|
||||
import { Employee } from '@anticrm/contact'
|
||||
import type { Class, Doc, Markup, Ref, Space, Timestamp } from '@anticrm/core'
|
||||
import type { AttachedDoc, Class, Doc, Markup, Ref, Space, Timestamp } from '@anticrm/core'
|
||||
import type { Asset, IntlString, Plugin } from '@anticrm/platform'
|
||||
import { plugin } from '@anticrm/platform'
|
||||
import { AnyComponent } from '@anticrm/ui'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface IssueStatus extends AttachedDoc {
|
||||
name: string
|
||||
description?: string
|
||||
color?: number
|
||||
category: Ref<IssueStatusCategory>
|
||||
rank: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface IssueStatusCategory extends Doc {
|
||||
icon: Asset
|
||||
label: IntlString
|
||||
color: number
|
||||
defaultStatusName: string
|
||||
order: number
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -26,16 +48,8 @@ export interface Team extends Space {
|
||||
teamLogo?: string | null
|
||||
identifier: string // Team identifier
|
||||
sequence: number
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export enum IssueStatus {
|
||||
Backlog,
|
||||
Todo,
|
||||
InProgress,
|
||||
Done,
|
||||
Canceled
|
||||
issueStatuses: number
|
||||
defaultIssueStatus: Ref<IssueStatus>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +98,7 @@ export enum IssuesDateModificationPeriod {
|
||||
export interface Issue extends Doc {
|
||||
title: string
|
||||
description: Markup
|
||||
status: IssueStatus
|
||||
status: Ref<IssueStatus>
|
||||
priority: IssuePriority
|
||||
|
||||
number: number
|
||||
@@ -153,17 +167,28 @@ export interface Project extends Doc {
|
||||
*/
|
||||
export const trackerId = 'tracker' as Plugin
|
||||
|
||||
export * from './utils'
|
||||
|
||||
export default plugin(trackerId, {
|
||||
class: {
|
||||
Team: '' as Ref<Class<Team>>,
|
||||
Issue: '' as Ref<Class<Issue>>,
|
||||
Document: '' as Ref<Class<Document>>,
|
||||
Project: '' as Ref<Class<Project>>
|
||||
Project: '' as Ref<Class<Project>>,
|
||||
IssueStatus: '' as Ref<Class<IssueStatus>>,
|
||||
IssueStatusCategory: '' as Ref<Class<IssueStatusCategory>>
|
||||
},
|
||||
component: {
|
||||
Tracker: '' as AnyComponent,
|
||||
TrackerApp: '' as AnyComponent
|
||||
},
|
||||
issueStatusCategory: {
|
||||
Backlog: '' as Ref<IssueStatusCategory>,
|
||||
Unstarted: '' as Ref<IssueStatusCategory>,
|
||||
Started: '' as Ref<IssueStatusCategory>,
|
||||
Completed: '' as Ref<IssueStatusCategory>,
|
||||
Canceled: '' as Ref<IssueStatusCategory>
|
||||
},
|
||||
icon: {
|
||||
TrackerApplication: '' as Asset,
|
||||
Project: '' as Asset,
|
||||
@@ -183,11 +208,12 @@ export default plugin(trackerId, {
|
||||
DueDate: '' as Asset,
|
||||
Parent: '' as Asset,
|
||||
|
||||
StatusBacklog: '' as Asset,
|
||||
StatusTodo: '' as Asset,
|
||||
StatusInProgress: '' as Asset,
|
||||
StatusDone: '' as Asset,
|
||||
StatusCanceled: '' as Asset,
|
||||
CategoryBacklog: '' as Asset,
|
||||
CategoryUnstarted: '' as Asset,
|
||||
CategoryStarted: '' as Asset,
|
||||
CategoryCompleted: '' as Asset,
|
||||
CategoryCanceled: '' as Asset,
|
||||
|
||||
PriorityNoPriority: '' as Asset,
|
||||
PriorityUrgent: '' as Asset,
|
||||
PriorityHigh: '' as Asset,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright © 2022 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.
|
||||
//
|
||||
|
||||
import { LexoRank, LexoDecimal, LexoNumeralSystem36 } from 'lexorank'
|
||||
import LexoRankBucket from 'lexorank/lib/lexoRank/lexoRankBucket'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const genRanks = (count: number): Generator<string, void, unknown> =>
|
||||
(function * () {
|
||||
const sys = new LexoNumeralSystem36()
|
||||
const base = 36
|
||||
const max = base ** 6
|
||||
const gap = LexoDecimal.parse(Math.trunc(max / (count + 2)).toString(base), sys)
|
||||
let cur = LexoDecimal.parse('0', sys)
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
cur = cur.add(gap)
|
||||
yield new LexoRank(LexoRankBucket.BUCKET_0, cur).toString()
|
||||
}
|
||||
})()
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const calcRank = (prev?: { rank: string }, next?: { rank: string }): string => {
|
||||
const a = prev?.rank !== undefined ? LexoRank.parse(prev.rank) : LexoRank.min()
|
||||
const b = next?.rank !== undefined ? LexoRank.parse(next.rank) : LexoRank.max()
|
||||
|
||||
return a.between(b).toString()
|
||||
}
|
||||
Reference in New Issue
Block a user