@dssp/supervision 0.0.35 → 1.0.0-alpha.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 (31) hide show
  1. package/client/pages/building-inspection/building-inspection-detail-checklist.ts +9 -5
  2. package/client/pages/building-inspection/building-inspection-list.ts +10 -9
  3. package/client/pages/building-inspection/component/building-inspection-detail-header.ts +11 -5
  4. package/client/pages/checklist/attachment-list-popup.ts +20 -2
  5. package/client/pages/checklist/checklist-view.ts +34 -23
  6. package/client/pages/checklist/comment-list-popup.ts +12 -3
  7. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +9 -5
  8. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -1
  9. package/dist-client/pages/building-inspection/building-inspection-list.js +10 -9
  10. package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -1
  11. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +11 -5
  12. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -1
  13. package/dist-client/pages/checklist/attachment-list-popup.js +22 -2
  14. package/dist-client/pages/checklist/attachment-list-popup.js.map +1 -1
  15. package/dist-client/pages/checklist/checklist-view.js +34 -23
  16. package/dist-client/pages/checklist/checklist-view.js.map +1 -1
  17. package/dist-client/pages/checklist/comment-list-popup.js +16 -3
  18. package/dist-client/pages/checklist/comment-list-popup.js.map +1 -1
  19. package/dist-client/tsconfig.tsbuildinfo +1 -1
  20. package/dist-server/service/building-inspection/building-inspection-mutation.js +9 -1
  21. package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -1
  22. package/dist-server/service/checklist-item/checklist-item-query.d.ts +2 -0
  23. package/dist-server/service/checklist-item/checklist-item-query.js +15 -0
  24. package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -1
  25. package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js +19 -1
  26. package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js.map +1 -1
  27. package/dist-server/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +13 -13
  29. package/server/service/building-inspection/building-inspection-mutation.ts +13 -1
  30. package/server/service/checklist-item/checklist-item-query.ts +11 -0
  31. package/server/service/checklist-item-comment/checklist-item-comment-mutation.ts +21 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dssp/supervision",
3
- "version": "0.0.35",
3
+ "version": "1.0.0-alpha.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -27,17 +27,17 @@
27
27
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
28
28
  },
29
29
  "dependencies": {
30
- "@dssp/building-complex": "^0.0.35",
31
- "@dssp/drawing": "^0.0.35",
32
- "@dssp/project": "^0.0.35",
33
- "@operato/event-view": "^8.0.0-alpha",
34
- "@operato/graphql": "^8.0.0-alpha",
35
- "@operato/image-marker": "^8.0.0-alpha",
36
- "@operato/input": "^8.0.0-alpha",
37
- "@operato/mini-map": "^8.0.0-alpha",
38
- "@operato/shell": "^8.0.0-alpha",
39
- "@things-factory/auth-base": "^8.0.0-alpha",
40
- "@things-factory/shell": "^8.0.0-alpha"
30
+ "@dssp/building-complex": "^1.0.0-alpha.0",
31
+ "@dssp/drawing": "^1.0.0-alpha.0",
32
+ "@dssp/project": "^1.0.0-alpha.0",
33
+ "@operato/event-view": "^8.0.0-beta",
34
+ "@operato/graphql": "^8.0.0-beta",
35
+ "@operato/image-marker": "^8.0.0-beta",
36
+ "@operato/input": "^8.0.0-beta",
37
+ "@operato/mini-map": "^8.0.0-beta",
38
+ "@operato/shell": "^8.0.0-beta",
39
+ "@things-factory/auth-base": "^8.0.0-beta",
40
+ "@things-factory/shell": "^8.0.0-beta"
41
41
  },
42
- "gitHead": "075cee051e01751c29cbf1849968ba3f892c1e85"
42
+ "gitHead": "7b8b1a1ab63177487b30c0acb7f2cbc82afe6a0e"
43
43
  }
@@ -197,6 +197,12 @@ export class BuildingInspectionMutation {
197
197
  if (!patch.id) throw new Error('검측 아이디가 없습니다.')
198
198
 
199
199
  const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id })
