@things-factory/meta-ui 8.0.39 → 9.0.0-9.0.0-beta.59.0

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.
Files changed (119) hide show
  1. package/dist-client/bootstrap.d.ts +5 -5
  2. package/dist-client/bootstrap.js +20 -20
  3. package/dist-client/bootstrap.js.map +1 -1
  4. package/dist-client/tsconfig.tsbuildinfo +1 -1
  5. package/dist-client/utils/service-util.d.ts +2 -2
  6. package/dist-client/utils/service-util.js +4 -4
  7. package/dist-client/utils/service-util.js.map +1 -1
  8. package/dist-server/service/index.d.ts +2 -2
  9. package/dist-server/tsconfig.tsbuildinfo +1 -1
  10. package/package.json +24 -24
  11. package/client/bootstrap.ts +0 -170
  12. package/client/component/filter/filter-form-meta-code-select.ts +0 -102
  13. package/client/component/filter/filter-form-meta-object-select.ts +0 -107
  14. package/client/component/filter/filter-grist-meta-code-select.ts +0 -97
  15. package/client/component/filter/filter-grist-meta-object-select.ts +0 -102
  16. package/client/component/grist/editor/grist-editor-code-input.js +0 -96
  17. package/client/component/grist/editor/grist-editor-meta-code-selector.js +0 -157
  18. package/client/component/grist/editor/grist-editor-meta-object-selector.js +0 -122
  19. package/client/component/grist/renderer/grist-renderer-code-input.js +0 -20
  20. package/client/component/grist/renderer/grist-renderer-meta-code-selector.js +0 -28
  21. package/client/component/grist/renderer/grist-renderer-meta-object-selector.js +0 -25
  22. package/client/component/popup/code-input-editor-popup.js +0 -111
  23. package/client/component/popup/file-upload-popup.js +0 -129
  24. package/client/component/popup/meta-object-selector-popup.ts +0 -356
  25. package/client/component/popup/record-based-code-editor-popup.ts +0 -141
  26. package/client/dynamic-menus.ts +0 -38
  27. package/client/index.ts +0 -18
  28. package/client/load-components.ts +0 -17
  29. package/client/mixin/meta-base-mixin.js +0 -323
  30. package/client/mixin/meta-basic-grist-mixin.js +0 -283
  31. package/client/mixin/meta-button-mixin.js +0 -116
  32. package/client/mixin/meta-form-mixin.js +0 -435
  33. package/client/mixin/meta-grist-tab-mixin.js +0 -335
  34. package/client/mixin/meta-main-tab-mixin.js +0 -267
  35. package/client/mixin/meta-master-detail-mixin.js +0 -395
  36. package/client/mixin/meta-service-mixin.js +0 -306
  37. package/client/mixin/meta-tab-detail-mixin.js +0 -283
  38. package/client/mixin/meta-tab-mixin.js +0 -190
  39. package/client/pages/activity/meta-activity-define-page.js +0 -422
  40. package/client/pages/activity/meta-activity-list-page.js +0 -262
  41. package/client/pages/activity/meta-activity-viewer-element.js +0 -35
  42. package/client/pages/activity/meta-activity-writer-element.js +0 -48
  43. package/client/pages/activity/meta-activiy-mixin.js +0 -79
  44. package/client/pages/button-role/button-role-detail.js +0 -50
  45. package/client/pages/button-role/button-role-page.js +0 -25
  46. package/client/pages/doc-number/doc-number-page.js +0 -24
  47. package/client/pages/doc-number/next-doc-number-popup.js +0 -25
  48. package/client/pages/entity/config-entity.js +0 -955
  49. package/client/pages/entity/main-menu-selector.js +0 -245
  50. package/client/pages/history/history-copy-list-popup.js +0 -145
  51. package/client/pages/history/history-json-list-popup.js +0 -159
  52. package/client/pages/menu/dynamic-menu-template.js +0 -92
  53. package/client/pages/menu/dynamic-menu.ts +0 -744
  54. package/client/pages/menu/export-menu-popup.js +0 -468
  55. package/client/pages/meta-form-element.js +0 -9
  56. package/client/pages/meta-grist-element.js +0 -12
  57. package/client/pages/meta-grist-page.js +0 -16
  58. package/client/pages/meta-grist-tab-element.js +0 -16
  59. package/client/pages/meta-grist-tab-page.js +0 -16
  60. package/client/pages/meta-main-tab-element.js +0 -12
  61. package/client/pages/meta-main-tab-page.js +0 -16
  62. package/client/pages/meta-master-detail-element.js +0 -12
  63. package/client/pages/meta-master-detail-page.js +0 -16
  64. package/client/pages/meta-tab-detail-element.js +0 -12
  65. package/client/pages/meta-tab-detail-page.js +0 -16
  66. package/client/pages/meta-tab-element.js +0 -15
  67. package/client/pages/printer-device/printer-device-page.js +0 -24
  68. package/client/pages/template/doc-template-page.js +0 -24
  69. package/client/pages/template/template-file-page.js +0 -24
  70. package/client/pages/terms/config-terminology.js +0 -214
  71. package/client/pages/work-code/work-code-detail-popup.js +0 -16
  72. package/client/pages/work-code/work-code-page.js +0 -23
  73. package/client/route.ts +0 -36
  74. package/client/tsconfig.json +0 -13
  75. package/client/utils/grist-default-value.js +0 -36
  76. package/client/utils/meta-api.js +0 -811
  77. package/client/utils/meta-crypto.js +0 -52
  78. package/client/utils/meta-ui-util.js +0 -3304
  79. package/client/utils/rest-service-util.js +0 -328
  80. package/client/utils/service-util.js +0 -1327
  81. package/client/utils/terms-util.ts +0 -119
  82. package/client/utils/ui-util.js +0 -338
  83. package/client/utils/value-util.js +0 -234
  84. package/server/activity/CommonActivity.ts +0 -68
  85. package/server/index.ts +0 -3
  86. package/server/routes.ts +0 -61
  87. package/server/service/button-role/button-role-mutation.ts +0 -105
  88. package/server/service/button-role/button-role-query.ts +0 -53
  89. package/server/service/button-role/button-role-type.ts +0 -39
  90. package/server/service/button-role/button-role.ts +0 -61
  91. package/server/service/button-role/index.ts +0 -7
  92. package/server/service/dynamic-menu/dynamic-menu-query.ts +0 -270
  93. package/server/service/dynamic-menu/dynamic-menu-type.ts +0 -74
  94. package/server/service/dynamic-menu/index.ts +0 -3
  95. package/server/service/entity-event-subscriber/entity-event-subscriber.ts +0 -80
  96. package/server/service/entity-event-subscriber/index.ts +0 -3
  97. package/server/service/index.ts +0 -41
  98. package/server/service/menu-button-auth/index.ts +0 -7
  99. package/server/service/menu-button-auth/menu-button-auth-mutation.ts +0 -133
  100. package/server/service/menu-button-auth/menu-button-auth-query.ts +0 -138
  101. package/server/service/menu-button-auth/menu-button-auth-type.ts +0 -63
  102. package/server/service/menu-button-auth/menu-button-auth.ts +0 -92
  103. package/server/service/meta-activity/index.ts +0 -5
  104. package/server/service/meta-activity/meta-activity-mutation.ts +0 -191
  105. package/server/service/meta-activity/meta-activity-query.ts +0 -43
  106. package/server/service/meta-activity/meta-activity-type.ts +0 -56
  107. package/server/service/set-translations/index.ts +0 -3
  108. package/server/service/set-translations/set-translation-resolver.ts +0 -63
  109. package/server/service/work-code/index.ts +0 -6
  110. package/server/service/work-code/work-code-mutation.ts +0 -147
  111. package/server/service/work-code/work-code-query.ts +0 -67
  112. package/server/service/work-code/work-code-type.ts +0 -60
  113. package/server/service/work-code/work-code.ts +0 -83
  114. package/server/service/work-code-detail/index.ts +0 -6
  115. package/server/service/work-code-detail/work-code-detail-mutation.ts +0 -149
  116. package/server/service/work-code-detail/work-code-detail-query.ts +0 -59
  117. package/server/service/work-code-detail/work-code-detail-type.ts +0 -50
  118. package/server/service/work-code-detail/work-code-detail.ts +0 -82
  119. package/server/tsconfig.json +0 -9
