rez_core 2.2.183 → 2.2.184

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.2.183",
3
+ "version": "2.2.184",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -21,10 +21,12 @@ export class CommTemplateController {
21
21
  async getTemplate(
22
22
  @Req() req: Request & { user: any },
23
23
  @Body('entity_type') entity_type: string,
24
+ @Body('action_id') action_id: number,
24
25
  ) {
25
26
  const loggedInUser = req.user.userData;
26
27
  const result = this.commTemplateService.getAllCommTemplate(
27
28
  entity_type || '',
29
+ action_id,
28
30
  loggedInUser,
29
31
  );
30
32
  return result;
@@ -28,4 +28,7 @@ export class CommTemplate extends BaseEntity {
28
28
  // if format_type is 'markup', this field will be used
29
29
  @Column({ nullable: true })
30
30
  markup_id: number;
31
+
32
+ @Column({ nullable: true })
33
+ is_template: boolean;
31
34
  }
@@ -1,7 +1,7 @@
1
1
  import { Injectable, NotFoundException } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
3
  import { Workflow } from '../entity/workflow.entity';
4
- import { Repository } from 'typeorm';
4
+ import { DataSource, Repository } from 'typeorm';
5
5
  import { CommTemplate } from '../entity/comm-template.entity';
6
6
  import { TemplateAttach } from '../entity/template-attach-mapper.entity';
7
7
  import { MediaDataService } from 'src/module/meta/service/media-data.service';
@@ -14,15 +14,44 @@ export class CommTemplateRepository {
14
14
  @InjectRepository(TemplateAttach)
15
15
  private readonly templateAttachEntity: Repository<TemplateAttach>,
16
16
  private readonly mediaDataService: MediaDataService,
17
+ private readonly dataSource: DataSource,
17
18
  ) {}
18
19
 
19
- async getAllCommTemplate(entity_type: string, loggedInUser) {
20
+ async getAllCommTemplate(
21
+ entity_type: string,
22
+ action_id: number,
23
+ loggedInUser,
24
+ ) {
20
25
  const { organization_id } = loggedInUser;
26
+
27
+ const [actionResult] = await this.dataSource.query(
28
+ `SELECT is_template
29
+ FROM cr_wf_action
30
+ WHERE id = ? AND organization_id = ?
31
+ LIMIT 1`,
32
+ [action_id, organization_id],
33
+ );
34
+
35
+ if (!actionResult) {
36
+ throw new Error('Invalid action_id');
37
+ }
38
+
39
+ const { is_template } = actionResult;
40
+
41
+ await this.dataSource.query(
42
+ `UPDATE cr_wf_comm_template
43
+ SET is_template = ?
44
+ WHERE mapped_entity_type = ?
45
+ AND organization_id = ?`,
46
+ [is_template, entity_type, organization_id],
47
+ );
48
+
21
49
  return this.commTemplateRepository.find({
22
- select: ['name', 'code', 'mode'],
50
+ select: ['name', 'code', 'mode', 'is_template'],
23
51
  where: {
24
52
  mapped_entity_type: entity_type,
25
- organization_id: organization_id,
53
+ organization_id,
54
+ is_template,
26
55
  },
27
56
  });
28
57
  }
@@ -78,10 +78,15 @@ export class CommTemplateService extends EntityServiceImpl {
78
78
  return getTemplate;
79
79
  }
80
80
 
81
- async getAllCommTemplate(entity_type: string, loggedInUser) {
81
+ async getAllCommTemplate(
82
+ entity_type: string,
83
+ action_id: number,
84
+ loggedInUser,
85
+ ) {
82
86
  const commTemplateData =
83
87
  await this.commTemplateRepository.getAllCommTemplate(
84
88
  entity_type,
89
+ action_id,
85
90
  loggedInUser,
86
91
  );
87
92
 
@@ -89,6 +94,7 @@ export class CommTemplateService extends EntityServiceImpl {
89
94
  value: item.code,
90
95
  label: item.name,
91
96
  mode: item.mode,
97
+ template: item.is_template,
92
98
  }));
93
99
 
94
100
  return response;
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint"
4
- ]
5
- }