bpm-core 0.0.131 → 0.0.133
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/cli/deploy/build.js +62 -0
- package/cli/deploy/git-operations-handler.js +104 -0
- package/cli/deploy/index.js +61 -0
- package/cli/deploy/jenkins-manager.js +107 -0
- package/cli/generate/index.js +10 -0
- package/cli/generate/mock/form-node.js +77 -0
- package/cli/generate/mock/index.js +209 -0
- package/cli/generate/mock/lov.js +18 -0
- package/cli/generate/new/angular-template/.editorconfig +13 -0
- package/cli/generate/new/angular-template/README.md +7 -0
- package/cli/generate/new/angular-template/angular.json.ejs +167 -0
- package/cli/generate/new/angular-template/build.sh +6 -0
- package/cli/generate/new/angular-template/extra-webpack.config.js.ejs +5 -0
- package/cli/generate/new/angular-template/karma.conf.js +44 -0
- package/cli/generate/new/angular-template/package.json.ejs +66 -0
- package/cli/generate/new/angular-template/protractor.conf.js +28 -0
- package/cli/generate/new/angular-template/src/app/app.component.html +35 -0
- package/cli/generate/new/angular-template/src/app/app.component.scss +0 -0
- package/cli/generate/new/angular-template/src/app/app.component.ts +81 -0
- package/cli/generate/new/angular-template/src/app/config/segment-dynamic-loader.config.ts.ejs +8 -0
- package/cli/generate/new/angular-template/src/app/i18n/ar.ts.ejs +18 -0
- package/cli/generate/new/angular-template/src/app/i18n/en.ts.ejs +18 -0
- package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/@@.component.html.ejs +33 -0
- package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/@@.component.ts.ejs +128 -0
- package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/_html-field.ejs +97 -0
- package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/_html-table.ejs +27 -0
- package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/_ts-field.ejs +3 -0
- package/cli/generate/new/angular-template/src/app/shared/pipes/translate.pipe.ts +32 -0
- package/cli/generate/new/angular-template/src/app/shared/services/i18n.service.ts +32 -0
- package/cli/generate/new/angular-template/src/app/shared/services/segment-dynamic-loader.service.ts.ejs +49 -0
- package/cli/generate/new/angular-template/src/app/shared/services/state-machine.service.ts +119 -0
- package/cli/generate/new/angular-template/src/app/shared/types/lov.enum.ts.ejs +7 -0
- package/cli/generate/new/angular-template/src/app/templates/print-section/print-section.component.html +5 -0
- package/cli/generate/new/angular-template/src/app/templates/print-section/print-section.component.scss +0 -0
- package/cli/generate/new/angular-template/src/app/templates/print-section/print-section.component.ts.ejs +156 -0
- package/cli/generate/new/angular-template/src/app/templates/print.ts.ejs +392 -0
- package/cli/generate/new/angular-template/src/environments/environment.local.ts.ejs +40 -0
- package/cli/generate/new/angular-template/src/environments/environment.prod.ts +25 -0
- package/cli/generate/new/angular-template/src/environments/environment.ts +25 -0
- package/cli/generate/new/angular-template/src/favicon.ico +0 -0
- package/cli/generate/new/angular-template/src/index.html.ejs +14 -0
- package/cli/generate/new/angular-template/src/main.ts +49 -0
- package/cli/generate/new/angular-template/src/polyfills.ts +65 -0
- package/cli/generate/new/angular-template/src/styles.scss.ejs +121 -0
- package/cli/generate/new/angular-template/src/test.ts +26 -0
- package/cli/generate/new/angular-template/tsconfig.app.json +15 -0
- package/cli/generate/new/angular-template/tsconfig.json +50 -0
- package/cli/generate/new/angular-template/tsconfig.spec.json +18 -0
- package/cli/generate/new/angular-template/tslint.json +143 -0
- package/cli/generate/new/copy-and-generate.js +120 -0
- package/cli/generate/new/field.js +4 -0
- package/cli/generate/new/index.js +47 -0
- package/cli/generate/new/service-data.js +284 -0
- package/cli/index.js +14 -0
- package/cli/utilities/utilities.js +114 -0
- package/fesm2022/bpm-core.mjs +350 -395
- package/fesm2022/bpm-core.mjs.map +1 -1
- package/lib/components/shared-components/form-field/search-employee/search-employee.component.d.ts +6 -1
- package/lib/components/shared-components/form-field/shared-imports.d.ts +1 -1
- package/lib/components/shared-components/form-field/table-list/table-list.component.d.ts +1 -1
- package/lib/services/core.service.ts.d.ts +1 -0
- package/lib/testComponent/request-details-section/request-details-section.component.d.ts +0 -2
- package/package.json +2 -2
package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/_html-field.ejs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<% if (item.visibilityCheckCode) { -%>
|
|
2
|
+
<% importsManager.addImport(getEnumName(item), '../../shared/types/lov.enum') -%>
|
|
3
|
+
@if(<%= changeCase.camelCase(`is ${item.fieldName || item.headerName} visible`) %>){
|
|
4
|
+
<% } -%>
|
|
5
|
+
<% switch(item.componentName){
|
|
6
|
+
case 'input': -%>
|
|
7
|
+
<app-input
|
|
8
|
+
<%- getCommonAttributes(item) -%>
|
|
9
|
+
<% if(item.maxLength){ -%>
|
|
10
|
+
maxLength="<%=item.maxLength%>"
|
|
11
|
+
<% } -%>
|
|
12
|
+
>
|
|
13
|
+
</app-input>
|
|
14
|
+
<% break; case 'textarea': -%>
|
|
15
|
+
<app-textarea
|
|
16
|
+
<%- getCommonAttributes(item) -%>
|
|
17
|
+
<% if(item.maxLength){ -%>
|
|
18
|
+
maxLength="<%=item.maxLength%>"
|
|
19
|
+
<% } -%>
|
|
20
|
+
>
|
|
21
|
+
</app-textarea>
|
|
22
|
+
<% break; case 'input-number': -%>
|
|
23
|
+
<app-input-number
|
|
24
|
+
<%- getCommonAttributes(item) -%>
|
|
25
|
+
>
|
|
26
|
+
</app-input-number>
|
|
27
|
+
<% break; case 'input-currency': -%>
|
|
28
|
+
<app-input-currency
|
|
29
|
+
<%- getCommonAttributes(item) -%>
|
|
30
|
+
>
|
|
31
|
+
</app-input-currency>
|
|
32
|
+
<% break; case 'select': -%>
|
|
33
|
+
<app-custom-searchable
|
|
34
|
+
<%- getCommonAttributes(item) -%>
|
|
35
|
+
[options]="lov?.<%=item.lovName%>?.options"
|
|
36
|
+
[key]="'value'"
|
|
37
|
+
[displayedLabel]="'description'"
|
|
38
|
+
>
|
|
39
|
+
</app-custom-searchable>
|
|
40
|
+
<% break; case 'attachment-section': -%>
|
|
41
|
+
<app-attachment-section
|
|
42
|
+
class="section-item full"
|
|
43
|
+
formControlName="<%=item.fieldName%>"
|
|
44
|
+
<% if(item.label){ %>
|
|
45
|
+
[label]="'<%=changeCase.camelCase(item.label)%>' | translate"
|
|
46
|
+
<% } %>
|
|
47
|
+
[mandatory]="<%=item.required%>"
|
|
48
|
+
[isReadOnly]="<%=item.readOnly ? 'true' : 'section?.header?.readOnly'%>"
|
|
49
|
+
>
|
|
50
|
+
</app-attachment-section>
|
|
51
|
+
<% break; case 'file-uploader': -%>
|
|
52
|
+
<app-file-uploader
|
|
53
|
+
<%- getCommonAttributes(item) -%>
|
|
54
|
+
<% if(item.maxLength){ -%>
|
|
55
|
+
[maxLength]="<%=item.maxLength%>"
|
|
56
|
+
<% } -%>
|
|
57
|
+
<% if(item.multiple){ -%>
|
|
58
|
+
[multiple]="true"
|
|
59
|
+
[displayedFiles]="formGroup.value?.<%=item.fieldName%>"
|
|
60
|
+
<% } -%>
|
|
61
|
+
>
|
|
62
|
+
</app-file-uploader>
|
|
63
|
+
<% break; case 'datepicker': -%>
|
|
64
|
+
<app-datepicker
|
|
65
|
+
<%- getCommonAttributes(item) -%>
|
|
66
|
+
<% if(item.minDate){ -%>
|
|
67
|
+
minDate="<%=item.minDate%>"
|
|
68
|
+
<% } -%>
|
|
69
|
+
<% if(item.maxDate){ -%>
|
|
70
|
+
maxDate="<%=item.maxDate%>"
|
|
71
|
+
<% } -%>
|
|
72
|
+
<% if(item.customMinDate){ -%>
|
|
73
|
+
customMinDate="<%=item.customMinDate%>"
|
|
74
|
+
<% } -%>
|
|
75
|
+
<% if(item.customMaxDate){ -%>
|
|
76
|
+
customMaxDate="<%=item.customMaxDate%>"
|
|
77
|
+
<% } -%>
|
|
78
|
+
>
|
|
79
|
+
</app-datepicker>
|
|
80
|
+
<% break; case 'panel-start': -%>
|
|
81
|
+
<div class="header-line full fs-12 fw-medium mb-2">
|
|
82
|
+
{{ "<%=changeCase.camelCase(item.headerName)%>" | translate }}
|
|
83
|
+
</div>
|
|
84
|
+
<% break; case 'hint': -%>
|
|
85
|
+
<ds-alert class="mb-3 full" type="<%=item.type%>" icon="<%=item.type === 'danger' ? 'close-circle' : 'info'%>">
|
|
86
|
+
{{'<%=changeCase.camelCase(item.headerName)%>' | translate}}
|
|
87
|
+
</ds-alert>
|
|
88
|
+
<% break; case 'search-employee': -%>
|
|
89
|
+
<app-search-employee
|
|
90
|
+
<%- getCommonAttributes(item) -%>
|
|
91
|
+
>
|
|
92
|
+
</app-search-employee>
|
|
93
|
+
<% break; -%>
|
|
94
|
+
<% } -%>
|
|
95
|
+
<% if (item.visibilityCheckCode) { -%>
|
|
96
|
+
}
|
|
97
|
+
<% } %>
|
package/cli/generate/new/angular-template/src/app/page-components/@@comp-template@@/_html-table.ejs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<div class="section-item full mt-2">
|
|
2
|
+
<% if(field.label){ -%>
|
|
3
|
+
<div class="header-line full fs-12 fw-medium mb-1">{{ "<%=changeCase.camelCase(field.label)%>" | translate }}</div>
|
|
4
|
+
<% } -%>
|
|
5
|
+
<div class="gray-table-wrapper">
|
|
6
|
+
<table>
|
|
7
|
+
<thead>
|
|
8
|
+
<tr>
|
|
9
|
+
<% field.tableColumns.forEach((column) => { -%>
|
|
10
|
+
<th>{{'<%=changeCase.camelCase(column.label)%>' | translate}}</th>
|
|
11
|
+
<% }); -%>
|
|
12
|
+
</tr>
|
|
13
|
+
</thead>
|
|
14
|
+
<tbody formArrayName="<%=field.arrayName%>">
|
|
15
|
+
@for (item of section.body.details.<%=field.arrayName%>; track $index) {
|
|
16
|
+
<tr [formGroupName]="$index">
|
|
17
|
+
<% field.tableColumns.forEach((column) => { -%>
|
|
18
|
+
<td>
|
|
19
|
+
<%- include('_html-field', {item: column}) %>
|
|
20
|
+
</td>
|
|
21
|
+
<% }); -%>
|
|
22
|
+
</tr>
|
|
23
|
+
}
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
import * as en from '../../../app/i18n/en';
|
|
3
|
+
import * as ar from '../../../app/i18n/ar';
|
|
4
|
+
|
|
5
|
+
@Pipe({
|
|
6
|
+
name: 'translate',
|
|
7
|
+
standalone:true
|
|
8
|
+
})
|
|
9
|
+
export class TranslatePipe implements PipeTransform {
|
|
10
|
+
private coreLocales: { [key: string]: { [key: string]: string } };
|
|
11
|
+
public language: string;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
// this.language = "en";
|
|
15
|
+
this.language = (window as any).wmConfig.language;
|
|
16
|
+
this.coreLocales = { en: en.default, ar: ar.default };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
transform(key) {
|
|
20
|
+
let result = null;
|
|
21
|
+
try {
|
|
22
|
+
result = this.coreLocales[this.language][key];
|
|
23
|
+
} catch (e) {
|
|
24
|
+
result = null;
|
|
25
|
+
}
|
|
26
|
+
return result || key;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getLanguage() {
|
|
30
|
+
return this.language;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as en from '../../../app/i18n/en';
|
|
3
|
+
import * as ar from '../../../app/i18n/ar';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'any',
|
|
7
|
+
})
|
|
8
|
+
export class I18nService {
|
|
9
|
+
private readonly locales: {[key: string]: {[key: string]: string}};
|
|
10
|
+
private readonly language : string;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
this.language = (window as any).wmConfig.language;
|
|
14
|
+
// this.language = "en";
|
|
15
|
+
this.locales = {en: en.default, ar: ar.default};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
translate(key) {
|
|
19
|
+
let result = null;
|
|
20
|
+
try {
|
|
21
|
+
result = this.locales[this.language][key];
|
|
22
|
+
}
|
|
23
|
+
catch(e) {
|
|
24
|
+
result = null;
|
|
25
|
+
}
|
|
26
|
+
return result || key;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getLanguage() {
|
|
30
|
+
return this.language;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import {RequestDetailsSectionComponent} from '../../page-components/request-details-section/request-details-section.component';
|
|
3
|
+
import segmentDynamicLoaderConfiguration from '../../config/segment-dynamic-loader.config';
|
|
4
|
+
import * as Constants from 'bpm-core';
|
|
5
|
+
import { I18nService } from './i18n.service';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'any'
|
|
9
|
+
})
|
|
10
|
+
export class SegmentDynamicLoaderService {
|
|
11
|
+
requestDetailsSection = RequestDetailsSectionComponent;
|
|
12
|
+
roleToApprovalSectionMapping = segmentDynamicLoaderConfiguration.roleToApprovalSectionMapping;
|
|
13
|
+
|
|
14
|
+
constructor(private i18n: I18nService) {
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getComponent(componentId: string) {
|
|
19
|
+
if (componentId.toLowerCase() === Constants.SECTION_ID_REQUEST_DETAILS.toLowerCase()) {
|
|
20
|
+
return this.requestDetailsSection;
|
|
21
|
+
}
|
|
22
|
+
let role = componentId.toLowerCase().split(Constants.SECTION_ID_APPROVAL_PARTIAL_NAME.toLowerCase())[0].toLowerCase();
|
|
23
|
+
return this.roleToApprovalSectionMapping[role];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getSectionName(componentId: string): string {
|
|
27
|
+
if(componentId.toLowerCase() === Constants.SECTION_ID_REQUEST_DETAILS.toLowerCase()) {
|
|
28
|
+
return this.i18n.translate('requestDetailsTitle');
|
|
29
|
+
}
|
|
30
|
+
else if(componentId.toLowerCase() === 'hrRequestDetails'.toLowerCase()) {
|
|
31
|
+
return this.i18n.translate('hrRequestDetailsTitle');
|
|
32
|
+
}
|
|
33
|
+
let role = componentId.toLowerCase().split(Constants.SECTION_ID_APPROVAL_PARTIAL_NAME.toLowerCase())[0].toLowerCase();
|
|
34
|
+
return this.i18n.translate(`${role.toLowerCase()}Role`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getPrintPartialName (componentName: string) {
|
|
38
|
+
if (componentName === Constants.SECTION_ID_REQUEST_DETAILS) {
|
|
39
|
+
return 'sectionRequestDetails';
|
|
40
|
+
}
|
|
41
|
+
<% getRoleStages().forEach(stageInfo => { -%>
|
|
42
|
+
else if (componentName === "<%= stageInfo.role.toLowerCase()%>Approval") {
|
|
43
|
+
return "<%=stageInfo.printPartialName%>";
|
|
44
|
+
}
|
|
45
|
+
<% }); -%>
|
|
46
|
+
else { return 'sectionGeneralApproval' }
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {Injectable} from '@angular/core';
|
|
2
|
+
import {HttpClient} from '@angular/common/http';
|
|
3
|
+
import * as constants from "bpm-core";
|
|
4
|
+
import {CoreService, Messages} from "bpm-core";
|
|
5
|
+
import {environment} from "../../../environments/environment";
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'any',
|
|
9
|
+
})
|
|
10
|
+
export class StateMachineService {
|
|
11
|
+
private readonly transitions: { [key: string]: { [key: string]: Function } };
|
|
12
|
+
private state: string;
|
|
13
|
+
|
|
14
|
+
constructor(private http: HttpClient, private coreStateMachineService: CoreService) {
|
|
15
|
+
this.state = constants.STATE_MACHINE_STATUS_IDLE;
|
|
16
|
+
this.transitions = {
|
|
17
|
+
idle: {
|
|
18
|
+
generalApi: function (serviceName: string, ...args) {
|
|
19
|
+
let body = {
|
|
20
|
+
method: constants.HTTP_METHOD_GET, //GET - PUT - POST
|
|
21
|
+
destination: constants.TARGET_SERVER_WM,
|
|
22
|
+
serviceName: serviceName, //,
|
|
23
|
+
formName: environment.formName,
|
|
24
|
+
queryParameters: {
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let options = this.coreStateMachineService.getRequestOptions();
|
|
29
|
+
let succ = 'serviceResponce';
|
|
30
|
+
return this.callPost(body, succ, options);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
fetching: {
|
|
34
|
+
serviceResponce: function (...args: any) {
|
|
35
|
+
let [payload] = args;
|
|
36
|
+
let result = payload;
|
|
37
|
+
this.state = constants.STATE_MACHINE_STATUS_IDLE;
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
failure: function (...args) {
|
|
41
|
+
let [errors] = args;
|
|
42
|
+
this.state = constants.STATE_MACHINE_STATUS_ERROR;
|
|
43
|
+
return this.dispatch(constants.STATE_MACHINE_ACTION_HANDLE_ERROR, errors);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
error: {
|
|
47
|
+
handleError: function (...args) {
|
|
48
|
+
let [errors] = args;
|
|
49
|
+
let result = new Messages(
|
|
50
|
+
{},
|
|
51
|
+
[],
|
|
52
|
+
[],
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
55
|
+
if (errors?.meta?.messages) {
|
|
56
|
+
errors.meta.messages.forEach((message) => {
|
|
57
|
+
result[message.type].push(message.message);
|
|
58
|
+
if (message.payloadReference) {
|
|
59
|
+
let payloadReferenceTokens = message.payloadReference.split('/');
|
|
60
|
+
payloadReferenceTokens.slice(1, payloadReferenceTokens.length - 1);
|
|
61
|
+
let element = result.errorFields;
|
|
62
|
+
payloadReferenceTokens.forEach((token) => {
|
|
63
|
+
element[token] = {};
|
|
64
|
+
element = element[token];
|
|
65
|
+
})
|
|
66
|
+
element = true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
} else if (errors?.errors) {
|
|
70
|
+
errors.errors.forEach((message) => {
|
|
71
|
+
result['error'].push(message.message);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
this.state = constants.STATE_MACHINE_STATUS_IDLE;
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
sending: {
|
|
79
|
+
failure: function (...args) {
|
|
80
|
+
let [errors] = args;
|
|
81
|
+
this.state = constants.STATE_MACHINE_STATUS_ERROR;
|
|
82
|
+
return this.dispatch(constants.STATE_MACHINE_ACTION_HANDLE_ERROR, errors);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public dispatch(actionName, ...args) {
|
|
89
|
+
const actions = this.transitions[this.state];
|
|
90
|
+
const action = actions[actionName];
|
|
91
|
+
|
|
92
|
+
if (action) {
|
|
93
|
+
return action.apply(this, args);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public callPost(body, succ, options) {
|
|
98
|
+
let apiUrl = environment.proxyServiceBaseUrl + (window as any).wmConfig.language + environment.proxyFullAddress + environment.proxyServiceExecute;
|
|
99
|
+
return this.http.post(apiUrl, encodeURIComponent(JSON.stringify(body)), options).toPromise()
|
|
100
|
+
.then(
|
|
101
|
+
(responseObject: any) => {
|
|
102
|
+
let payload = responseObject;
|
|
103
|
+
this.state = constants.STATE_MACHINE_STATUS_FETCHING;
|
|
104
|
+
return this.dispatch(succ, payload);
|
|
105
|
+
},
|
|
106
|
+
).catch(
|
|
107
|
+
(httpError: any) => {
|
|
108
|
+
let responseError = httpError.error;
|
|
109
|
+
if (responseError) {
|
|
110
|
+
this.state = constants.STATE_MACHINE_STATUS_FETCHING;
|
|
111
|
+
return this.dispatch(constants.STATE_MACHINE_ACTION_FAILURE, responseError);
|
|
112
|
+
} else {
|
|
113
|
+
this.state = constants.STATE_MACHINE_STATUS_IDLE;
|
|
114
|
+
throw httpError;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {Component, CUSTOM_ELEMENTS_SCHEMA, Input, NO_ERRORS_SCHEMA} from '@angular/core';
|
|
2
|
+
import printTemplate from '../print';
|
|
3
|
+
import * as Constants from 'bpm-core';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import {Form} from 'bpm-core';
|
|
6
|
+
import {SegmentDynamicLoaderService} from '../../shared/services/segment-dynamic-loader.service';
|
|
7
|
+
import * as Handlebars from 'handlebars';
|
|
8
|
+
import {I18nService} from '../../shared/services/i18n.service';
|
|
9
|
+
import { DecimalPipe } from "@angular/common";
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'app-print-section',
|
|
13
|
+
templateUrl: './print-section.component.html',
|
|
14
|
+
styleUrls: ['./print-section.component.scss'],
|
|
15
|
+
standalone: true,
|
|
16
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
|
17
|
+
})
|
|
18
|
+
export class PrintSectionComponent {
|
|
19
|
+
|
|
20
|
+
@Input() form: Form;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
public i18n: I18nService,
|
|
24
|
+
public segmentDynamicLoader: SegmentDynamicLoaderService,
|
|
25
|
+
) { }
|
|
26
|
+
|
|
27
|
+
print() {
|
|
28
|
+
let compiledTemplate = null;
|
|
29
|
+
let popupWin: any;
|
|
30
|
+
popupWin = window.open('', '_blank', 'top=0,left=0,height=auto,width=auto');
|
|
31
|
+
let printObject = {
|
|
32
|
+
form: this.form,
|
|
33
|
+
i18n: this.i18n,
|
|
34
|
+
segmentDynamicLoader: this.segmentDynamicLoader,
|
|
35
|
+
lovs: this.form.lovs,
|
|
36
|
+
formId: this.form.header.formId
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Handlebars.registerHelper('i18nTranslate', this.translateHelper);
|
|
40
|
+
Handlebars.registerHelper('dateFormat', this.dateFormatHelper);
|
|
41
|
+
Handlebars.registerHelper('dateFormatHelper3', this.dateFormatHelper3);
|
|
42
|
+
Handlebars.registerHelper('dateFormat2', this.dateFormatHelper2);
|
|
43
|
+
Handlebars.registerHelper('getPartialName', this.sectionIdHelper);
|
|
44
|
+
Handlebars.registerHelper('getSectionTitle', this.sectionTitleHelper);
|
|
45
|
+
Handlebars.registerHelper('consoleLog', this.consoleLog);
|
|
46
|
+
Handlebars.registerHelper('eq', this.eq);
|
|
47
|
+
Handlebars.registerHelper('getFormId', this.getFormId.bind(this));
|
|
48
|
+
Handlebars.registerHelper('getDirection', this.getDirection.bind(this));
|
|
49
|
+
Handlebars.registerHelper('and', this.and);
|
|
50
|
+
Handlebars.registerHelper('or', this.or);
|
|
51
|
+
Handlebars.registerHelper('not', this.not);
|
|
52
|
+
Handlebars.registerHelper('statusClass', this.statusClass);
|
|
53
|
+
Handlebars.registerHelper("currencyFormat", this.currencyFormat);
|
|
54
|
+
|
|
55
|
+
<% getPrintPartials().forEach(printPartial => { -%>
|
|
56
|
+
Handlebars.registerPartial(
|
|
57
|
+
"<%= printPartial.printPartialName %>",
|
|
58
|
+
printTemplate.<%= printPartial.printPartialName %>
|
|
59
|
+
);
|
|
60
|
+
<% }); -%>
|
|
61
|
+
|
|
62
|
+
compiledTemplate = Handlebars.compile(printTemplate.printTemplate);
|
|
63
|
+
popupWin.document.open();
|
|
64
|
+
popupWin.document.write(compiledTemplate(printObject));
|
|
65
|
+
popupWin.document.close();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public getCurrentLang() {
|
|
69
|
+
return this.i18n.getLanguage();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private sectionIdHelper(context: any, id: any) {
|
|
73
|
+
return context.segmentDynamicLoader.getPrintPartialName(id);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private translateHelper(key: any) {
|
|
77
|
+
return this.i18n.translate(key);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private dateFormatHelper(key: any) {
|
|
81
|
+
return moment(key).locale('en-US').format(Constants.DATE_TIME);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private dateFormatHelper2(key: any) {
|
|
85
|
+
return moment(key).locale('en-US').format(Constants.DATE_DASH);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private dateFormatHelper3(key: any) {
|
|
89
|
+
return moment(key).locale('en-US').format(Constants.DATE_SLASH);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private consoleLog(type: any) {
|
|
93
|
+
// <label>{{consolelog 'test'}}</label>
|
|
94
|
+
console.log('------------', type, '-----------------', this);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private getFormId() {
|
|
98
|
+
return this.form.header.formId;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private sectionTitleHelper(componentId: any, segmentDynamicLoader: any) {
|
|
102
|
+
return segmentDynamicLoader.getSectionName(componentId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private eq(valueA: any, valueB: any) {
|
|
106
|
+
// {{#if (eq action.key 'MOVE')}}
|
|
107
|
+
let result = valueA === valueB;
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private and(valueA: any, valueB: any) {
|
|
112
|
+
// {{#if (and (eq body.details.workRelation.key 'SUBCONTRACTOR') (eq body.details.workRelation.key 'CONTRACTOR'))}}
|
|
113
|
+
let result = valueA && valueB;
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private or(valueA: any, valueB: any) {
|
|
118
|
+
// {{#if (or (eq body.details.workRelation.key 'SUBCONTRACTOR') (eq body.details.workRelation.key 'CONTRACTOR'))}}
|
|
119
|
+
let result = valueA || valueB;
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private not(valueA: any, valueB: any) {
|
|
124
|
+
// {{#if (not action.key 'MOVE')}}
|
|
125
|
+
let result = valueA != valueB;
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
private statusClass(status: string) {
|
|
131
|
+
if (
|
|
132
|
+
status === Constants.FORM_STATUS_REJECTED || status === Constants.FORM_STATUS_CANCELLED
|
|
133
|
+
|| status.toLowerCase() === 'reject' || status.toLowerCase() === 'unsatisfied' || status.toLowerCase() === 'cancel'
|
|
134
|
+
) {
|
|
135
|
+
return 'danger';
|
|
136
|
+
} else if (status === Constants.FORM_STATUS_PENDING || status.toLowerCase() === 'pending') {
|
|
137
|
+
return 'warning';
|
|
138
|
+
} else {
|
|
139
|
+
return 'success';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private getDirection() {
|
|
144
|
+
if (this.i18n.getLanguage() === Constants.LANGUAGE_CODE_AR) {
|
|
145
|
+
return 'rtl';
|
|
146
|
+
} else {
|
|
147
|
+
return 'ltr';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private currencyFormat(value: number | string): string {
|
|
152
|
+
const decimalPipe = new DecimalPipe('en-US');
|
|
153
|
+
return decimalPipe.transform(value, '1.2-2');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|