@things-factory/meta-ui 8.0.0-beta.9 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/bootstrap.ts +170 -0
- package/client/component/filter/filter-form-meta-code-select.ts +102 -0
- package/client/component/filter/filter-form-meta-object-select.ts +107 -0
- package/client/component/filter/filter-grist-meta-code-select.ts +97 -0
- package/client/component/filter/filter-grist-meta-object-select.ts +102 -0
- package/client/component/grist/editor/grist-editor-code-input.js +96 -0
- package/client/component/grist/editor/grist-editor-meta-code-selector.js +157 -0
- package/client/component/grist/editor/grist-editor-meta-object-selector.js +122 -0
- package/client/component/grist/renderer/grist-renderer-code-input.js +20 -0
- package/client/component/grist/renderer/grist-renderer-meta-code-selector.js +28 -0
- package/client/component/grist/renderer/grist-renderer-meta-object-selector.js +25 -0
- package/client/component/popup/code-input-editor-popup.js +111 -0
- package/client/component/popup/file-upload-popup.js +129 -0
- package/client/component/popup/meta-object-selector-popup.ts +356 -0
- package/client/component/popup/record-based-code-editor-popup.ts +141 -0
- package/client/dynamic-menus.ts +38 -0
- package/client/index.ts +18 -0
- package/client/load-components.ts +17 -0
- package/client/mixin/meta-base-mixin.js +323 -0
- package/client/mixin/meta-basic-grist-mixin.js +283 -0
- package/client/mixin/meta-button-mixin.js +116 -0
- package/client/mixin/meta-form-mixin.js +435 -0
- package/client/mixin/meta-grist-tab-mixin.js +335 -0
- package/client/mixin/meta-main-tab-mixin.js +267 -0
- package/client/mixin/meta-master-detail-mixin.js +395 -0
- package/client/mixin/meta-service-mixin.js +306 -0
- package/client/mixin/meta-tab-detail-mixin.js +283 -0
- package/client/mixin/meta-tab-mixin.js +190 -0
- package/client/pages/activity/meta-activity-define-page.js +422 -0
- package/client/pages/activity/meta-activity-list-page.js +262 -0
- package/client/pages/activity/meta-activity-viewer-element.js +35 -0
- package/client/pages/activity/meta-activity-writer-element.js +48 -0
- package/client/pages/activity/meta-activiy-mixin.js +79 -0
- package/client/pages/button-role/button-role-detail.js +50 -0
- package/client/pages/button-role/button-role-page.js +25 -0
- package/client/pages/doc-number/doc-number-page.js +24 -0
- package/client/pages/doc-number/next-doc-number-popup.js +25 -0
- package/client/pages/entity/config-entity.js +955 -0
- package/client/pages/entity/main-menu-selector.js +245 -0
- package/client/pages/history/history-copy-list-popup.js +145 -0
- package/client/pages/history/history-json-list-popup.js +159 -0
- package/client/pages/menu/dynamic-menu-template.js +92 -0
- package/client/pages/menu/dynamic-menu.ts +744 -0
- package/client/pages/menu/export-menu-popup.js +468 -0
- package/client/pages/meta-form-element.js +9 -0
- package/client/pages/meta-grist-element.js +12 -0
- package/client/pages/meta-grist-page.js +16 -0
- package/client/pages/meta-grist-tab-element.js +16 -0
- package/client/pages/meta-grist-tab-page.js +16 -0
- package/client/pages/meta-main-tab-element.js +12 -0
- package/client/pages/meta-main-tab-page.js +16 -0
- package/client/pages/meta-master-detail-element.js +12 -0
- package/client/pages/meta-master-detail-page.js +16 -0
- package/client/pages/meta-tab-detail-element.js +12 -0
- package/client/pages/meta-tab-detail-page.js +16 -0
- package/client/pages/meta-tab-element.js +15 -0
- package/client/pages/printer-device/printer-device-page.js +24 -0
- package/client/pages/template/doc-template-page.js +24 -0
- package/client/pages/template/template-file-page.js +24 -0
- package/client/pages/terms/config-terminology.js +214 -0
- package/client/pages/work-code/work-code-detail-popup.js +16 -0
- package/client/pages/work-code/work-code-page.js +23 -0
- package/client/route.ts +36 -0
- package/client/tsconfig.json +13 -0
- package/client/utils/grist-default-value.js +36 -0
- package/client/utils/meta-api.js +811 -0
- package/client/utils/meta-crypto.js +52 -0
- package/client/utils/meta-ui-util.js +3304 -0
- package/client/utils/rest-service-util.js +328 -0
- package/client/utils/service-util.js +1327 -0
- package/client/utils/terms-util.ts +119 -0
- package/client/utils/ui-util.js +338 -0
- package/client/utils/value-util.js +234 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/service-util.d.ts +2 -2
- package/dist-client/utils/service-util.js +4 -4
- package/dist-client/utils/service-util.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -24
- package/server/activity/CommonActivity.ts +68 -0
- package/server/index.ts +3 -0
- package/server/routes.ts +61 -0
- package/server/service/button-role/button-role-mutation.ts +105 -0
- package/server/service/button-role/button-role-query.ts +53 -0
- package/server/service/button-role/button-role-type.ts +39 -0
- package/server/service/button-role/button-role.ts +61 -0
- package/server/service/button-role/index.ts +7 -0
- package/server/service/dynamic-menu/dynamic-menu-query.ts +270 -0
- package/server/service/dynamic-menu/dynamic-menu-type.ts +74 -0
- package/server/service/dynamic-menu/index.ts +3 -0
- package/server/service/entity-event-subscriber/entity-event-subscriber.ts +80 -0
- package/server/service/entity-event-subscriber/index.ts +3 -0
- package/server/service/index.ts +41 -0
- package/server/service/menu-button-auth/index.ts +7 -0
- package/server/service/menu-button-auth/menu-button-auth-mutation.ts +133 -0
- package/server/service/menu-button-auth/menu-button-auth-query.ts +138 -0
- package/server/service/menu-button-auth/menu-button-auth-type.ts +63 -0
- package/server/service/menu-button-auth/menu-button-auth.ts +92 -0
- package/server/service/meta-activity/index.ts +5 -0
- package/server/service/meta-activity/meta-activity-mutation.ts +191 -0
- package/server/service/meta-activity/meta-activity-query.ts +43 -0
- package/server/service/meta-activity/meta-activity-type.ts +56 -0
- package/server/service/set-translations/index.ts +3 -0
- package/server/service/set-translations/set-translation-resolver.ts +63 -0
- package/server/service/work-code/index.ts +6 -0
- package/server/service/work-code/work-code-mutation.ts +147 -0
- package/server/service/work-code/work-code-query.ts +67 -0
- package/server/service/work-code/work-code-type.ts +60 -0
- package/server/service/work-code/work-code.ts +83 -0
- package/server/service/work-code-detail/index.ts +6 -0
- package/server/service/work-code-detail/work-code-detail-mutation.ts +149 -0
- package/server/service/work-code-detail/work-code-detail-query.ts +59 -0
- package/server/service/work-code-detail/work-code-detail-type.ts +50 -0
- package/server/service/work-code-detail/work-code-detail.ts +82 -0
- package/server/tsconfig.json +9 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { IsNull, Not } from 'typeorm'
|
|
3
|
+
import {
|
|
4
|
+
Domain,
|
|
5
|
+
ListParam,
|
|
6
|
+
convertListParams,
|
|
7
|
+
getRepository,
|
|
8
|
+
getQueryBuilderFromListParams
|
|
9
|
+
} from '@things-factory/shell'
|
|
10
|
+
import { User } from '@things-factory/auth-base'
|
|
11
|
+
import { MenuButtonAuth } from './menu-button-auth'
|
|
12
|
+
import { MenuButtonAuthList } from './menu-button-auth-type'
|
|
13
|
+
import { Menu } from '@things-factory/menu-base'
|
|
14
|
+
import { ButtonRole } from './../button-role/button-role'
|
|
15
|
+
|
|
16
|
+
@Resolver(MenuButtonAuth)
|
|
17
|
+
export class MenuButtonAuthQuery {
|
|
18
|
+
@Query(returns => MenuButtonAuth, { description: 'To fetch a MenuButtonAuth' })
|
|
19
|
+
async menuButtonAuth(@Arg('id') id: string, @Ctx() context: any): Promise<MenuButtonAuth> {
|
|
20
|
+
const { domain } = context.state
|
|
21
|
+
return await getRepository(MenuButtonAuth).findOne({
|
|
22
|
+
where: { domain: { id: domain.id }, id }
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Query(returns => MenuButtonAuthList, { description: 'To fetch a multiple MenuButtonAuth' })
|
|
27
|
+
async menuButtonAuths(@Args(type => ListParam) params: ListParam, @Ctx() context: any): Promise<MenuButtonAuthList> {
|
|
28
|
+
const { domain } = context.state
|
|
29
|
+
|
|
30
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
31
|
+
domain,
|
|
32
|
+
params,
|
|
33
|
+
repository: await getRepository(MenuButtonAuth)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
37
|
+
|
|
38
|
+
return { items, total }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Query(returns => MenuButtonAuthList, { description: 'To fetch a multiple RoleMenuButtonAuth' })
|
|
42
|
+
async roleMenuButtonAuths(
|
|
43
|
+
@Args(type => ListParam) params: ListParam,
|
|
44
|
+
@Ctx() context: any
|
|
45
|
+
): Promise<MenuButtonAuthList> {
|
|
46
|
+
const { domain } = context.state
|
|
47
|
+
const roleId = params.filters.find(x => x.name == 'roleId').value
|
|
48
|
+
const parentMenuId = params.filters.some(x => x.name == 'menuId')
|
|
49
|
+
? params.filters.find(x => x.name == 'menuId').value
|
|
50
|
+
: undefined
|
|
51
|
+
|
|
52
|
+
// 기존 role 권한 조회
|
|
53
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
54
|
+
domain,
|
|
55
|
+
params,
|
|
56
|
+
repository: await getRepository(MenuButtonAuth)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
60
|
+
|
|
61
|
+
// 메뉴 리스트 조회
|
|
62
|
+
let menuParams = {
|
|
63
|
+
where: {
|
|
64
|
+
domain: {
|
|
65
|
+
id: domain.id
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
order: { rank: 'ASC' }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (parentMenuId) {
|
|
72
|
+
menuParams.where['parent'] = {
|
|
73
|
+
id: parentMenuId
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
menuParams.where['parent'] = Not(IsNull())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const menus: Menu[] = await getRepository(Menu).find(menuParams as any)
|
|
80
|
+
|
|
81
|
+
let results: MenuButtonAuth[] = []
|
|
82
|
+
|
|
83
|
+
menus.forEach(menu => {
|
|
84
|
+
let menuRole = {
|
|
85
|
+
id: menu.id,
|
|
86
|
+
menu: menu,
|
|
87
|
+
menuId: menu.id,
|
|
88
|
+
roleId: roleId,
|
|
89
|
+
role: { id: roleId, name: '', description: '', domain: domain, domainId: domain.id },
|
|
90
|
+
domain: domain,
|
|
91
|
+
domainId: domain.id,
|
|
92
|
+
selectAuth: false,
|
|
93
|
+
createAuth: false,
|
|
94
|
+
updateAuth: false,
|
|
95
|
+
deleteAuth: false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (items.some(x => x.menuId == menu.id)) {
|
|
99
|
+
let menuAuth = items.find(x => x.menuId == menu.id)
|
|
100
|
+
|
|
101
|
+
menuRole.id = menuAuth.id
|
|
102
|
+
menuRole.selectAuth = menuAuth.selectAuth
|
|
103
|
+
menuRole.updateAuth = menuAuth.updateAuth
|
|
104
|
+
menuRole.createAuth = menuAuth.createAuth
|
|
105
|
+
menuRole.deleteAuth = menuAuth.deleteAuth
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
results.push(menuRole)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
return { items: results, total: 0 }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@FieldResolver(type => ButtonRole)
|
|
115
|
+
async role(@Root() menuButtonAuth: MenuButtonAuth): Promise<ButtonRole> {
|
|
116
|
+
return await getRepository(ButtonRole).findOneBy({ id: menuButtonAuth.roleId })
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@FieldResolver(type => Menu)
|
|
120
|
+
async menu(@Root() menuButtonAuth: MenuButtonAuth): Promise<Menu> {
|
|
121
|
+
return await getRepository(Menu).findOneBy({ id: menuButtonAuth.menuId })
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@FieldResolver(type => Domain)
|
|
125
|
+
async domain(@Root() menuButtonAuth: MenuButtonAuth): Promise<Domain> {
|
|
126
|
+
return await getRepository(Domain).findOneBy({ id: menuButtonAuth.domainId })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@FieldResolver(type => User)
|
|
130
|
+
async updater(@Root() menuButtonAuth: MenuButtonAuth): Promise<User> {
|
|
131
|
+
return await getRepository(User).findOneBy({ id: menuButtonAuth.updaterId })
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@FieldResolver(type => User)
|
|
135
|
+
async creator(@Root() menuButtonAuth: MenuButtonAuth): Promise<User> {
|
|
136
|
+
return await getRepository(User).findOneBy({ id: menuButtonAuth.creatorId })
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
import { ObjectType, Field, InputType, Int, ID, Float, registerEnumType } from 'type-graphql'
|
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
import { MenuButtonAuth } from './menu-button-auth'
|
|
6
|
+
|
|
7
|
+
@InputType()
|
|
8
|
+
export class NewMenuButtonAuth {
|
|
9
|
+
|
|
10
|
+
@Field(type => ObjectRef)
|
|
11
|
+
role: ObjectRef
|
|
12
|
+
|
|
13
|
+
@Field(type => ObjectRef)
|
|
14
|
+
menu: ObjectRef
|
|
15
|
+
|
|
16
|
+
@Field({ nullable: false })
|
|
17
|
+
selectAuth?: boolean
|
|
18
|
+
|
|
19
|
+
@Field({ nullable: true })
|
|
20
|
+
createAuth?: boolean
|
|
21
|
+
|
|
22
|
+
@Field({ nullable: true })
|
|
23
|
+
updateAuth?: boolean
|
|
24
|
+
|
|
25
|
+
@Field({ nullable: true })
|
|
26
|
+
deleteAuth?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@InputType()
|
|
30
|
+
export class MenuButtonAuthPatch {
|
|
31
|
+
@Field(type => ID, { nullable: true })
|
|
32
|
+
id?: string
|
|
33
|
+
|
|
34
|
+
@Field(type => ObjectRef)
|
|
35
|
+
role: ObjectRef
|
|
36
|
+
|
|
37
|
+
@Field(type => ObjectRef)
|
|
38
|
+
menu: ObjectRef
|
|
39
|
+
|
|
40
|
+
@Field({ nullable: false })
|
|
41
|
+
selectAuth?: boolean
|
|
42
|
+
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
createAuth?: boolean
|
|
45
|
+
|
|
46
|
+
@Field({ nullable: true })
|
|
47
|
+
updateAuth?: boolean
|
|
48
|
+
|
|
49
|
+
@Field({ nullable: true })
|
|
50
|
+
deleteAuth?: boolean
|
|
51
|
+
|
|
52
|
+
@Field()
|
|
53
|
+
cuFlag: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@ObjectType()
|
|
57
|
+
export class MenuButtonAuthList {
|
|
58
|
+
@Field(type => [MenuButtonAuth])
|
|
59
|
+
items: MenuButtonAuth[]
|
|
60
|
+
|
|
61
|
+
@Field(type => Int)
|
|
62
|
+
total: number
|
|
63
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
Index,
|
|
6
|
+
Column,
|
|
7
|
+
RelationId,
|
|
8
|
+
ManyToOne,
|
|
9
|
+
OneToMany,
|
|
10
|
+
PrimaryGeneratedColumn
|
|
11
|
+
} from 'typeorm'
|
|
12
|
+
import { ObjectType, Field, Int, ID, Float, registerEnumType } from 'type-graphql'
|
|
13
|
+
|
|
14
|
+
import { Domain } from '@things-factory/shell'
|
|
15
|
+
import { User } from '@things-factory/auth-base'
|
|
16
|
+
import { Menu } from '@things-factory/menu-base'
|
|
17
|
+
import { ButtonRole } from './../button-role/button-role'
|
|
18
|
+
|
|
19
|
+
@Entity('menu_button_auth')
|
|
20
|
+
@Index(
|
|
21
|
+
'ix_menu_button_auth_0',
|
|
22
|
+
(menuButtonAuth: MenuButtonAuth) => [menuButtonAuth.domain, menuButtonAuth.role, menuButtonAuth.menu],
|
|
23
|
+
{ unique: true }
|
|
24
|
+
)
|
|
25
|
+
@Index('ix_menu_button_auth_1', (menuButtonAuth: MenuButtonAuth) => [menuButtonAuth.domain, menuButtonAuth.role], {
|
|
26
|
+
unique: false
|
|
27
|
+
})
|
|
28
|
+
@ObjectType({ description: 'Entity for MenuButtonAuth' })
|
|
29
|
+
export class MenuButtonAuth {
|
|
30
|
+
@PrimaryGeneratedColumn('uuid')
|
|
31
|
+
@Field(type => ID)
|
|
32
|
+
readonly id: string
|
|
33
|
+
|
|
34
|
+
@ManyToOne(type => ButtonRole, { createForeignKeyConstraints: false, nullable: false })
|
|
35
|
+
@Field({ nullable: false })
|
|
36
|
+
role: ButtonRole
|
|
37
|
+
|
|
38
|
+
@RelationId((menuButtonAuth: MenuButtonAuth) => menuButtonAuth.role)
|
|
39
|
+
roleId: string
|
|
40
|
+
|
|
41
|
+
@ManyToOne(type => Menu, { createForeignKeyConstraints: false, nullable: false })
|
|
42
|
+
@Field({ nullable: false })
|
|
43
|
+
menu: Menu
|
|
44
|
+
|
|
45
|
+
@RelationId((menuButtonAuth: MenuButtonAuth) => menuButtonAuth.menu)
|
|
46
|
+
menuId: string
|
|
47
|
+
|
|
48
|
+
@Column({ name: 'select_auth', type: 'boolean', nullable: true, default: false })
|
|
49
|
+
@Field({ nullable: true })
|
|
50
|
+
selectAuth?: boolean
|
|
51
|
+
|
|
52
|
+
@Column({ name: 'create_auth', type: 'boolean', nullable: true, default: false })
|
|
53
|
+
@Field({ nullable: true })
|
|
54
|
+
createAuth?: boolean
|
|
55
|
+
|
|
56
|
+
@Column({ name: 'update_auth', type: 'boolean', nullable: true, default: false })
|
|
57
|
+
@Field({ nullable: true })
|
|
58
|
+
updateAuth?: boolean
|
|
59
|
+
|
|
60
|
+
@Column({ name: 'delete_auth', type: 'boolean', nullable: true, default: false })
|
|
61
|
+
@Field({ nullable: true })
|
|
62
|
+
deleteAuth?: boolean
|
|
63
|
+
|
|
64
|
+
@ManyToOne(type => Domain)
|
|
65
|
+
@Field(type => Domain, { nullable: false })
|
|
66
|
+
domain: Domain
|
|
67
|
+
|
|
68
|
+
@RelationId((menuButtonAuth: MenuButtonAuth) => menuButtonAuth.domain)
|
|
69
|
+
domainId: string
|
|
70
|
+
|
|
71
|
+
@CreateDateColumn()
|
|
72
|
+
@Field({ nullable: true })
|
|
73
|
+
createdAt?: Date
|
|
74
|
+
|
|
75
|
+
@UpdateDateColumn()
|
|
76
|
+
@Field({ nullable: true })
|
|
77
|
+
updatedAt?: Date
|
|
78
|
+
|
|
79
|
+
@ManyToOne(type => User, { createForeignKeyConstraints: false, nullable: true })
|
|
80
|
+
@Field(type => User, { nullable: true })
|
|
81
|
+
creator?: User
|
|
82
|
+
|
|
83
|
+
@RelationId((menuButtonAuth: MenuButtonAuth) => menuButtonAuth.creator)
|
|
84
|
+
creatorId?: string
|
|
85
|
+
|
|
86
|
+
@ManyToOne(type => User, { createForeignKeyConstraints: false, nullable: true })
|
|
87
|
+
@Field(type => User, { nullable: true })
|
|
88
|
+
updater?: User
|
|
89
|
+
|
|
90
|
+
@RelationId((menuButtonAuth: MenuButtonAuth) => menuButtonAuth.updater)
|
|
91
|
+
updaterId?: string
|
|
92
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
import { ActivityInstallations, Activity, ActivityStatus, ActivityTemplate } from '@things-factory/worklist'
|
|
4
|
+
import { MetaActivityPatch } from './meta-activity-type'
|
|
5
|
+
import { Menu } from '@things-factory/menu-base'
|
|
6
|
+
import { callback } from './../../activity/CommonActivity'
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const { appRootPath } = require('@things-factory/env')
|
|
9
|
+
const AppPackage = require(path.resolve(appRootPath, 'package.json'))
|
|
10
|
+
|
|
11
|
+
@Resolver(Activity)
|
|
12
|
+
export class MetaActivityMutation {
|
|
13
|
+
async findMenuModel(tx: any, menuObj: any) {
|
|
14
|
+
if (!menuObj) return []
|
|
15
|
+
|
|
16
|
+
let menu = await tx.getRepository(Menu).findOne({ where: { id: menuObj.id } })
|
|
17
|
+
if (!menu) return []
|
|
18
|
+
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: 'relation-menu',
|
|
22
|
+
description: JSON.stringify({
|
|
23
|
+
id: menu.id,
|
|
24
|
+
name: menu.name,
|
|
25
|
+
routing: menu.routing
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'customData',
|
|
30
|
+
inout: 'inout'
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async removeActivityTemplate(activity: Activity) {
|
|
36
|
+
if (activity) {
|
|
37
|
+
if (ActivityInstallations.get(activity.name)) {
|
|
38
|
+
delete ActivityInstallations.templates[activity.name]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async addActivityTemplate(activity: Activity) {
|
|
44
|
+
if (activity.state == ActivityStatus.Released) {
|
|
45
|
+
ActivityInstallations.installActivityTemplate({
|
|
46
|
+
name: `${activity.name}`,
|
|
47
|
+
release: AppPackage.version,
|
|
48
|
+
description: activity.description,
|
|
49
|
+
provider: AppPackage.provider,
|
|
50
|
+
// category: activity.category,
|
|
51
|
+
activityType: activity.activityType,
|
|
52
|
+
priority: activity.priority,
|
|
53
|
+
// searchKeys: [],
|
|
54
|
+
// startable: true,
|
|
55
|
+
startingType: activity.startingType,
|
|
56
|
+
model: activity.model,
|
|
57
|
+
uiType: activity.uiType,
|
|
58
|
+
uiSource: activity.uiSource,
|
|
59
|
+
viewType: activity.viewType,
|
|
60
|
+
viewSource: activity.viewSource,
|
|
61
|
+
activity: activity,
|
|
62
|
+
callback
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Directive('@transaction')
|
|
68
|
+
@Directive('@privilege(category: "activity", privilege: "mutation", domainOwnerGranted: true)')
|
|
69
|
+
@Mutation(returns => [Activity], { description: "To modify multiple MetaActivities' information" })
|
|
70
|
+
async updateMultipleMetaActivity(
|
|
71
|
+
@Arg('patches', type => [MetaActivityPatch]) patches: MetaActivityPatch[],
|
|
72
|
+
@Ctx() context: ResolverContext
|
|
73
|
+
): Promise<Activity[]> {
|
|
74
|
+
const { domain, user, tx } = context.state
|
|
75
|
+
|
|
76
|
+
let results = []
|
|
77
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
78
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
79
|
+
const activityRepo = tx.getRepository(Activity)
|
|
80
|
+
|
|
81
|
+
if (_createRecords.length > 0) {
|
|
82
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
83
|
+
const newRecord = _createRecords[i]
|
|
84
|
+
let model = await this.findMenuModel(tx, newRecord.menu)
|
|
85
|
+
const trxRecord = {
|
|
86
|
+
...newRecord,
|
|
87
|
+
model,
|
|
88
|
+
domain,
|
|
89
|
+
creator: user,
|
|
90
|
+
updater: user
|
|
91
|
+
}
|
|
92
|
+
const result = await activityRepo.save(trxRecord as any)
|
|
93
|
+
results.push({ ...result, cuFlag: '+' })
|
|
94
|
+
this.addActivityTemplate(trxRecord as any)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (_updateRecords.length > 0) {
|
|
99
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
100
|
+
const updateRecord = _updateRecords[i]
|
|
101
|
+
let model = await this.findMenuModel(tx, updateRecord.menu)
|
|
102
|
+
const activity = await activityRepo.findOne({
|
|
103
|
+
where: { id: updateRecord.id },
|
|
104
|
+
/* history에 항상 반영될 수 있도록 relations가 있어야 함. */
|
|
105
|
+
relations: ['domain', 'creator', 'updater']
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const trxRecord = {
|
|
109
|
+
...activity,
|
|
110
|
+
...updateRecord,
|
|
111
|
+
model,
|
|
112
|
+
updater: user
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const result = await activityRepo.save(trxRecord as any)
|
|
116
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
117
|
+
this.addActivityTemplate(trxRecord as any)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return results
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@Directive('@transaction')
|
|
125
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple MetaActivities' })
|
|
126
|
+
async deleteMetaActivities(
|
|
127
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
128
|
+
@Ctx() context: ResolverContext
|
|
129
|
+
): Promise<boolean> {
|
|
130
|
+
const { domain, tx } = context.state
|
|
131
|
+
|
|
132
|
+
let activityRepo = tx.getRepository(Activity)
|
|
133
|
+
let deleteActivities: Activity[] = []
|
|
134
|
+
for (let i = 0; i < ids.length; i++) {
|
|
135
|
+
deleteActivities.push(
|
|
136
|
+
await activityRepo.findOne({
|
|
137
|
+
where: { id: ids[i] }
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
await tx.getRepository(Activity).delete({
|
|
143
|
+
domain: { id: domain.id },
|
|
144
|
+
id: In(ids)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < deleteActivities.length; i++) {
|
|
148
|
+
await this.removeActivityTemplate(deleteActivities[i])
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Directive('@transaction')
|
|
155
|
+
@Mutation(returns => Boolean, { description: 'To install Activity Templates' })
|
|
156
|
+
async installActivityTemplate(@Ctx() context: ResolverContext): Promise<Boolean> {
|
|
157
|
+
const { domain, tx } = context.state
|
|
158
|
+
const releaseActivityTemplates: Activity[] = await tx.getRepository(Activity).find({
|
|
159
|
+
where: {
|
|
160
|
+
domain: { id: domain.id },
|
|
161
|
+
state: ActivityStatus.Released
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
;(releaseActivityTemplates || []).forEach(activity => {
|
|
166
|
+
if (activity.model && activity.model.some(x => x.name == 'relation-menu')) {
|
|
167
|
+
ActivityInstallations.installActivityTemplate({
|
|
168
|
+
name: `${activity.name}`,
|
|
169
|
+
release: AppPackage.version,
|
|
170
|
+
description: activity.description,
|
|
171
|
+
provider: AppPackage.provider,
|
|
172
|
+
// category: activity.category,
|
|
173
|
+
activityType: activity.activityType,
|
|
174
|
+
priority: activity.priority,
|
|
175
|
+
// searchKeys: [],
|
|
176
|
+
// startable: true,
|
|
177
|
+
startingType: activity.startingType,
|
|
178
|
+
model: activity.model,
|
|
179
|
+
uiType: activity.uiType,
|
|
180
|
+
uiSource: activity.uiSource,
|
|
181
|
+
viewType: activity.viewType,
|
|
182
|
+
viewSource: activity.viewSource,
|
|
183
|
+
activity: activity,
|
|
184
|
+
callback
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
return true
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
+
import { User } from '@things-factory/auth-base'
|
|
3
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { Activity } from '@things-factory/worklist'
|
|
5
|
+
import { MetaActivityList } from './meta-activity-type'
|
|
6
|
+
|
|
7
|
+
@Resolver(Activity)
|
|
8
|
+
export class MetaActivityQuery {
|
|
9
|
+
@Query(returns => MetaActivityList, { description: 'To fetch multiple Activities' })
|
|
10
|
+
async metaActivities(
|
|
11
|
+
@Args(type => ListParam) params: ListParam,
|
|
12
|
+
@Ctx() context: ResolverContext
|
|
13
|
+
): Promise<MetaActivityList> {
|
|
14
|
+
const { domain } = context.state
|
|
15
|
+
|
|
16
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
17
|
+
domain,
|
|
18
|
+
params,
|
|
19
|
+
repository: getRepository(Activity),
|
|
20
|
+
alias: 'activity',
|
|
21
|
+
searchables: ['name', 'description', 'model']
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
25
|
+
|
|
26
|
+
return { items, total }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@FieldResolver(type => Domain)
|
|
30
|
+
async domain(@Root() activity: Activity): Promise<Domain> {
|
|
31
|
+
return await getRepository(Domain).findOneBy({ id: activity.domainId })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@FieldResolver(type => User)
|
|
35
|
+
async updater(@Root() activity: Activity): Promise<User> {
|
|
36
|
+
return await getRepository(User).findOneBy({ id: activity.updaterId })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@FieldResolver(type => User)
|
|
40
|
+
async creator(@Root() activity: Activity): Promise<User> {
|
|
41
|
+
return await getRepository(User).findOneBy({ id: activity.creatorId })
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
import { ObjectType, Field, InputType, Int, ID, Float, registerEnumType } from 'type-graphql'
|
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
|
4
|
+
import { Activity } from '@things-factory/worklist'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@InputType()
|
|
8
|
+
export class MetaActivityPatch {
|
|
9
|
+
@Field(type => ID, { nullable: true })
|
|
10
|
+
id?: string
|
|
11
|
+
|
|
12
|
+
@Field({ nullable: true })
|
|
13
|
+
name?: string
|
|
14
|
+
|
|
15
|
+
@Field({ nullable: true })
|
|
16
|
+
description?: string
|
|
17
|
+
|
|
18
|
+
@Field({ nullable: true })
|
|
19
|
+
state?: string
|
|
20
|
+
|
|
21
|
+
@Field(type => ObjectRef, { nullable: true })
|
|
22
|
+
menu?: ObjectRef
|
|
23
|
+
|
|
24
|
+
@Field({ nullable: true })
|
|
25
|
+
activityType?: string
|
|
26
|
+
|
|
27
|
+
@Field({ nullable: true })
|
|
28
|
+
startingType?: string
|
|
29
|
+
|
|
30
|
+
@Field({ nullable: true })
|
|
31
|
+
multiple?: string
|
|
32
|
+
|
|
33
|
+
@Field({ nullable: true })
|
|
34
|
+
uiType?: string
|
|
35
|
+
|
|
36
|
+
@Field({ nullable: true })
|
|
37
|
+
uiSource?: string
|
|
38
|
+
|
|
39
|
+
@Field({ nullable: true })
|
|
40
|
+
viewType?: string
|
|
41
|
+
|
|
42
|
+
@Field({ nullable: true })
|
|
43
|
+
viewSource?: string
|
|
44
|
+
|
|
45
|
+
@Field()
|
|
46
|
+
cuFlag: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ObjectType()
|
|
50
|
+
export class MetaActivityList {
|
|
51
|
+
@Field(type => [Activity])
|
|
52
|
+
items: Activity[]
|
|
53
|
+
|
|
54
|
+
@Field(type => Int)
|
|
55
|
+
total: number
|
|
56
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { resolve, join } from 'path'
|
|
3
|
+
|
|
4
|
+
import { Arg, Query, Resolver } from 'type-graphql'
|
|
5
|
+
|
|
6
|
+
@Resolver()
|
|
7
|
+
export class SetTranslationResolver {
|
|
8
|
+
@Query(returns => Boolean, { description: 'To save terms for entity columns in JSON files' })
|
|
9
|
+
async setTranslations(
|
|
10
|
+
@Arg('bundle') bundle: string,
|
|
11
|
+
@Arg('terms', type => [String]) terms: string[]
|
|
12
|
+
): Promise<Boolean> {
|
|
13
|
+
return await syncTranslationFiles(bundle, terms)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function syncTranslationFiles(bundle, terms) {
|
|
18
|
+
const PACKAGES_PATH = getPackageRootPath();
|
|
19
|
+
const TRANSLATIONS_DIR_NAME = 'translations'
|
|
20
|
+
const JSON_EXT = 'json'
|
|
21
|
+
|
|
22
|
+
const TRANSLATIONS_PATH = join(PACKAGES_PATH, bundle, TRANSLATIONS_DIR_NAME)
|
|
23
|
+
|
|
24
|
+
const fileList = fs.readdirSync(TRANSLATIONS_PATH)
|
|
25
|
+
fileList.forEach(file => {
|
|
26
|
+
const ext = file.split('.').pop().toLowerCase()
|
|
27
|
+
if (ext === JSON_EXT) {
|
|
28
|
+
const translationFile = fs.readFileSync(join(TRANSLATIONS_PATH, file))
|
|
29
|
+
const translations = JSON.parse(translationFile.toString())
|
|
30
|
+
|
|
31
|
+
terms.forEach(term => {
|
|
32
|
+
if (!(term in translations)) {
|
|
33
|
+
const text = term.split('.').pop()
|
|
34
|
+
translations[term] = text.replaceAll('_', ' ')
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const updatedTranslations = JSON.stringify(translations, null, '\t')
|
|
39
|
+
fs.writeFileSync(join(TRANSLATIONS_PATH, file), updatedTranslations)
|
|
40
|
+
} else return
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 프로젝트 Package Path 구하기
|
|
48
|
+
* @returns String
|
|
49
|
+
*/
|
|
50
|
+
function getPackageRootPath() {
|
|
51
|
+
let appPath: string = process.env.PWD;
|
|
52
|
+
let splitPath: string[] = appPath.split('/');
|
|
53
|
+
let pathArr: string[] = [];
|
|
54
|
+
for (let i = 0; i < splitPath.length; i++) {
|
|
55
|
+
pathArr.push(splitPath[i]);
|
|
56
|
+
|
|
57
|
+
if (splitPath[i] == 'packages') {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return pathArr.join('/');
|
|
63
|
+
}
|