200
+
201
+ // 완료 상태인 검측데이터면 삭제 못함
202
+ if (buildingInspection.status === BuildingInspectionStatus.PASS) {
203
+ throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
204
+ }
205
+
200
206
  const result = await buildingInspectionRepo.save({
201
207
  ...buildingInspection,
202
208
  ...patch,
@@ -217,8 +223,14 @@ export class BuildingInspectionMutation {
217
223
  const checklistRepository = tx.getRepository(Checklist)
218
224
  const checklistItemRepository = tx.getRepository(ChecklistItem)
219
225
 
220
- // 검측 데이터 제거
221
226
  const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()
227
+
228
+ // 완료 상태인 검측데이터가 한개라도 있으면 삭제 못함
229
+ if (buildingInspections.filter(bi => bi.status === BuildingInspectionStatus.PASS).length > 0) {
230
+ throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
231
+ }
232
+
233
+ // 검측 데이터 제거
222
234
  await buildingInspectionRepository.softDelete({
223
235
  id: In(ids)
224
236
  })
@@ -5,6 +5,7 @@ import { User } from '@things-factory/auth-base'
5
5
  import { ChecklistItem } from './checklist-item'
6
6
  import { ChecklistItemList } from './checklist-item-type'
7
7
  import { ChecklistItemComment } from '../checklist-item-comment/checklist-item-comment'
8
+ import { BuildingInspection } from '../building-inspection/building-inspection'
8
9
 
9
10
  @Resolver(ChecklistItem)
10
11
  export class ChecklistItemQuery {
@@ -28,6 +29,16 @@ export class ChecklistItemQuery {
28
29
  return { items, total }
29
30
  }
30
31
 
32
+ @Query(returns => BuildingInspection, { description: 'BuildingInspection By ChecklistItemId' })
33
+ async inspectionByChecklistItemId(checklistItemId: string): Promise<BuildingInspection> {
34
+ return getRepository(BuildingInspection)
35
+ .createQueryBuilder('bi')
36
+ .innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
37
+ .innerJoin('checklist_items', 'ci', 'c.id = ci.checklist_id')
38
+ .where('ci.id = :checklistItemId', { checklistItemId })
39
+ .getOne()
40
+ }
41
+
31
42
  @FieldResolver(type => [ChecklistItemComment])
32
43
  async checklistItemComments(@Root() checklistItem: ChecklistItem): Promise<ChecklistItemComment[]> {
33
44
  return await getRepository(ChecklistItemComment).findBy({ checklistItem: { id: checklistItem.id } })
@@ -2,6 +2,8 @@ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
2
  import { getRepository } from '@things-factory/shell'
3
3
  import { ChecklistItemComment } from './checklist-item-comment'
4
4
  import { NewChecklistItemComment, ChecklistItemCommentPatch } from './checklist-item-comment-type'
5
+ import { BuildingInspectionStatus } from '../building-inspection/building-inspection'
6
+ import { ChecklistItemQuery } from '../checklist-item/checklist-item-query'
5
7
 
6
8
  @Resolver(ChecklistItemComment)
7
9
  export class ChecklistItemCommentMutation {
@@ -14,6 +16,13 @@ export class ChecklistItemCommentMutation {
14
16
  const { user, tx } = context.state
15
17
  const { comment, checklistItemId } = checklistItemComment
16
18
 
19
+ // 합격 상태인지 체크
20
+ const checklistItemQuery = new ChecklistItemQuery()
21
+ const inspection = await checklistItemQuery.inspectionByChecklistItemId(checklistItemId)
22
+ if (inspection.status === BuildingInspectionStatus.PASS) {
23
+ throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
24
+ }
25
+
17
26
  const result = await getRepository(ChecklistItemComment, tx).save({
18
27
  comment,
19
28
  checklistItem: { id: checklistItemId },
@@ -52,8 +61,19 @@ export class ChecklistItemCommentMutation {
52
61
  @Mutation(returns => Boolean, { description: 'To delete ChecklistItemComment' })
53
62
  async deleteChecklistItemComment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
54
63
  const { tx } = context.state
64
+ const repository = getRepository(ChecklistItemComment, tx)
65
+ const checklistItemComment = await repository.findOne({
66
+ where: { id }
67
+ })
68
+
69
+ // 합격 상태인지 체크
70
+ const checklistItemQuery = new ChecklistItemQuery()
71
+ const inspection = await checklistItemQuery.inspectionByChecklistItemId(checklistItemComment.checklistItemId)
72
+ if (inspection.status === BuildingInspectionStatus.PASS) {
73
+ throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
74
+ }
55
75
 
56
- await getRepository(ChecklistItemComment, tx).softDelete({ id })
76
+ await repository.softDelete({ id })
57
77
 
58
78
  return true
59
79
  }