mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-24 12:06:57 +03:00
Update doneStates of existing kanban cards (#625)
Signed-off-by: Ilya Sumbatyants <ilya.sumb@gmail.com>
This commit is contained in:
parent
caff583483
commit
9d6e2f2076
@ -19,11 +19,13 @@ import { MigrateOperation } from '@anticrm/model'
|
|||||||
import { taskOperation } from '@anticrm/model-task'
|
import { taskOperation } from '@anticrm/model-task'
|
||||||
import { attachmentOperation } from '@anticrm/model-attachment'
|
import { attachmentOperation } from '@anticrm/model-attachment'
|
||||||
import { leadOperation } from '@anticrm/model-lead'
|
import { leadOperation } from '@anticrm/model-lead'
|
||||||
|
import { recruitOperation } from '@anticrm/model-recruit'
|
||||||
import { viewOperation } from '@anticrm/model-view'
|
import { viewOperation } from '@anticrm/model-view'
|
||||||
|
|
||||||
export const migrateOperations: MigrateOperation[] = [
|
export const migrateOperations: MigrateOperation[] = [
|
||||||
taskOperation,
|
taskOperation,
|
||||||
attachmentOperation,
|
attachmentOperation,
|
||||||
leadOperation,
|
leadOperation,
|
||||||
|
recruitOperation,
|
||||||
viewOperation
|
viewOperation
|
||||||
]
|
]
|
||||||
|
@ -42,5 +42,20 @@ export const leadOperation: MigrateOperation = {
|
|||||||
} else {
|
} else {
|
||||||
console.log('Lead: => default funnel Kanban is ok')
|
console.log('Lead: => default funnel Kanban is ok')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const outdatedLeads = (await client.findAll(lead.class.Lead, {}))
|
||||||
|
.filter((x) => x.doneState === undefined)
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
outdatedLeads.map(async (lead) => {
|
||||||
|
console.info('Upgrade lead:', lead._id)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ops.updateDoc(lead._class, lead.space, lead._id, { doneState: null })
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,3 +251,5 @@ export function createModel (builder: Builder): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { default } from './plugin'
|
export { default } from './plugin'
|
||||||
|
|
||||||
|
export { recruitOperation } from './migration'
|
||||||
|
54
models/recruit/src/migration.ts
Normal file
54
models/recruit/src/migration.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||||
|
//
|
||||||
|
// 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 { TxOperations } from '@anticrm/core'
|
||||||
|
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model'
|
||||||
|
import core from '@anticrm/model-core'
|
||||||
|
|
||||||
|
import recruit from './plugin'
|
||||||
|
|
||||||
|
export const recruitOperation: MigrateOperation = {
|
||||||
|
async migrate (client: MigrationClient): Promise<void> {
|
||||||
|
|
||||||
|
},
|
||||||
|
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||||
|
console.log('Recruit: Performing model upgrades')
|
||||||
|
|
||||||
|
const ops = new TxOperations(client, core.account.System)
|
||||||
|
|
||||||
|
const outdatedApplications = (await client.findAll(recruit.class.Applicant, {}))
|
||||||
|
.filter((x) => x.doneState === undefined)
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
outdatedApplications.map(async (application) => {
|
||||||
|
console.info('Upgrade application:', application._id)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ops.updateCollection(
|
||||||
|
application._class,
|
||||||
|
application.space,
|
||||||
|
application._id,
|
||||||
|
application.attachedTo,
|
||||||
|
application.attachedToClass,
|
||||||
|
application.collection,
|
||||||
|
{ doneState: null }
|
||||||
|
)
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -51,5 +51,19 @@ export const taskOperation: MigrateOperation = {
|
|||||||
} else {
|
} else {
|
||||||
console.log('Task: => public project Kanban is ok')
|
console.log('Task: => public project Kanban is ok')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const outdatedTasks = (await client.findAll(task.class.Task, {}))
|
||||||
|
.filter((x) => x.doneState === undefined)
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
outdatedTasks.map(async (task) => {
|
||||||
|
console.info('Upgrade task:', task._id)
|
||||||
|
try {
|
||||||
|
await ops.updateDoc(task._class, task.space, task._id, { doneState: null })
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onDone = (state: DoneState) => async () => {
|
const onDone = (state: DoneState) => async () => {
|
||||||
await client.updateDoc(dragCard._class, dragCard.space, dragCard._id, {
|
if (client.getHierarchy().isDerived(_class, core.class.AttachedDoc)) {
|
||||||
doneState: state._id
|
const adoc: AttachedDoc = dragCard as Doc as AttachedDoc
|
||||||
})
|
await client.updateCollection(
|
||||||
|
_class,
|
||||||
|
space,
|
||||||
|
adoc._id as Ref<Doc> as Ref<AttachedDoc>,
|
||||||
|
adoc.attachedTo,
|
||||||
|
adoc.attachedToClass,
|
||||||
|
adoc.collection,
|
||||||
|
{ doneState: state._id }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await client.updateDoc(dragCard._class, dragCard.space, dragCard._id, {
|
||||||
|
doneState: state._id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
isDragging = false
|
isDragging = false
|
||||||
hoveredDoneState = undefined
|
hoveredDoneState = undefined
|
||||||
|
Loading…
Reference in New Issue
Block a user