Skip to content

Commit

Permalink
TSK-915: Tracker status
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo committed Mar 22, 2023
1 parent d7265f0 commit 3b37e2f
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 237 deletions.
13 changes: 5 additions & 8 deletions models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ import {
Project,
TimeReportDayType,
TimeSpendReport,
trackerId,
WorkDayLength
trackerId
} from '@hcengineering/tracker'
import { KeyBinding, ViewOptionsModel } from '@hcengineering/view'
import tracker from './plugin'
Expand All @@ -92,11 +91,14 @@ export const DOMAIN_TRACKER = 'tracker' as Domain
*/
@Model(tracker.class.IssueStatus, core.class.AttachedDoc, DOMAIN_TRACKER)
export class TIssueStatus extends TAttachedDoc implements IssueStatus {
name!: string
@Index(IndexKind.Indexed)
name!: string

description?: string
color?: number

@Prop(TypeRef(tracker.class.IssueStatusCategory), tracker.string.StatusCategory)
@Index(IndexKind.Indexed)
category!: Ref<IssueStatusCategory>

@Prop(TypeString(), tracker.string.Rank)
Expand Down Expand Up @@ -161,10 +163,6 @@ export class TTypeSprintStatus extends TType {}
@Model(tracker.class.Project, core.class.Space, DOMAIN_SPACE)
@UX(tracker.string.Project, tracker.icon.Project, 'Project')
export class TProject extends TSpace implements Project {
@Prop(TypeString(), tracker.string.Title)
@Index(IndexKind.FullText)
reamLogo!: IntlString

@Prop(TypeString(), tracker.string.Identifier)
@Index(IndexKind.FullText)
identifier!: IntlString
Expand All @@ -182,7 +180,6 @@ export class TProject extends TSpace implements Project {
@Prop(TypeRef(contact.class.Employee), tracker.string.DefaultAssignee)
defaultAssignee!: Ref<Employee>

declare workDayLength: WorkDayLength
declare defaultTimeReportDay: TimeReportDayType
}

Expand Down
12 changes: 4 additions & 8 deletions models/tracker/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ import {
IssueTemplate,
IssueTemplateChild,
Project,
TimeReportDayType,
WorkDayLength
TimeReportDayType
} from '@hcengineering/tracker'
import { DOMAIN_TRACKER } from '.'
import tracker from './plugin'
Expand Down Expand Up @@ -126,8 +125,7 @@ async function createDefaultProject (tx: TxOperations): Promise<void> {
issueStatuses: 0,
defaultIssueStatus: defaultStatusId,
defaultTimeReportDay: TimeReportDayType.PreviousWorkDay,
defaultAssignee: undefined,
workDayLength: WorkDayLength.EIGHT_HOURS
defaultAssignee: undefined
},
tracker.project.DefaultProject
)
Expand Down Expand Up @@ -157,14 +155,12 @@ async function fixProjectsIssueStatusesOrder (tx: TxOperations): Promise<void> {

async function upgradeProjectSettings (tx: TxOperations): Promise<void> {
const projects = await tx.findAll(tracker.class.Project, {
defaultTimeReportDay: { $exists: false },
workDayLength: { $exists: false }
defaultTimeReportDay: { $exists: false }
})
await Promise.all(
projects.map((project) =>
tx.update(project, {
defaultTimeReportDay: TimeReportDayType.PreviousWorkDay,
workDayLength: WorkDayLength.EIGHT_HOURS
defaultTimeReportDay: TimeReportDayType.PreviousWorkDay
})
)
)
Expand Down
1 change: 0 additions & 1 deletion plugins/tracker-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
"DefaultTimeReportDay": "Select default day for time report",
"DefaultAssignee": "Select default assignee for issues",

"WorkDayLength": "Select length of working day",
"SevenHoursLength": "Seven Hours",
"EightHoursLength": "Eight Hours",
"CreatedOn": "Created on",
Expand Down
1 change: 0 additions & 1 deletion plugins/tracker-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
"DefaultTimeReportDay": "Выберите день для временного отчета по умолчанию",
"DefaultAssignee": "Выберите исполнителя по умолчанию",

"WorkDayLength": "Выберите длину рабочего дня",
"SevenHoursLength": "Семь Часов",
"EightHoursLength": "Восемь Часов",
"CreatedOn": "Создана",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
<script lang="ts">
import core, {
IdMap,
Ref,
Timestamp,
toIdMap,
Tx,
TxCollectionCUD,
TxCreateDoc,
TxUpdateDoc,
WithLookup
} from '@hcengineering/core'
import core, { Ref, Timestamp, Tx, TxCollectionCUD, TxCreateDoc, TxUpdateDoc, WithLookup } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { Issue, IssueStatus } from '@hcengineering/tracker'
import { Label, ticker } from '@hcengineering/ui'
import tracker from '../../plugin'
import { statusByIdStore } from '../../utils'
import Duration from './Duration.svelte'
import StatusPresenter from './StatusPresenter.svelte'
Expand All @@ -28,23 +19,6 @@
duration: number
}
const stQuery = createQuery()
let statuses: IdMap<IssueStatus> = new Map()
stQuery.query(
tracker.class.IssueStatus,
{},
(res) => {
statuses = toIdMap(res)
},
{
lookup: {
category: tracker.class.IssueStatusCategory
}
}
)
$: query.query(
core.class.Tx,
{ 'tx.objectId': issue._id },
Expand Down Expand Up @@ -109,7 +83,7 @@
displaySt = result
}
$: updateStatus(txes, statuses, $ticker)
$: updateStatus(txes, $statusByIdStore, $ticker)
</script>

<div class="flex-row mt-4 mb-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
// limitations under the License.
-->
<script lang="ts">
import { AttachedData, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import { AttachedData, Ref, WithLookup } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { DraftIssueChild, Issue, IssueStatus, Project } from '@hcengineering/tracker'
import type { ButtonKind, ButtonSize } from '@hcengineering/ui'
import { Button, eventToHTMLElement, SelectPopup, showPopup, TooltipAlignment } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import tracker from '../../plugin'
import { statusStore } from '../../utils'
import IssueStatusIcon from './IssueStatusIcon.svelte'
import StatusPresenter from './StatusPresenter.svelte'
Expand All @@ -38,7 +39,6 @@
export let issueStatuses: Map<Ref<Project>, WithLookup<IssueStatus>[]> | undefined = undefined
const client = getClient()
const statusesQuery = createQuery()
const dispatch = createEventDispatcher()
const changeStatus = async (newStatus: Ref<IssueStatus> | undefined) => {
Expand Down Expand Up @@ -79,20 +79,7 @@
$: if (!statuses) {
statuses = '_id' in value ? issueStatuses?.get(value.space) : undefined
if (statuses === undefined) {
const query = '_id' in value ? { attachedTo: value.space } : {}
statusesQuery.query(
tracker.class.IssueStatus,
query,
(result) => {
statuses = result
},
{
lookup: { category: tracker.class.IssueStatusCategory },
sort: { rank: SortingOrder.Ascending }
}
)
} else {
statusesQuery.unsubscribe()
statuses = $statusStore.filter((it) => it.attachedTo === ('_id' in value ? value.space : undefined))
}
}
$: smallgap = size === 'inline' || size === 'small'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
// limitations under the License.
-->
<script lang="ts">
import { WithLookup } from '@hcengineering/core'
import { IssueStatus } from '@hcengineering/tracker'
import { statusByIdStore } from '../../utils'
import IssueStatusIcon from './IssueStatusIcon.svelte'
export let value: WithLookup<IssueStatus> | undefined
export let size: 'small' | 'medium' = 'medium'
export let value: IssueStatus | undefined
export let size: 'small' | 'medium' = 'small'
</script>

{#if value}
{@const icon = $statusByIdStore.get(value._id)?.$lookup?.category?.icon}
<div class="flex-presenter">
{#if value.$lookup?.category?.icon}
{#if icon}
<IssueStatusIcon {value} {size} />
{/if}
<span class="overflow-label" class:ml-2={value.$lookup?.category?.icon !== undefined}>
<span class="overflow-label" class:ml-2={icon !== undefined}>
{value.name}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
// limitations under the License.
-->
<script lang="ts">
import { Ref, WithLookup } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import tracker, { IssueStatus } from '@hcengineering/tracker'
import { Ref } from '@hcengineering/core'
import { IssueStatus } from '@hcengineering/tracker'
import { statusByIdStore } from '../../utils'
import StatusPresenter from './StatusPresenter.svelte'
export let value: Ref<IssueStatus> | undefined
export let size: 'small' | 'medium' = 'medium'
let status: WithLookup<IssueStatus> | undefined
const query = createQuery()
$: query.query(tracker.class.IssueStatus, { _id: value }, (res) => ([status] = res), {
lookup: { category: tracker.class.IssueStatusCategory }
})
</script>

<StatusPresenter value={status} {size} />
{#if value}
<StatusPresenter value={$statusByIdStore.get(value)} {size} />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
import { Class, Data, Doc, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
import { Class, Data, Doc, Ref, WithLookup } from '@hcengineering/core'
import notification from '@hcengineering/notification'
import { Panel } from '@hcengineering/panel'
import { getResource } from '@hcengineering/platform'
Expand Down Expand Up @@ -48,7 +48,6 @@
let lastId: Ref<Doc> = _id
let lastClass: Ref<Class<Doc>> = _class
const queryClient = createQuery()
const statusesQuery = createQuery()
const dispatch = createEventDispatcher()
const client = getClient()
Expand Down Expand Up @@ -93,20 +92,8 @@
{ lookup: { attachedTo: tracker.class.Issue, space: tracker.class.Project } }
)
$: currentProject &&
statusesQuery.query(
tracker.class.IssueStatus,
{ attachedTo: currentProject._id },
(statuses) => (issueStatuses = statuses),
{
lookup: { category: tracker.class.IssueStatusCategory },
sort: { rank: SortingOrder.Ascending }
}
)
$: issueId = currentProject && issue && getIssueId(currentProject, issue)
$: canSave = title.trim().length > 0
$: isDescriptionEmpty = !new DOMParser().parseFromString(description, 'text/html').documentElement.innerText?.trim()
$: parentIssue = issue?.$lookup?.attachedTo
let saved = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Ref, SortingOrder, toIdMap, WithLookup } from '@hcengineering/core'
import { Ref, toIdMap, WithLookup } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { Issue, IssueStatus, Project, trackerId } from '@hcengineering/tracker'
import {
Expand All @@ -22,9 +22,9 @@
closeTooltip,
ExpandCollapse,
getCurrentLocation,
IconScaleFull,
IconAdd,
IconArrowRight,
IconScaleFull,
Label,
navigate
} from '@hcengineering/ui'
Expand All @@ -33,10 +33,11 @@
createFilter,
filterStore,
getViewOptions,
viewOptionStore,
ViewletSettingButton
ViewletSettingButton,
viewOptionStore
} from '@hcengineering/view-resources'
import tracker from '../../../plugin'
import { statusStore } from '../../../utils'
import CreateSubIssue from './CreateSubIssue.svelte'
import SubIssueList from './SubIssueList.svelte'
Expand Down Expand Up @@ -70,26 +71,13 @@
projectsQuery.unsubscribe()
}
const statusesQuery = createQuery()
$: if (issueStatuses === undefined) {
statusesQuery.query(
tracker.class.IssueStatus,
{},
(statuses) => {
const st = new Map<Ref<Project>, WithLookup<IssueStatus>[]>()
for (const s of statuses) {
const id = s.attachedTo as Ref<Project>
st.set(id, [...(st.get(id) ?? []), s])
}
_issueStatuses = st
},
{
lookup: { category: tracker.class.IssueStatusCategory },
sort: { rank: SortingOrder.Ascending }
}
)
} else {
statusesQuery.unsubscribe()
const st = new Map<Ref<Project>, WithLookup<IssueStatus>[]>()
for (const s of $statusStore) {
const id = s.attachedTo as Ref<Project>
st.set(id, [...(st.get(id) ?? []), s])
}
_issueStatuses = st
}
$: viewOptions = viewlet !== undefined ? getViewOptions(viewlet, $viewOptionStore) : undefined
Expand Down
Loading

0 comments on commit 3b37e2f

Please sign in to comment.