@@ -1,191 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
- }
@@ -1,56 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- import { SetTranslationResolver } from './set-translation-resolver'
2
-
3
- export const resolvers = [SetTranslationResolver]
@@ -1,63 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import { WorkCode } from './work-code'
2
- import { WorkCodeQuery } from './work-code-query'
3
- import { WorkCodeMutation } from './work-code-mutation'
4
-
5
- export const entities = [WorkCode]
6
- export const resolvers = [WorkCodeQuery, WorkCodeMutation]
@@ -1,147 +0,0 @@
1
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
- import { In } from 'typeorm'
3
-
4
- import { getRepository } from '@things-factory/shell'
5
-
6
- import { WorkCodeDetail } from '../work-code-detail/work-code-detail'
7
- import { WorkCode } from './work-code'
8
- import { WorkCodePatch, NewWorkCode } from './work-code-type'
9
-
10
- @Resolver(WorkCode)
11
- export class WorkCodeMutation {
12
- @Directive('@transaction')
13
- @Mutation(returns => WorkCode, { description: 'To create new WorkCode' })
14
- async createWorkCode(
15
- @Arg('workCode') workCode: NewWorkCode,
16
- @Ctx() context: ResolverContext
17
- ): Promise<WorkCode> {
18
- const { domain, user, tx } = context.state
19
-
20
- const details = await getRepository(WorkCodeDetail).findByIds(workCode.details || [])
21
-
22
- return await tx.getRepository(WorkCode).save({
23
- ...workCode,
24
- details,
25
- domain,
26
- creator: user,
27
- updater: user
28
- })
29
- }
30
-
31
- @Directive('@transaction')
32
- @Mutation(returns => WorkCode, { description: 'To modify WorkCode information' })
33
- async updateWorkCode(
34
- @Arg('patch') patch: WorkCodePatch,
35
- @Ctx() context: ResolverContext
36
- ): Promise<WorkCode> {
37
- const { domain, user, tx } = context.state
38
-
39
- const repository = tx.getRepository(WorkCode)
40
- const workCode = await repository.findOne({
41
- where: { id:patch.id },
42
- relations: ['details']
43
- })
44
-
45
- const detailIds = workCode.details.map(detail => detail.id)
46
- if (patch.details && patch.details.length) {
47
- patch.details.forEach((detailId: string) => {
48
- if (!detailIds.includes(detailId)) {
49
- detailIds.push(detailId)
50
- }
51
- })
52
- }
53
-
54
- return await repository.save({
55
- ...workCode,
56
- ...patch,
57
- details: await getRepository(WorkCodeDetail).findByIds(detailIds),
58
- updater: user
59
- })
60
- }
61
-
62
- @Directive('@transaction')
63
- @Mutation(returns => [WorkCode], { description: "To modify multiple WorkCodes' information" })
64
- async updateMultipleWorkCode(
65
- @Arg('patches', type => [WorkCodePatch]) patches: WorkCodePatch[],
66
- @Ctx() context: ResolverContext
67
- ): Promise<WorkCode[]> {
68
- const { domain, user, tx } = context.state
69
-
70
- let results = []
71
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
72
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
73
- const commonCodeRepo = tx.getRepository(WorkCode)
74
-
75
- if (_createRecords.length > 0) {
76
- for (let i = 0; i < _createRecords.length; i++) {
77
- const newRecord = _createRecords[i]
78
-
79
- const result = await commonCodeRepo.save({
80
- ...(newRecord as any),
81
- domain,
82
- creator: user,
83
- updater: user
84
- })
85
-
86
- results.push({ ...result, cuFlag: '+' })
87
- }
88
- }
89
-
90
- if (_updateRecords.length > 0) {
91
- for (let i = 0; i < _updateRecords.length; i++) {
92
- const newRecord = _updateRecords[i]
93
- const commonCode = await commonCodeRepo.findOneBy({ id: newRecord.id })
94
-
95
- const result = await commonCodeRepo.save({
96
- ...commonCode,
97
- ...(newRecord as any),
98
- updater: user
99
- })
100
-
101
- results.push({ ...result, cuFlag: 'M' })
102
- }
103
- }
104
-
105
- return results
106
- }
107
-
108
- @Directive('@transaction')
109
- @Mutation(returns => Boolean, { description: 'To delete WorkCode' })
110
- async deleteWorkCode(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
111
- const { domain, tx } = context.state
112
-
113
- await tx.getRepository(WorkCode).delete({ id })
114
- return true
115
- }
116
-
117
- @Directive('@transaction')
118
- @Mutation(returns => Boolean, { description: 'To delete multiple WorkCodes' })
119
- async deleteWorkCodes(
120
- @Arg('ids', type => [String]) ids: string[],
121
- @Ctx() context: ResolverContext
122
- ): Promise<boolean> {
123
- const { domain, tx } = context.state
124
-
125
- await tx.getRepository(WorkCode).delete({id: In(ids)})
126
- return true
127
- }
128
-
129
- @Directive('@transaction')
130
- @Mutation(returns => Boolean, { description: 'To import multiple WorkCodes' })
131
- async importWorkCodes(
132
- @Arg('workCodes', type => [WorkCodePatch]) commonCodes: WorkCodePatch[],
133
- @Ctx() context: ResolverContext
134
- ): Promise<boolean> {
135
- const { domain, tx } = context.state
136
-
137
- await Promise.all(
138
- commonCodes.map(async (workCode: WorkCodePatch) => {
139
- const createdWorkCode: WorkCode = await tx
140
- .getRepository(WorkCode)
141
- .save({ domain, ...(workCode as any) })
142
- })
143
- )
144
-
145
- return true
146
- }
147
- }
@@ -1,67 +0,0 @@
1
- import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
-
6
- import { WorkCodeDetail } from '../work-code-detail/work-code-detail'
7
- import { WorkCode } from './work-code'
8
- import { WorkCodeList } from './work-code-type'
9
-
10
- @Resolver(WorkCode)
11
- export class WorkCodeQuery {
12
- @Query(returns => WorkCode!, { nullable: true, description: 'To fetch a WorkCode' })
13
- async workCode(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<WorkCode> {
14
- const { domain } = context.state
15
-
16
- return await getRepository(WorkCode).findOne({
17
- where: { id }
18
- })
19
- }
20
-
21
- @Query(returns => WorkCode!, { nullable: true, description: 'To fetch a WorkCode' })
22
- async workCodeByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<WorkCode> {
23
- const { domain } = context.state
24
-
25
- return await getRepository(WorkCode).findOne({
26
- where: { domain: { id: domain.id }, name }
27
- })
28
- }
29
-
30
- @Query(returns => WorkCodeList, { description: 'To fetch multiple WorkCodes' })
31
- async workCodes(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<WorkCodeList> {
32
- const { domain } = context.state
33
-
34
- const queryBuilder = getQueryBuilderFromListParams({
35
- domain,
36
- params,
37
- repository: await getRepository(WorkCode),
38
- searchables: ['name', 'description']
39
- })
40
-
41
- const [items, total] = await queryBuilder.getManyAndCount()
42
-
43
- return { items, total }
44
- }
45
-
46
- @FieldResolver(type => [WorkCodeDetail])
47
- async details(@Root() workCode: WorkCode): Promise<WorkCodeDetail[]> {
48
- return await getRepository(WorkCodeDetail).findBy({
49
- workCode: { id: workCode.id }
50
- })
51
- }
52
-
53
- @FieldResolver(type => Domain)
54
- async domain(@Root() workCode: WorkCode): Promise<Domain> {
55
- return await getRepository(Domain).findOneBy({ id: workCode.domainId })
56
- }
57
-
58
- @FieldResolver(type => User)
59
- async updater(@Root() workCode: WorkCode): Promise<User> {
60
- return await getRepository(User).findOneBy({ id: workCode.updaterId })
61
- }
62
-
63
- @FieldResolver(type => User)
64
- async creator(@Root() workCode: WorkCode): Promise<User> {
65
- return await getRepository(User).findOneBy({ id: workCode.creatorId })
66
- }
67
- }
@@ -1,60 +0,0 @@
1
- import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
-
3
- import { WorkCode } from './work-code'
4
-
5
- @InputType()
6
- export class NewWorkCode {
7
- @Field()
8
- name: string
9
-
10
- @Field({ nullable: true })
11
- description?: string
12
-
13
- @Field({ nullable: true })
14
- category1?: string
15
-
16
- @Field({ nullable: true })
17
- category2?: string
18
-
19
- @Field({ nullable: true })
20
- category3?: string
21
-
22
- @Field(type => [String], { nullable: true })
23
- details?: string[]
24
- }
25
-
26
- @InputType()
27
- export class WorkCodePatch {
28
- @Field(type => ID, { nullable: true })
29
- id?: string
30
-
31
- @Field({ nullable: true })
32
- name?: string
33
-
34
- @Field({ nullable: true })
35
- description?: string
36
-
37
- @Field({ nullable: true })
38
- category1?: string
39
-
40
- @Field({ nullable: true })
41
- category2?: string
42
-
43
- @Field({ nullable: true })
44
- category3?: string
45
-
46
- @Field(type => [String], { nullable: true })
47
- details?: string[]
48
-
49
- @Field({ nullable: true })
50
- cuFlag?: string
51
- }
52
-
53
- @ObjectType()
54
- export class WorkCodeList {
55
- @Field(type => [WorkCode])
56
- items: WorkCode[]
57
-
58
- @Field(type => Int)
59
- total: number
60
- }