mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Minor fixes (#2615)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
8d14dbef14
commit
ef77d22116
@ -65,11 +65,7 @@ export async function generateIssues (
|
||||
}
|
||||
|
||||
async function genIssue (client: TxOperations): Promise<void> {
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ status: object.status },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
|
@ -13,10 +13,20 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { Doc, DocumentUpdate, generateId, Ref, SortingOrder, TxOperations, TxResult } from '@hcengineering/core'
|
||||
import core, {
|
||||
Doc,
|
||||
DocumentUpdate,
|
||||
DOMAIN_TX,
|
||||
generateId,
|
||||
Ref,
|
||||
SortingOrder,
|
||||
TxOperations,
|
||||
TxResult
|
||||
} from '@hcengineering/core'
|
||||
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import tags from '@hcengineering/tags'
|
||||
import {
|
||||
calcRank,
|
||||
genRanks,
|
||||
Issue,
|
||||
IssueStatus,
|
||||
@ -327,6 +337,45 @@ async function createDefaults (tx: TxOperations): Promise<void> {
|
||||
)
|
||||
}
|
||||
|
||||
async function fillRank (client: MigrationClient): Promise<void> {
|
||||
const docs = await client.find<Issue>(DOMAIN_TRACKER, {
|
||||
_class: tracker.class.Issue,
|
||||
rank: ''
|
||||
})
|
||||
let last = (
|
||||
await client.find<Issue>(
|
||||
DOMAIN_TRACKER,
|
||||
{
|
||||
_class: tracker.class.Issue,
|
||||
rank: { $ne: '' }
|
||||
},
|
||||
{
|
||||
sort: { rank: SortingOrder.Descending },
|
||||
limit: 1
|
||||
}
|
||||
)
|
||||
)[0]
|
||||
for (const doc of docs) {
|
||||
const rank = calcRank(last)
|
||||
await client.update(
|
||||
DOMAIN_TRACKER,
|
||||
{
|
||||
_id: doc._id
|
||||
},
|
||||
{
|
||||
rank
|
||||
}
|
||||
)
|
||||
await client.update(
|
||||
DOMAIN_TX,
|
||||
{ 'tx.objectId': doc._id, 'tx._class': core.class.TxCreateDoc },
|
||||
{ 'tx.attributes.rank': rank }
|
||||
)
|
||||
doc.rank = rank
|
||||
last = doc
|
||||
}
|
||||
}
|
||||
|
||||
async function upgradeTeams (tx: TxOperations): Promise<void> {
|
||||
await upgradeTeamIssueStatuses(tx)
|
||||
await fixTeamsIssueStatusesOrder(tx)
|
||||
@ -375,6 +424,7 @@ export const trackerOperation: MigrateOperation = {
|
||||
)
|
||||
await Promise.all([migrateIssueProjects(client), migrateParentIssues(client)])
|
||||
await migrateIssueParentInfo(client)
|
||||
await fillRank(client)
|
||||
},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
const tx = new TxOperations(client, core.account.System)
|
||||
|
@ -49,11 +49,7 @@
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(
|
||||
board.class.Card,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne(board.class.Card, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
|
||||
|
||||
const value: AttachedData<BoardCard> = {
|
||||
|
@ -70,7 +70,7 @@
|
||||
const client = getClient()
|
||||
|
||||
async function addItem (title: any) {
|
||||
const lastOne = await client.findOne(task.class.State, { space }, { sort: { rank: SortingOrder.Descending } })
|
||||
const lastOne = await client.findOne(task.class.State, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
await client.createDoc(task.class.State, space, {
|
||||
title,
|
||||
color: 9,
|
||||
|
@ -36,11 +36,7 @@
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(
|
||||
board.class.Card,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne(board.class.Card, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
|
||||
|
||||
const value: AttachedData<BoardCard> = {
|
||||
|
@ -24,7 +24,7 @@ export async function createCard (
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(board.class.Card, { state }, { sort: { rank: SortingOrder.Descending } })
|
||||
const lastOne = await client.findOne(board.class.Card, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
|
||||
|
||||
const value: AttachedData<Card> = {
|
||||
|
@ -63,11 +63,7 @@
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(
|
||||
lead.class.Lead,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne(lead.class.Lead, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
|
||||
|
||||
const value: AttachedData<Lead> = {
|
||||
|
@ -116,11 +116,7 @@
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(
|
||||
recruit.class.Applicant,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne(recruit.class.Applicant, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
|
||||
|
||||
const candidateInstance = await client.findOne(contact.class.Person, { _id: _candidate })
|
||||
|
@ -15,11 +15,11 @@
|
||||
<script lang="ts">
|
||||
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
|
||||
import contact, { Organization } from '@hcengineering/contact'
|
||||
import core, { FindResult, generateId, getCurrentAccount, Ref } from '@hcengineering/core'
|
||||
import core, { FindResult, generateId, getCurrentAccount, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { Card, createQuery, getClient, UserBox } from '@hcengineering/presentation'
|
||||
import { Vacancy as VacancyClass } from '@hcengineering/recruit'
|
||||
import task, { createKanban, KanbanTemplate } from '@hcengineering/task'
|
||||
import tracker, { IssueStatus, IssueTemplate } from '@hcengineering/tracker'
|
||||
import tracker, { calcRank, Issue, IssueStatus, IssueTemplate } from '@hcengineering/tracker'
|
||||
import { Button, Component, createFocusManager, EditBox, FocusHandler, IconAttachment } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import recruit from '../plugin'
|
||||
@ -84,43 +84,56 @@
|
||||
objectId
|
||||
)
|
||||
|
||||
for (const issueTemplate of issueTemplates) {
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
issueTemplate.space,
|
||||
{
|
||||
$inc: { sequence: 1 }
|
||||
},
|
||||
true
|
||||
)
|
||||
await client.addCollection(
|
||||
tracker.class.Issue,
|
||||
issueTemplate.space,
|
||||
tracker.ids.NoParent,
|
||||
tracker.class.Issue,
|
||||
'subIssues',
|
||||
{
|
||||
title: issueTemplate.title,
|
||||
description: issueTemplate.description,
|
||||
assignee: issueTemplate.assignee,
|
||||
project: issueTemplate.project,
|
||||
sprint: issueTemplate.sprint,
|
||||
number: (incResult as any).object.sequence,
|
||||
status: '' as Ref<IssueStatus>,
|
||||
priority: issueTemplate.priority,
|
||||
rank: '',
|
||||
comments: 0,
|
||||
subIssues: 0,
|
||||
dueDate: null,
|
||||
parents: [],
|
||||
reportedTime: 0,
|
||||
estimation: issueTemplate.estimation,
|
||||
reports: 0,
|
||||
relations: [{ _id: id, _class: recruit.class.Vacancy }],
|
||||
childInfo: []
|
||||
if (issueTemplates.length > 0) {
|
||||
for (const issueTemplate of issueTemplates) {
|
||||
// we need find for each because it can be in another space
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ space: issueTemplate.space },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
issueTemplate.space,
|
||||
{
|
||||
$inc: { sequence: 1 }
|
||||
},
|
||||
true
|
||||
)
|
||||
const team = await client.findOne(tracker.class.Team, { _id: issueTemplate.space })
|
||||
const rank = calcRank(lastOne, undefined)
|
||||
await client.addCollection(
|
||||
tracker.class.Issue,
|
||||
issueTemplate.space,
|
||||
tracker.ids.NoParent,
|
||||
tracker.class.Issue,
|
||||
'subIssues',
|
||||
{
|
||||
title: issueTemplate.title,
|
||||
description: issueTemplate.description,
|
||||
assignee: issueTemplate.assignee,
|
||||
project: issueTemplate.project,
|
||||
sprint: issueTemplate.sprint,
|
||||
number: (incResult as any).object.sequence,
|
||||
status: team?.defaultIssueStatus as Ref<IssueStatus>,
|
||||
priority: issueTemplate.priority,
|
||||
rank,
|
||||
comments: 0,
|
||||
subIssues: 0,
|
||||
dueDate: null,
|
||||
parents: [],
|
||||
reportedTime: 0,
|
||||
estimation: issueTemplate.estimation,
|
||||
reports: 0,
|
||||
relations: [{ _id: id, _class: recruit.class.Vacancy }],
|
||||
childInfo: []
|
||||
}
|
||||
)
|
||||
if (lastOne !== undefined) {
|
||||
lastOne.rank = rank
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
await createKanban(client, id, templateId)
|
||||
|
@ -75,7 +75,7 @@
|
||||
}
|
||||
|
||||
async function onAdd (_class: Ref<Class<State | DoneState>>) {
|
||||
const lastOne = await client.findOne(_class, { space: kanban.space }, { sort: { rank: SortingOrder.Descending } })
|
||||
const lastOne = await client.findOne(_class, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
if (hierarchy.isDerived(_class, task.class.DoneState)) {
|
||||
await client.createDoc(_class, kanban.space, {
|
||||
title: 'New Done State',
|
||||
|
@ -407,11 +407,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ status: object.status },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
@ -475,11 +471,7 @@
|
||||
}
|
||||
}
|
||||
for (const subIssue of subIssues) {
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ status: object.status },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
|
@ -91,11 +91,7 @@
|
||||
loading = true
|
||||
try {
|
||||
const space = currentTeam._id
|
||||
const lastOne = await client.findOne<Issue>(
|
||||
tracker.class.Issue,
|
||||
{ space },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne<Issue>(tracker.class.Issue, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
const incResult = await client.updateDoc(
|
||||
tracker.class.Team,
|
||||
core.space.Space,
|
||||
|
@ -52,11 +52,7 @@
|
||||
if (state === undefined) {
|
||||
throw new Error('Move: state not found')
|
||||
}
|
||||
const lastOne = await client.findOne(
|
||||
(doc as Task)._class,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const lastOne = await client.findOne((doc as Task)._class, {}, { sort: { rank: SortingOrder.Descending } })
|
||||
await moveToSpace(client, doc, space, {
|
||||
state: state._id,
|
||||
rank: calcRank(lastOne, undefined)
|
||||
|
@ -33,13 +33,21 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
|
||||
tx.modifiedOn = Date.now()
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = tx as TxCreateDoc<Doc & { createOn: Timestamp }>
|
||||
if (createTx.attributes.createOn !== undefined) {
|
||||
const hasCreateOn = this.storage.hierarchy.findAttribute(createTx.objectClass, 'createOn')
|
||||
if (hasCreateOn !== undefined) {
|
||||
createTx.attributes.createOn = tx.modifiedOn
|
||||
}
|
||||
}
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCollectionCUD)) {
|
||||
const coltx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
coltx.tx.modifiedOn = tx.modifiedOn
|
||||
if (this.storage.hierarchy.isDerived(coltx.tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = coltx.tx as TxCreateDoc<AttachedDoc & { createOn: Timestamp }>
|
||||
const hasCreateOn = this.storage.hierarchy.findAttribute(createTx.objectClass, 'createOn')
|
||||
if (hasCreateOn !== undefined) {
|
||||
createTx.attributes.createOn = tx.modifiedOn
|
||||
}
|
||||
}
|
||||
}
|
||||
return await this.provideTx(ctx, tx)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user