mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 08:21:08 +00:00
Inventory spaces (#2715)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
ca002b4a41
commit
c6dd5a6619
@ -13,9 +13,51 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import core, { TxOperations } from '@hcengineering/core'
|
||||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||||
|
import inventory from './plugin'
|
||||||
|
|
||||||
|
async function createSpace (tx: TxOperations): Promise<void> {
|
||||||
|
const categories = await tx.findOne(core.class.Space, {
|
||||||
|
_id: inventory.space.Category
|
||||||
|
})
|
||||||
|
if (categories === undefined) {
|
||||||
|
await tx.createDoc(
|
||||||
|
core.class.Space,
|
||||||
|
core.space.Space,
|
||||||
|
{
|
||||||
|
name: 'Categories',
|
||||||
|
description: 'Categories',
|
||||||
|
private: false,
|
||||||
|
archived: false,
|
||||||
|
members: []
|
||||||
|
},
|
||||||
|
inventory.space.Category
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const products = await tx.findOne(core.class.Space, {
|
||||||
|
_id: inventory.space.Products
|
||||||
|
})
|
||||||
|
if (products === undefined) {
|
||||||
|
await tx.createDoc(
|
||||||
|
core.class.Space,
|
||||||
|
core.space.Space,
|
||||||
|
{
|
||||||
|
name: 'Products',
|
||||||
|
description: 'Products',
|
||||||
|
private: false,
|
||||||
|
archived: false,
|
||||||
|
members: []
|
||||||
|
},
|
||||||
|
inventory.space.Products
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const inventoryOperation: MigrateOperation = {
|
export const inventoryOperation: MigrateOperation = {
|
||||||
async migrate (client: MigrationClient): Promise<void> {},
|
async migrate (client: MigrationClient): Promise<void> {},
|
||||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {}
|
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||||
|
const tx = new TxOperations(client, core.account.System)
|
||||||
|
await createSpace(tx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user