tuain-ng-forms-lib 14.4.93 → 14.4.96
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/esm2020/lib/classes/forms/action.mjs +36 -0
- package/esm2020/lib/classes/forms/element.mjs +26 -0
- package/esm2020/lib/classes/forms/field.mjs +445 -0
- package/esm2020/lib/classes/forms/form.constants.mjs +26 -0
- package/esm2020/lib/classes/forms/form.mjs +431 -0
- package/esm2020/lib/classes/forms/piece-propagate.mjs +37 -0
- package/esm2020/lib/classes/forms/piece.mjs +95 -0
- package/esm2020/lib/classes/forms/section.mjs +138 -0
- package/esm2020/lib/classes/forms/subsection.mjs +81 -0
- package/esm2020/lib/classes/forms/table/action.mjs +18 -0
- package/esm2020/lib/classes/forms/table/column.mjs +74 -0
- package/esm2020/lib/classes/forms/table/row-data.mjs +116 -0
- package/esm2020/lib/classes/forms/table/table.mjs +416 -0
- package/esm2020/lib/components/elements/action.component.mjs +71 -0
- package/esm2020/lib/components/elements/field.component.mjs +81 -0
- package/esm2020/lib/components/elements/layout/element.component.mjs +20 -0
- package/esm2020/lib/components/elements/layout/form-error.component.mjs +20 -0
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +31 -0
- package/esm2020/lib/components/elements/layout/piece.component.mjs +39 -0
- package/esm2020/lib/components/elements/layout/section.component.mjs +37 -0
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +37 -0
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +56 -0
- package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +30 -0
- package/esm2020/lib/components/elements/tables/table.component.mjs +89 -0
- package/esm2020/lib/components/forms/basic-form.mjs +1530 -0
- package/esm2020/lib/services/event-manager.service.mjs +18 -0
- package/esm2020/lib/services/file-manager.service.mjs +6 -0
- package/esm2020/lib/services/form-manager.service.mjs +80 -0
- package/esm2020/lib/tuain-ng-forms-lib.module.mjs +71 -0
- package/esm2020/public-api.mjs +19 -0
- package/esm2020/tuain-ng-forms-lib.mjs +5 -0
- package/fesm2015/tuain-ng-forms-lib.mjs +4276 -0
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -0
- package/fesm2020/tuain-ng-forms-lib.mjs +4090 -0
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -0
- package/lib/classes/forms/action.d.ts +22 -0
- package/lib/classes/forms/element.d.ts +17 -0
- package/lib/classes/forms/field.d.ts +205 -0
- package/lib/classes/forms/form.constants.d.ts +25 -0
- package/lib/classes/forms/form.d.ts +137 -0
- package/lib/classes/forms/piece-propagate.d.ts +13 -0
- package/lib/classes/forms/piece.d.ts +41 -0
- package/lib/classes/forms/section.d.ts +32 -0
- package/lib/classes/forms/subsection.d.ts +24 -0
- package/lib/classes/forms/table/action.d.ts +15 -0
- package/lib/classes/forms/table/column.d.ts +33 -0
- package/lib/classes/forms/table/row-data.d.ts +14 -0
- package/lib/classes/forms/table/table.d.ts +100 -0
- package/lib/components/elements/action.component.d.ts +17 -0
- package/lib/components/elements/field.component.d.ts +38 -0
- package/lib/components/elements/layout/element.component.d.ts +9 -0
- package/lib/components/elements/layout/form-error.component.d.ts +8 -0
- package/lib/components/elements/layout/form-header.component.d.ts +12 -0
- package/lib/components/elements/layout/piece.component.d.ts +12 -0
- package/lib/components/elements/layout/section.component.d.ts +11 -0
- package/lib/components/elements/layout/sub-section.component.d.ts +11 -0
- package/lib/components/elements/tables/table-record-action.component.d.ts +16 -0
- package/lib/components/elements/tables/table-record-field.component.d.ts +12 -0
- package/lib/components/elements/tables/table.component.d.ts +35 -0
- package/lib/components/forms/basic-form.d.ts +355 -0
- package/lib/services/event-manager.service.d.ts +9 -0
- package/lib/services/file-manager.service.d.ts +5 -0
- package/lib/services/form-manager.service.d.ts +28 -0
- package/lib/tuain-ng-forms-lib.module.d.ts +20 -0
- package/package.json +24 -6
- package/{src/public-api.ts → public-api.d.ts} +0 -5
- package/tuain-ng-forms-lib.d.ts +5 -0
- package/.browserslistrc +0 -16
- package/.yarn/cache/nanoid-npm-4.0.0-924f5c6312-7d5946df5c.zip +0 -0
- package/.yarn/cache/tslib-npm-2.4.1-36f0ed04db-19480d6e03.zip +0 -0
- package/.yarn/cache/yn-npm-5.0.0-b001dab23c-f0ec7710d3.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -11
- package/src/lib/classes/forms/action.ts +0 -56
- package/src/lib/classes/forms/element.ts +0 -29
- package/src/lib/classes/forms/field.ts +0 -500
- package/src/lib/classes/forms/form.constants.ts +0 -28
- package/src/lib/classes/forms/form.ts +0 -508
- package/src/lib/classes/forms/piece-propagate.ts +0 -46
- package/src/lib/classes/forms/piece.ts +0 -122
- package/src/lib/classes/forms/section.ts +0 -152
- package/src/lib/classes/forms/subsection.ts +0 -90
- package/src/lib/classes/forms/table/action.ts +0 -32
- package/src/lib/classes/forms/table/column.ts +0 -94
- package/src/lib/classes/forms/table/row-data.ts +0 -121
- package/src/lib/classes/forms/table/table.ts +0 -478
- package/src/lib/components/elements/action.component.ts +0 -59
- package/src/lib/components/elements/field.component.ts +0 -92
- package/src/lib/components/elements/layout/element.component.ts +0 -13
- package/src/lib/components/elements/layout/form-error.component.ts +0 -11
- package/src/lib/components/elements/layout/form-header.component.ts +0 -17
- package/src/lib/components/elements/layout/piece.component.ts +0 -34
- package/src/lib/components/elements/layout/section.component.ts +0 -31
- package/src/lib/components/elements/layout/sub-section.component.ts +0 -31
- package/src/lib/components/elements/tables/table-record-action.component.ts +0 -50
- package/src/lib/components/elements/tables/table-record-field.component.ts +0 -20
- package/src/lib/components/elements/tables/table.component.ts +0 -86
- package/src/lib/components/forms/basic-form.ts +0 -1588
- package/src/lib/services/event-manager.service.ts +0 -21
- package/src/lib/services/file-manager.service.ts +0 -6
- package/src/lib/services/form-manager.service.ts +0 -89
- package/src/lib/services/icon-dictionary.service.ts +0 -159
- package/src/lib/tuain-ng-forms-lib.module.ts +0 -40
- package/src/test.ts +0 -27
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
2
|
-
import { FormPiecePropagate } from './piece-propagate';
|
|
3
|
-
import { FormAction } from './action';
|
|
4
|
-
import { RecordFormSubSection } from './subsection';
|
|
5
|
-
|
|
6
|
-
const ACTIVE = 'active';
|
|
7
|
-
|
|
8
|
-
export class RecordFormSection extends FormPiecePropagate {
|
|
9
|
-
private readonly _activation = new Subject<string>();
|
|
10
|
-
private readonly _inactivation = new Subject<string>();
|
|
11
|
-
|
|
12
|
-
active = false;
|
|
13
|
-
sectionId: string | null = null;
|
|
14
|
-
sectionCode: string | null = null;
|
|
15
|
-
sectionTitle: string | null = null;
|
|
16
|
-
subSections: RecordFormSubSection[] = [];
|
|
17
|
-
subSectionsObj: any;
|
|
18
|
-
private _exclusiveSubSectionsByAttr = {};
|
|
19
|
-
|
|
20
|
-
constructor(sectionReceived, formObject, formConfig) {
|
|
21
|
-
super(sectionReceived, formConfig);
|
|
22
|
-
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.sections ?? [];
|
|
23
|
-
if (!sectionReceived) { return; }
|
|
24
|
-
this.sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
|
|
25
|
-
this.sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
|
|
26
|
-
this.sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
|
|
27
|
-
this.subSections = [];
|
|
28
|
-
this.subSectionsObj = {};
|
|
29
|
-
if (sectionReceived.subsections) {
|
|
30
|
-
const subsections = sectionReceived.subsections.map(subSecDef => {
|
|
31
|
-
const visibleStates = subSecDef.visibleStates ?? [];
|
|
32
|
-
if (subSecDef.elements && Array.isArray(subSecDef.elements)) {
|
|
33
|
-
subSecDef.elements = subSecDef.elements.map(elm => ({ code: elm.elementCode, type: elm.elementTypeName }));
|
|
34
|
-
}
|
|
35
|
-
return { ...subSecDef, visibleStates };
|
|
36
|
-
});
|
|
37
|
-
for (const subsectionReceived of subsections) {
|
|
38
|
-
const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject, formConfig);
|
|
39
|
-
const subsectionCode = subSectionToAdd.subsectionCode;
|
|
40
|
-
if (subsectionCode) {
|
|
41
|
-
this.subSections.push(subSectionToAdd);
|
|
42
|
-
this.subSectionsObj[subsectionCode] = subSectionToAdd;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get code() { return this.sectionCode; }
|
|
49
|
-
get activation() { return this._activation; }
|
|
50
|
-
get inactivation() { return this._inactivation; }
|
|
51
|
-
|
|
52
|
-
activate() {
|
|
53
|
-
if (!this.active) {
|
|
54
|
-
this.active = true;
|
|
55
|
-
this.sectionCode && this._activation.next(this.sectionCode);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
inactivate() {
|
|
60
|
-
if (this.active) {
|
|
61
|
-
this.active = false;
|
|
62
|
-
this.sectionCode && this._inactivation.next(this.sectionCode);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get title() { return this.sectionTitle; }
|
|
67
|
-
set title(title) { this.sectionTitle = title; }
|
|
68
|
-
|
|
69
|
-
getVisibleSubsections(state) {
|
|
70
|
-
return this.subSections.filter(subSection => subSection.visible);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getSubsection(subSectionCode) {
|
|
74
|
-
return (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
75
|
-
? this.subSectionsObj[subSectionCode] : null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
activateSubSection(subSectionCode) {
|
|
79
|
-
if (subSectionCode === this._exclusiveSubSectionsByAttr[ACTIVE]) { return; }
|
|
80
|
-
const subSection = (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
81
|
-
? this.subSectionsObj[subSectionCode] : null;
|
|
82
|
-
if (subSection) {
|
|
83
|
-
subSection?.activate();
|
|
84
|
-
this._exclusiveSubSectionsByAttr[ACTIVE] = subSectionCode;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getFields() {
|
|
89
|
-
let fieldsArray: any[] = [];
|
|
90
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
91
|
-
for (const subSection of this.subSections) {
|
|
92
|
-
const subsectionFields: any[] = subSection.getFields() ?? [];
|
|
93
|
-
if (subsectionFields?.length > 0) {
|
|
94
|
-
fieldsArray = fieldsArray.concat(subsectionFields);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return fieldsArray;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getActions(): FormAction[] {
|
|
102
|
-
let actionArray: any[] = [];
|
|
103
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
104
|
-
for (const subSection of this.subSections) {
|
|
105
|
-
const subSectionActions = subSection.getActions() ?? [];
|
|
106
|
-
if (subSectionActions?.length > 0) {
|
|
107
|
-
actionArray = actionArray.concat(subSectionActions);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return actionArray;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getActionNames(): string[] {
|
|
115
|
-
let actionArray: string[] = [];
|
|
116
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
117
|
-
for (const subSection of this.subSections) {
|
|
118
|
-
actionArray = actionArray.concat(subSection.getActionNames());
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return actionArray;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getFieldNames() {
|
|
125
|
-
let fieldsArray: string[] = [];
|
|
126
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
127
|
-
for (const subSection of this.subSections) {
|
|
128
|
-
fieldsArray = fieldsArray.concat(subSection.getFieldNames());
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return fieldsArray;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
getField(name) {
|
|
135
|
-
let field = null;
|
|
136
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
137
|
-
for (const subSection of this.subSections) {
|
|
138
|
-
field = subSection.getField(name);
|
|
139
|
-
if (field) {
|
|
140
|
-
return field;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
override formStateChangeCustomSubscribe(formChangeSubject) {
|
|
148
|
-
this.subSections?.forEach(subsection => {
|
|
149
|
-
subsection?.subscribeFormStateChange(formChangeSubject);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { FormPiecePropagate } from './piece-propagate';
|
|
2
|
-
import { FormAction } from './action';
|
|
3
|
-
import { elementTypes } from './form.constants';
|
|
4
|
-
|
|
5
|
-
export class RecordFormSubSection extends FormPiecePropagate {
|
|
6
|
-
_customRender: string | null = null;
|
|
7
|
-
subsectionId: string | null = null;
|
|
8
|
-
subsectionCode: string | null = null;
|
|
9
|
-
subsectionTitle: string | null = null;
|
|
10
|
-
|
|
11
|
-
subSectionElements: any[] = [];
|
|
12
|
-
subSectionFields: any[] = [];
|
|
13
|
-
subSectionTables: any[] = [];
|
|
14
|
-
subSectionActions: any[] = [];
|
|
15
|
-
elementsArray: any = {};
|
|
16
|
-
active = false;
|
|
17
|
-
|
|
18
|
-
constructor(subsectionReceived, formObject, formConfig) {
|
|
19
|
-
super(subsectionReceived, formConfig);
|
|
20
|
-
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.subsections ?? [];
|
|
21
|
-
if (!subsectionReceived) { return; }
|
|
22
|
-
this.subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
|
|
23
|
-
this.subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
|
|
24
|
-
this.subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
|
|
25
|
-
if (subsectionReceived.elements) {
|
|
26
|
-
for (const receivedElement of subsectionReceived.elements) {
|
|
27
|
-
let elementObject: any = null;
|
|
28
|
-
let arrayToAdd: any[] = [];
|
|
29
|
-
const { type, code } = receivedElement;
|
|
30
|
-
switch (type) {
|
|
31
|
-
case elementTypes.field:
|
|
32
|
-
elementObject = formObject.getField(code);
|
|
33
|
-
arrayToAdd = this.subSectionFields;
|
|
34
|
-
break;
|
|
35
|
-
case elementTypes.table:
|
|
36
|
-
elementObject = formObject.getTable(code);
|
|
37
|
-
arrayToAdd = this.subSectionTables;
|
|
38
|
-
break;
|
|
39
|
-
case elementTypes.action:
|
|
40
|
-
elementObject = formObject.getAction(code);
|
|
41
|
-
arrayToAdd = this.subSectionActions;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
if (elementObject) {
|
|
45
|
-
elementObject.elementType = type;
|
|
46
|
-
arrayToAdd.push(elementObject);
|
|
47
|
-
this.subSectionElements.push(elementObject);
|
|
48
|
-
this.elementsArray[code] = elementObject;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get customRender() { return this._customRender; }
|
|
55
|
-
set customRender(customRenderName) { this._customRender = customRenderName; }
|
|
56
|
-
|
|
57
|
-
getField(name) {
|
|
58
|
-
return this.subSectionFields.find(fld => fld.name === name);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getFields() {
|
|
62
|
-
return this.subSectionFields;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
getFieldNames() {
|
|
66
|
-
return this.subSectionFields.map(field => field.code);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getActions(): FormAction[] {
|
|
70
|
-
return this.subSectionActions;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getActionNames(): string[] {
|
|
74
|
-
return this.subSectionActions.map(action => action.actionCode);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
activate() {
|
|
78
|
-
if (!this.active) {
|
|
79
|
-
this.active = true;
|
|
80
|
-
// this.subsectionCode && this._activation.next(this.subsectionCode);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
inactivate() {
|
|
85
|
-
if (this.active) {
|
|
86
|
-
this.active = false;
|
|
87
|
-
// this.subsectionCode && this._inactivation.next(this.subsectionCode);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FormPiece } from '../piece';
|
|
2
|
-
export class TableAction extends FormPiece {
|
|
3
|
-
newState: string;
|
|
4
|
-
|
|
5
|
-
actionCode: string;
|
|
6
|
-
actionTitle: string;
|
|
7
|
-
iconName: string;
|
|
8
|
-
actionType: string;
|
|
9
|
-
actionClass: string;
|
|
10
|
-
stateField: string;
|
|
11
|
-
|
|
12
|
-
backend: boolean;
|
|
13
|
-
restrictedOnField: string;
|
|
14
|
-
restrictedOnValue: string;
|
|
15
|
-
restrictedOnOperator: string;
|
|
16
|
-
|
|
17
|
-
constructor(actionDefinition, formConfig) {
|
|
18
|
-
super(actionDefinition, formConfig);
|
|
19
|
-
|
|
20
|
-
this.actionCode = actionDefinition.actionCode;
|
|
21
|
-
this.actionTitle = actionDefinition.actionTitle;
|
|
22
|
-
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
23
|
-
this.actionType = actionDefinition.actionType || 'STANDARD';
|
|
24
|
-
this.actionClass = actionDefinition.actionClass || 'INLINE';
|
|
25
|
-
this.newState = actionDefinition.newState;
|
|
26
|
-
this.stateField = actionDefinition.stateField || '';
|
|
27
|
-
this.backend = actionDefinition?.serverAction ?? false;
|
|
28
|
-
this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
|
|
29
|
-
this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
|
|
30
|
-
this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { FormPiece } from '../piece';
|
|
2
|
-
|
|
3
|
-
export interface FilterDef {
|
|
4
|
-
operators: string[];
|
|
5
|
-
options: any[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface FilterSetup {
|
|
9
|
-
fieldCode: string;
|
|
10
|
-
operator: string;
|
|
11
|
-
values: any[];
|
|
12
|
-
}
|
|
13
|
-
export class RecordTableColumn extends FormPiece {
|
|
14
|
-
fieldCode: string = '';
|
|
15
|
-
fieldTitle: string = '';
|
|
16
|
-
fieldType: string = '';
|
|
17
|
-
fieldAlignment: string = '';
|
|
18
|
-
fieldFormat: string = '';
|
|
19
|
-
sortable: boolean = true;
|
|
20
|
-
searchable: boolean = true;
|
|
21
|
-
sortDirections: string[] = [];
|
|
22
|
-
// Filtros
|
|
23
|
-
filterVisible: boolean = false;
|
|
24
|
-
filterDef: FilterDef | null = null;
|
|
25
|
-
filterSetup: FilterSetup | null = null;
|
|
26
|
-
|
|
27
|
-
constructor(recTableColReceived, formConfig) {
|
|
28
|
-
super(recTableColReceived, formConfig);
|
|
29
|
-
this.filterDef = null;
|
|
30
|
-
if (recTableColReceived) {
|
|
31
|
-
this.fieldCode = recTableColReceived.fieldCode;
|
|
32
|
-
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
33
|
-
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
34
|
-
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
35
|
-
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
36
|
-
this._absoluteVisible = recTableColReceived?.visible ?? true;
|
|
37
|
-
this.sortable = recTableColReceived?.sortable ?? false;
|
|
38
|
-
this.searchable = recTableColReceived?.searchable ?? true;
|
|
39
|
-
this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [];
|
|
40
|
-
this.fieldFormat = recTableColReceived.format || '';
|
|
41
|
-
this.customAttributes = recTableColReceived?.customAttributes ?? {};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setSearchable(searchable = true) { this.searchable = searchable; }
|
|
46
|
-
|
|
47
|
-
hideFilter() {
|
|
48
|
-
this.filterVisible = false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
addFilterDefinition(filterDefinition) {
|
|
52
|
-
this.filterDef = {
|
|
53
|
-
operators: filterDefinition.operators,
|
|
54
|
-
options: filterDefinition.options ?? null,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get filterDefinition() {
|
|
59
|
-
return this.filterDef;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
addFilter(columnValues, operator) {
|
|
63
|
-
this.filterSetup = {
|
|
64
|
-
fieldCode: this.fieldCode,
|
|
65
|
-
operator: operator ?? this.filterDef?.operators[0],
|
|
66
|
-
values: columnValues,
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get filter() {
|
|
71
|
-
return this.filterSetup;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
removeFilter() {
|
|
75
|
-
this.filterSetup = null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get options() {
|
|
79
|
-
if (this.filterDef?.operators?.length === 1 && this.filterDef?.operators[0] === 'IN') {
|
|
80
|
-
return this.filterDef?.options;
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
serSortDirections(ascend: boolean, descend: boolean) {
|
|
86
|
-
this.sortDirections = [];
|
|
87
|
-
if (ascend) {
|
|
88
|
-
this.sortDirections.unshift('ascend');
|
|
89
|
-
}
|
|
90
|
-
if (descend) {
|
|
91
|
-
this.sortDirections.unshift('descend');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { RecordTableColumn } from './column';
|
|
2
|
-
import { operators } from '../form.constants';
|
|
3
|
-
|
|
4
|
-
export class TableRecordData {
|
|
5
|
-
recordId: string | null = null;
|
|
6
|
-
selected: boolean = false;
|
|
7
|
-
recordData: any = {};
|
|
8
|
-
|
|
9
|
-
constructor(recordReceived, recordDefinition: RecordTableColumn[], selectionFieldName = null) {
|
|
10
|
-
const { tableRecordId, recordData } = recordReceived;
|
|
11
|
-
this.recordId = tableRecordId;
|
|
12
|
-
if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const fieldNames = recordDefinition.map(column => column.fieldCode);
|
|
16
|
-
if (Array.isArray(recordData)) {
|
|
17
|
-
const rawRecordData = recordData.filter(fieldData => fieldData.fieldCode && fieldNames.includes(fieldData.fieldCode));
|
|
18
|
-
rawRecordData.forEach(fieldData => {
|
|
19
|
-
const { fieldCode, fieldValue } = fieldData;
|
|
20
|
-
const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
|
|
21
|
-
this.recordData[fieldCode] = fieldValue ?? '';
|
|
22
|
-
if (fieldCode === selectionFieldName) {
|
|
23
|
-
this.selected = fieldValue;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
const fields = Object.keys(recordData);
|
|
28
|
-
fields.forEach(fieldCode => {
|
|
29
|
-
const fieldValue = recordData[fieldCode];
|
|
30
|
-
const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
|
|
31
|
-
this.recordData[fieldCode] = fieldValue ?? '';
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
toggleSelect() { this.selected = !this.selected; }
|
|
37
|
-
select() { this.selected = true; }
|
|
38
|
-
unselect() { this.selected = false; }
|
|
39
|
-
|
|
40
|
-
get recordIdKey() {
|
|
41
|
-
return (typeof this.recordId === 'object')
|
|
42
|
-
? JSON.stringify(this.recordId) : this.recordId;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getFieldValue(fieldCode): any {
|
|
46
|
-
return (fieldCode && this.recordData) ? this.recordData[fieldCode] : null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
hasPattern(words, columnObj) {
|
|
50
|
-
if (!words || words.length === 0) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
for (const word of words) {
|
|
54
|
-
let wordIsPresent = false;
|
|
55
|
-
for (const fieldCode in this.recordData) {
|
|
56
|
-
const columnDef = columnObj?.[fieldCode];
|
|
57
|
-
if (columnDef?.searchable && this.recordData.hasOwnProperty(fieldCode)) {
|
|
58
|
-
const term = word.toUpperCase();
|
|
59
|
-
let fieldValue;
|
|
60
|
-
if (columnDef.fieldType.toUpperCase().includes('DATE')) {
|
|
61
|
-
fieldValue = this.recordData[fieldCode].substring(0, 16);
|
|
62
|
-
} else {
|
|
63
|
-
fieldValue = this.recordData[fieldCode];
|
|
64
|
-
}
|
|
65
|
-
if (fieldValue.toString().toUpperCase().includes(term)) {
|
|
66
|
-
wordIsPresent = true;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!wordIsPresent) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
hasCondition(columnFilters) {
|
|
79
|
-
if (!columnFilters || columnFilters.length === 0) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
for (const condition of columnFilters) {
|
|
83
|
-
const { fieldCode, operator, values } = condition;
|
|
84
|
-
if (this.recordData.hasOwnProperty(fieldCode)) {
|
|
85
|
-
const fieldValue = this.recordData[fieldCode];
|
|
86
|
-
const stringValue = fieldValue.toString().toUpperCase();
|
|
87
|
-
if (operator === operators.G && fieldValue <= values[0]) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (operator === operators.L && fieldValue >= values[0]) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (operator === operators.GE && fieldValue < values[0]) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (operator === operators.LE && fieldValue > values[0]) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
if (operator === operators.IN && !values.includes(fieldValue)) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
if (operator === operators.EQ) {
|
|
103
|
-
return fieldValue === values[0];
|
|
104
|
-
}
|
|
105
|
-
if (operator === operators.NEQ && fieldValue === values[0]) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
if (operator === operators.HAS && !stringValue.includes(values[0].toString().toUpperCase())) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (operator === operators.NOTHAS && stringValue.includes(values[0].toString().toUpperCase())) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
if (operator === operators.BETWEEN && (fieldValue < values[0] || fieldValue > values[1])) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
}
|