tuain-ng-forms-lib 14.4.93 → 14.4.95
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 +1514 -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 +4259 -0
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -0
- package/fesm2020/tuain-ng-forms-lib.mjs +4074 -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 +353 -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,478 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
2
|
-
import { elementTypes } from '../form.constants';
|
|
3
|
-
import { FormElement } from '../element';
|
|
4
|
-
import { RecordTableColumn } from './column';
|
|
5
|
-
import { TableAction } from './action';
|
|
6
|
-
import { TableRecordData } from './row-data';
|
|
7
|
-
|
|
8
|
-
const TABLE_SORT_ASCENDING = 'asc';
|
|
9
|
-
const TABLE_SORT_DESCENDING = 'desc';
|
|
10
|
-
|
|
11
|
-
const attrs = {
|
|
12
|
-
allSelected: { name: 'allSelected', propagate: 'allSelected' },
|
|
13
|
-
tableCode: { name: 'tableCode', propagate: 'code' },
|
|
14
|
-
clientPaging: { name: 'clientPaging', propagate: null },
|
|
15
|
-
globalSearch: { name: 'globalSearch', propagate: 'globalSearch' },
|
|
16
|
-
globalFilterString: { name: 'globalFilterString', propagate: 'globalFilterString' },
|
|
17
|
-
sorting: { name: 'sorting', propagate: null },
|
|
18
|
-
recordsPerPage: { name: 'recordsPerPage', propagate: 'recordsPerPage' },
|
|
19
|
-
layout: { name: 'layout', propagate: 'layout' },
|
|
20
|
-
columns: { name: 'columns', propagate: 'columns' },
|
|
21
|
-
selectedRecords: { name: 'selectedRecords', propagate: 'selectedRecords' },
|
|
22
|
-
currentPage: { name: 'currentPage', propagate: 'currentPage' },
|
|
23
|
-
totalRecordsNumber: { name: 'totalRecordsNumber', propagate: 'totalRecordsNumber' },
|
|
24
|
-
visibleRecords: { name: 'visibleRecords', propagate: 'visibleRecords' },
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export interface TableActionEvent {
|
|
28
|
-
actionCode: string;
|
|
29
|
-
recordId: any;
|
|
30
|
-
recordData: any;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface TableEvent {
|
|
34
|
-
tableCode: string;
|
|
35
|
-
actionCode: string | null;
|
|
36
|
-
actionDetail: any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class RecordTable extends FormElement {
|
|
40
|
-
private readonly _inlineActionTrigger = new Subject<TableEvent>();
|
|
41
|
-
private readonly _globalActionTrigger = new Subject<TableEvent>();
|
|
42
|
-
private readonly _recordSelectionTrigger = new Subject<TableEvent>();
|
|
43
|
-
private readonly _selectionActionTrigger = new Subject<TableEvent>();
|
|
44
|
-
private readonly _getDataTrigger = new Subject<TableEvent>();
|
|
45
|
-
private _tableColumnObj = {};
|
|
46
|
-
private _appendPages: boolean;
|
|
47
|
-
private _actions: TableAction[];
|
|
48
|
-
private _actionsObj = {};
|
|
49
|
-
|
|
50
|
-
// Mecanismos de filtrado nueva versión
|
|
51
|
-
private globalFilterString: string = '';
|
|
52
|
-
private globalFilterStrings: string[] = [];
|
|
53
|
-
private selectedRecords: any;
|
|
54
|
-
private restrictedId: any;
|
|
55
|
-
private layout: string | null = null;
|
|
56
|
-
|
|
57
|
-
globalSearch: boolean;
|
|
58
|
-
tableRecords: TableRecordData[];
|
|
59
|
-
tableRecordObj = {};
|
|
60
|
-
visibleRecords: TableRecordData[] | null = null;
|
|
61
|
-
columns: RecordTableColumn[];
|
|
62
|
-
selectable: boolean;
|
|
63
|
-
selectionBackend: boolean;
|
|
64
|
-
selectionField: string;
|
|
65
|
-
allSelected = false;
|
|
66
|
-
|
|
67
|
-
tableCode: string = '';
|
|
68
|
-
tableTitle: string;
|
|
69
|
-
currentPage: number;
|
|
70
|
-
totalPages: number;
|
|
71
|
-
requestedPage: number;
|
|
72
|
-
recordsPerPage: number = 10;
|
|
73
|
-
totalRecordsNumber: number = 0;
|
|
74
|
-
recordsNumber: number = 0;
|
|
75
|
-
sorting: any;
|
|
76
|
-
|
|
77
|
-
waiting: boolean;
|
|
78
|
-
clientPaging: boolean = true;
|
|
79
|
-
sortable: boolean;
|
|
80
|
-
|
|
81
|
-
constructor(tableReceived, formConfig) {
|
|
82
|
-
super(tableReceived, formConfig);
|
|
83
|
-
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.tables ?? [];
|
|
84
|
-
this.elementType = elementTypes.table;
|
|
85
|
-
this.waiting = false;
|
|
86
|
-
this.currentPage = 1;
|
|
87
|
-
this.totalPages = 1;
|
|
88
|
-
this.requestedPage = 1;
|
|
89
|
-
this.columns = [];
|
|
90
|
-
this._tableColumnObj = {};
|
|
91
|
-
this._actions = [];
|
|
92
|
-
this._actionsObj = {};
|
|
93
|
-
this.tableRecords = [];
|
|
94
|
-
this.globalSearch = false;
|
|
95
|
-
this.restrictedId = null;
|
|
96
|
-
|
|
97
|
-
this.tableTitle = tableReceived.tableTitle;
|
|
98
|
-
this._appendPages = tableReceived?.append ?? false;
|
|
99
|
-
this.selectable = tableReceived?.selectable ?? false;
|
|
100
|
-
this.selectionBackend = tableReceived?.selectionBackend ?? false;
|
|
101
|
-
this.sortable = tableReceived?.sortable ?? false;
|
|
102
|
-
|
|
103
|
-
this.setAttr(attrs.allSelected, false);
|
|
104
|
-
this.setAttr(attrs.tableCode, tableReceived.tableCode);
|
|
105
|
-
this.setAttr(attrs.clientPaging, tableReceived?.clientPaging ?? true);
|
|
106
|
-
this.setAttr(attrs.globalSearch, tableReceived?.simpleFilter ?? false);
|
|
107
|
-
this.setAttr(attrs.globalFilterString, '');
|
|
108
|
-
this.setAttr(attrs.sorting, { columnName: '', direction: '' });
|
|
109
|
-
this.setAttr(attrs.recordsPerPage, formConfig.defaultRecordsPerPage);
|
|
110
|
-
this.setAttr(attrs.layout, '');
|
|
111
|
-
|
|
112
|
-
if (tableReceived.fields) {
|
|
113
|
-
const columns: RecordTableColumn[] = [];
|
|
114
|
-
for (const columnReceived of tableReceived.fields) {
|
|
115
|
-
const columnEnriched = {
|
|
116
|
-
...columnReceived,
|
|
117
|
-
visibleStates: this.visibleStates,
|
|
118
|
-
enabledStates: this.enabledStates
|
|
119
|
-
};
|
|
120
|
-
const columnDefinition: RecordTableColumn = new RecordTableColumn(columnEnriched, this._formConfig);
|
|
121
|
-
columns.push(columnDefinition);
|
|
122
|
-
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
123
|
-
}
|
|
124
|
-
this.setAttr(attrs.columns, columns);
|
|
125
|
-
}
|
|
126
|
-
if (tableReceived.actions) {
|
|
127
|
-
const tableActions = tableReceived.actions.map(objDef => {
|
|
128
|
-
let visibleStates = objDef.visibleStates;
|
|
129
|
-
let enabledStates = objDef.enabledStates;
|
|
130
|
-
if (!visibleStates) {
|
|
131
|
-
visibleStates = (objDef.actionModes || '').split(',')
|
|
132
|
-
.map(state => state.trim())
|
|
133
|
-
.filter(state => state.length > 0);
|
|
134
|
-
enabledStates = (objDef.actionModes || '').split(',')
|
|
135
|
-
.map(state => state.trim())
|
|
136
|
-
.filter(state => state.length > 0);
|
|
137
|
-
}
|
|
138
|
-
return { ...objDef, visibleStates, enabledStates };
|
|
139
|
-
});
|
|
140
|
-
for (const actionReceived of tableActions) {
|
|
141
|
-
const inlineAction = new TableAction(actionReceived, this._formConfig);
|
|
142
|
-
this._actions.push(inlineAction);
|
|
143
|
-
this._actionsObj[inlineAction.actionCode] = inlineAction;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
this.selectionField = (this.selectable) ? tableReceived?.selectionField : null;
|
|
147
|
-
// Filtros predefinidos en el formulario
|
|
148
|
-
if (tableReceived.filters) {
|
|
149
|
-
for (let index = 0; index < tableReceived.filters.length; index++) {
|
|
150
|
-
this.addFilterDefinition(tableReceived.filters[index].fieldCode, tableReceived.filters[index]);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
get columnNames() { return Object.keys(this._tableColumnObj); }
|
|
156
|
-
get inlineActionTrigger() { return this._inlineActionTrigger; }
|
|
157
|
-
get globalActionTrigger() { return this._globalActionTrigger; }
|
|
158
|
-
get selectionActionTrigger() { return this._selectionActionTrigger; }
|
|
159
|
-
get recordSelectionTrigger() { return this._recordSelectionTrigger; }
|
|
160
|
-
get getDataTrigger() { return this._getDataTrigger; }
|
|
161
|
-
|
|
162
|
-
getLayout() { return this.layout; }
|
|
163
|
-
setLayout(layout) { this.setAttr(attrs.layout, layout); }
|
|
164
|
-
hasActions() { return (this._actions.length > 0); }
|
|
165
|
-
getSelectedRecords() { return this.tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
|
|
166
|
-
activateGlobalSearch() { this.globalSearch = true; }
|
|
167
|
-
inactivateGlobalSearch() { this.globalSearch = false; }
|
|
168
|
-
columnDefinition(fieldCode): RecordTableColumn { return this._tableColumnObj[fieldCode]; }
|
|
169
|
-
putOnWait() { this.waiting = true; }
|
|
170
|
-
freeWaiting() { this.waiting = false; }
|
|
171
|
-
|
|
172
|
-
notifyGlobalAction(actionCode) {
|
|
173
|
-
const tableEvent: TableEvent = {
|
|
174
|
-
tableCode: this.tableCode,
|
|
175
|
-
actionCode,
|
|
176
|
-
actionDetail: null
|
|
177
|
-
};
|
|
178
|
-
this._globalActionTrigger.next(tableEvent);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
notifyInlineAction(tableActionEvent: TableActionEvent) {
|
|
182
|
-
const tableEvent: TableEvent = {
|
|
183
|
-
tableCode: this.tableCode,
|
|
184
|
-
actionCode: tableActionEvent.actionCode,
|
|
185
|
-
actionDetail: {
|
|
186
|
-
recordId: tableActionEvent.recordId,
|
|
187
|
-
recordData: tableActionEvent.recordData
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
this._inlineActionTrigger.next(tableEvent);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
notifyRecordSelection(recordId) {
|
|
194
|
-
const record = this.getTableRecord(recordId);
|
|
195
|
-
if (!record) { return; }
|
|
196
|
-
record.toggleSelect();
|
|
197
|
-
this.requestedPage = this.currentPage ?? 1;
|
|
198
|
-
const tableEvent: TableEvent = {
|
|
199
|
-
tableCode: this.tableCode,
|
|
200
|
-
actionCode: null,
|
|
201
|
-
actionDetail: {
|
|
202
|
-
recordId: record.recordId,
|
|
203
|
-
recordData: record.recordData
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
this.recordSelectionTrigger.next(tableEvent);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
notifySelectionAction(actionCode) {
|
|
210
|
-
const tableEvent: TableEvent = {
|
|
211
|
-
tableCode: this.tableCode,
|
|
212
|
-
actionCode,
|
|
213
|
-
actionDetail: {
|
|
214
|
-
selectedRecords: this.selectedRecords
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
this._selectionActionTrigger.next(tableEvent);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
notifyGetDataAction(requestedPage = null) {
|
|
221
|
-
this.updateVisibleRecords();
|
|
222
|
-
this.requestedPage = requestedPage || this.currentPage || 1;
|
|
223
|
-
const tableEvent: TableEvent = {
|
|
224
|
-
tableCode: this.tableCode,
|
|
225
|
-
actionCode: null,
|
|
226
|
-
actionDetail: null,
|
|
227
|
-
};
|
|
228
|
-
this._getDataTrigger.next(tableEvent);
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
clean() {
|
|
233
|
-
this.tableRecords = [];
|
|
234
|
-
this.unSelectAll();
|
|
235
|
-
this.tableRecordObj = {};
|
|
236
|
-
this.updateVisibleRecords();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
selectAll() {
|
|
240
|
-
this.setAttr(attrs.allSelected, true);
|
|
241
|
-
this.tableRecords.forEach(record => record.select());
|
|
242
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
243
|
-
return true;
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
unSelectAll() {
|
|
248
|
-
this.setAttr(attrs.allSelected, false);
|
|
249
|
-
this.tableRecords.forEach(record => record.unselect());
|
|
250
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
setTableRecords(tableRecords, append) {
|
|
255
|
-
if (!append) {
|
|
256
|
-
this.tableRecords = [];
|
|
257
|
-
this.setAttr(attrs.allSelected, false);
|
|
258
|
-
this.tableRecords.forEach(record => record.unselect());
|
|
259
|
-
this.setAttr(attrs.selectedRecords, []);
|
|
260
|
-
this.tableRecordObj = {};
|
|
261
|
-
}
|
|
262
|
-
const newRecordsObj = { ...this.tableRecordObj };
|
|
263
|
-
const newRecords = [...this.tableRecords];
|
|
264
|
-
for (const tableRecord of tableRecords) {
|
|
265
|
-
const recordReceived: TableRecordData = new TableRecordData(tableRecord, this.columns, this.selectionField);
|
|
266
|
-
const recordIdKey = recordReceived.recordIdKey;
|
|
267
|
-
newRecords.push(recordReceived);
|
|
268
|
-
newRecordsObj[recordIdKey] = recordReceived;
|
|
269
|
-
}
|
|
270
|
-
this.tableRecords = newRecords;
|
|
271
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
272
|
-
this.tableRecordObj = newRecordsObj;
|
|
273
|
-
this.updateVisibleRecords();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
appendRecords(records) { this.setTableRecords(records, true); }
|
|
277
|
-
replaceRecords(records) { this.setTableRecords(records, false); }
|
|
278
|
-
|
|
279
|
-
setTableAppend(append: boolean) { this._appendPages = append }
|
|
280
|
-
|
|
281
|
-
changePage(requestedPage) {
|
|
282
|
-
if (this.clientPaging) {
|
|
283
|
-
this.setAttr(attrs.currentPage, requestedPage);
|
|
284
|
-
this.updateVisibleRecords();
|
|
285
|
-
} else {
|
|
286
|
-
this.notifyGetDataAction(requestedPage);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
updateVisibleRecords() {
|
|
291
|
-
let visibleRecords: any[];
|
|
292
|
-
if (this.clientPaging) {
|
|
293
|
-
let filteredRecords = this.getFilteredRecords();
|
|
294
|
-
this.setAttr(attrs.totalRecordsNumber, filteredRecords.length);
|
|
295
|
-
const sliceNumber1 = (this.currentPage - 1) * this.recordsPerPage;
|
|
296
|
-
const sliceNumber2 = (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage
|
|
297
|
-
visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
|
|
298
|
-
const recordsLastPage = this.totalRecordsNumber % this.recordsPerPage;
|
|
299
|
-
const totalPages = Math.trunc(this.totalRecordsNumber / this.recordsPerPage + (recordsLastPage ? 1 : 0));
|
|
300
|
-
if (this.currentPage > totalPages) {
|
|
301
|
-
this.currentPage = totalPages || 1;
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
visibleRecords = this.tableRecords;
|
|
305
|
-
}
|
|
306
|
-
this.setAttr(attrs.visibleRecords, visibleRecords);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
updateFromServer(tableReceived) {
|
|
310
|
-
this.requestedPage = 1;
|
|
311
|
-
this.visible = tableReceived?.visible || true;
|
|
312
|
-
this.totalPages = tableReceived.totalPages || 1;
|
|
313
|
-
this.recordsNumber = tableReceived.recordsNumber;
|
|
314
|
-
this.setAttr(attrs.currentPage, +tableReceived?.currentPage || 1);
|
|
315
|
-
this.setAttr(attrs.recordsPerPage, +tableReceived.recordsPerPage);
|
|
316
|
-
this.setAttr(attrs.totalRecordsNumber, (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
|
|
317
|
-
this.setAttr(attrs.sorting, {
|
|
318
|
-
columnName: tableReceived.sortingColumn || '',
|
|
319
|
-
direction: tableReceived.sortingDirection || ''
|
|
320
|
-
});
|
|
321
|
-
this.waiting = false;
|
|
322
|
-
if (!this._appendPages) {
|
|
323
|
-
this.replaceRecords(tableReceived.tableRecords);
|
|
324
|
-
} else {
|
|
325
|
-
this.appendRecords(tableReceived.tableRecords);
|
|
326
|
-
}
|
|
327
|
-
this.updateVisibleRecords();
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
getTableRecord(recordId) {
|
|
331
|
-
const recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
|
|
332
|
-
return (this.tableRecordObj && recordId && this.tableRecordObj[recordId])
|
|
333
|
-
? this.tableRecordObj[recordId] : null;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
getAction(actionCode) {
|
|
337
|
-
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
338
|
-
? this._actionsObj[actionCode] : null;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
getActions(actionClass: string = this._formConfig.tableActions.inline, actionTypes: string[] = null) {
|
|
342
|
-
return this._actions.filter(actionDef => {
|
|
343
|
-
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
344
|
-
return actionDef.actionClass === actionClass && typeIncluded;
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Filtros
|
|
349
|
-
|
|
350
|
-
setFilterById(id) {
|
|
351
|
-
if (this.restrictedId === id) { return; }
|
|
352
|
-
this.restrictedId = id;
|
|
353
|
-
this.updateVisibleRecords();
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
cleanIdFilter() {
|
|
357
|
-
if (this.restrictedId === null) { return; }
|
|
358
|
-
this.restrictedId = null;
|
|
359
|
-
this.updateVisibleRecords();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
setGlobalFilterString(text, notifyComponent = true) {
|
|
363
|
-
this.globalFilterStrings = text.split(' ').filter(t => t && t.trim().length > 0).map(t => t.trim()) ?? [];
|
|
364
|
-
if (this.clientPaging) {
|
|
365
|
-
this.changePage(1);
|
|
366
|
-
}
|
|
367
|
-
if (notifyComponent) {
|
|
368
|
-
this.setAttr(attrs.globalFilterString, text.trim());
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
addFilterDefinition(columnName, filterDefinition) {
|
|
373
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
374
|
-
tableColumn && tableColumn.addFilterDefinition(filterDefinition);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
getFilteredRecords() {
|
|
378
|
-
let filteredRecords = this.tableRecords;
|
|
379
|
-
if (this.restrictedId) {
|
|
380
|
-
filteredRecords = filteredRecords.filter(record => record.recordId === this.restrictedId);
|
|
381
|
-
}
|
|
382
|
-
if (this.globalFilterStrings.length > 0) {
|
|
383
|
-
filteredRecords = filteredRecords.filter(record => record.hasPattern(this.globalFilterStrings, this._tableColumnObj));
|
|
384
|
-
}
|
|
385
|
-
const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
|
|
386
|
-
if (columnFilters.length > 0) {
|
|
387
|
-
filteredRecords = filteredRecords.filter(record => record.hasCondition(columnFilters));
|
|
388
|
-
}
|
|
389
|
-
return filteredRecords;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
getColumnFilter(columnName: string) {
|
|
393
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
394
|
-
return tableColumn?.filter ?? null;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
addColumnFilter(columnName: string, columnValues: any | any[], operator: string = null) {
|
|
398
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
399
|
-
const columnFilterDefinition = tableColumn?.filterDefinition ?? null;
|
|
400
|
-
if (!columnFilterDefinition) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
tableColumn && tableColumn.addFilter(columnValues, operator);
|
|
404
|
-
this.updateVisibleRecords();
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
removeColumnFilter(columnName: string) {
|
|
408
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
409
|
-
tableColumn && tableColumn.removeFilter();
|
|
410
|
-
this.updateVisibleRecords();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
get currentFilter() {
|
|
414
|
-
const compactFilter: any = {
|
|
415
|
-
simpleFilterWords: this.globalFilterStrings,
|
|
416
|
-
advancedFilter: [],
|
|
417
|
-
};
|
|
418
|
-
const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
|
|
419
|
-
for (let index = 0; index < columnFilters.length; index++) {
|
|
420
|
-
const columnFilter = columnFilters[index];
|
|
421
|
-
compactFilter.advancedFilter.push({
|
|
422
|
-
fieldCode: columnFilter?.fieldCode,
|
|
423
|
-
operator: columnFilter?.operator,
|
|
424
|
-
fieldValue1: columnFilter?.values[0],
|
|
425
|
-
fieldValue2: columnFilter?.values[1],
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
return compactFilter;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// Ordenamiento de registros local
|
|
432
|
-
|
|
433
|
-
sort(columnName, direction) {
|
|
434
|
-
this.setRequiredOrder(columnName, direction);
|
|
435
|
-
if (this.clientPaging) {
|
|
436
|
-
this.localSortData()
|
|
437
|
-
} else {
|
|
438
|
-
this.notifyGetDataAction();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
setRequiredOrder(columnField, direction = null) {
|
|
443
|
-
this.setAttr(attrs.sorting, {
|
|
444
|
-
columnName: columnField,
|
|
445
|
-
direction: (direction === 'ascend') ? TABLE_SORT_ASCENDING : TABLE_SORT_DESCENDING,
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
localSortData() {
|
|
450
|
-
if (!this.sorting.columnName || !this.sorting.direction) { return; }
|
|
451
|
-
this.tableRecords.sort((a, b) => this.recordCompare(a, b, this.sorting.columnName, this.sorting.direction));
|
|
452
|
-
//this.unSelectAll();
|
|
453
|
-
this.updateVisibleRecords();
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
recordCompare(recordA: TableRecordData, recordB: TableRecordData, columnCompare, direction) {
|
|
457
|
-
const recordAValue = recordA.getFieldValue(columnCompare);
|
|
458
|
-
const recordBValue = recordB.getFieldValue(columnCompare);
|
|
459
|
-
const recordAColumn = isNaN(recordAValue) ? recordAValue.toLocaleLowerCase() : +recordAValue;
|
|
460
|
-
const recordBColumn = isNaN(recordBValue) ? recordBValue.toLocaleLowerCase() : +recordBValue;
|
|
461
|
-
let result = 0;
|
|
462
|
-
if (recordAColumn < recordBColumn) {
|
|
463
|
-
result = -1;
|
|
464
|
-
} else if (recordAColumn > recordBColumn) {
|
|
465
|
-
result = 1;
|
|
466
|
-
}
|
|
467
|
-
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
override formStateChangeCustomSubscribe(formChangeSubject) {
|
|
471
|
-
this.columns?.forEach(column => {
|
|
472
|
-
column?.subscribeFormStateChange(formChangeSubject);
|
|
473
|
-
});
|
|
474
|
-
this._actions?.forEach(action => {
|
|
475
|
-
action?.subscribeFormStateChange(formChangeSubject);
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
-
import { FormAction } from '../../classes/forms/action';
|
|
3
|
-
import { ElementComponent } from './layout/element.component'
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'lib-action',
|
|
7
|
-
template: `<ng-content></ng-content>`
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
export class ActionComponent extends ElementComponent implements OnInit {
|
|
11
|
-
inProgress: boolean = false;
|
|
12
|
-
|
|
13
|
-
@Input() action: FormAction | null = null;
|
|
14
|
-
@Input() busy: any;
|
|
15
|
-
@Input() relatedField: any;
|
|
16
|
-
|
|
17
|
-
@Input() style = 'primary';
|
|
18
|
-
@Input() showLabel = true;
|
|
19
|
-
|
|
20
|
-
ngOnInit() {
|
|
21
|
-
if (!this.action) { return; }
|
|
22
|
-
this.formConfig = this.action?._formConfig;
|
|
23
|
-
const mapping = Object.entries(this.formConfig?.actionPropagateAttributes);
|
|
24
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
25
|
-
const actionAttr = mapping[index]?.[0];
|
|
26
|
-
const componentAttr = mapping[index]?.[1]?.toString() ?? '';
|
|
27
|
-
if (componentAttr) {
|
|
28
|
-
const value = this.action?.[actionAttr];
|
|
29
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
30
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
this.action?.attributeChange?.subscribe(event => {
|
|
34
|
-
const { name: componentAttr, value } = event;
|
|
35
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
36
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
37
|
-
});
|
|
38
|
-
this.start();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
activate() {
|
|
42
|
-
if (this.action?.notifyActivation) {
|
|
43
|
-
this.action.notifyActivation();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
visibleOnRestriction() {
|
|
48
|
-
if (!this.action?.restrictedOnField) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
if ((this.action?.restrictedOnOperator === '=='
|
|
52
|
-
&& this.relatedField === this.action?.restrictedOnValue)
|
|
53
|
-
|| (this.action?.restrictedOnOperator === '!='
|
|
54
|
-
&& this.relatedField !== this.action?.restrictedOnValue)) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, Input } from '@angular/core';
|
|
2
|
-
import { FieldDescriptor } from '../../classes/forms/field';
|
|
3
|
-
import { ElementComponent } from './layout/element.component'
|
|
4
|
-
|
|
5
|
-
const VALUE = 'value';
|
|
6
|
-
const FOCUS = 'focus';
|
|
7
|
-
@Component({
|
|
8
|
-
selector: 'lib-field',
|
|
9
|
-
template: `<ng-content></ng-content>`
|
|
10
|
-
})
|
|
11
|
-
export class FieldComponent extends ElementComponent implements OnInit {
|
|
12
|
-
// Atributos obtenidos estáticamente
|
|
13
|
-
code: string = '';
|
|
14
|
-
value: any;
|
|
15
|
-
info: string = '';
|
|
16
|
-
alignment: string = '';
|
|
17
|
-
tooltip: string = '';
|
|
18
|
-
|
|
19
|
-
// Atributos actualizados por subscripción
|
|
20
|
-
maxLength: any;
|
|
21
|
-
minValue: any;
|
|
22
|
-
maxValue: any;
|
|
23
|
-
onValidation: any;
|
|
24
|
-
captureType: any;
|
|
25
|
-
title: any;
|
|
26
|
-
type: any;
|
|
27
|
-
visibleLabel: any;
|
|
28
|
-
required: any;
|
|
29
|
-
options: any;
|
|
30
|
-
|
|
31
|
-
errorType: any;
|
|
32
|
-
errorCode: any;
|
|
33
|
-
errorMessage: any;
|
|
34
|
-
|
|
35
|
-
@Input() field: FieldDescriptor | null = null;
|
|
36
|
-
|
|
37
|
-
ngOnInit() {
|
|
38
|
-
if (!this.field) { return; }
|
|
39
|
-
this.formConfig = this.field?._formConfig;
|
|
40
|
-
const mapping = Object.entries(this.formConfig?.fieldPropagateAttributes);
|
|
41
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
42
|
-
const fieldAttr = mapping[index]?.[0];
|
|
43
|
-
const componentAttr = mapping[index]?.[1]?.toString() ?? '';
|
|
44
|
-
if (componentAttr) {
|
|
45
|
-
const value = this.field?.[fieldAttr];
|
|
46
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
47
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Subscripción a cambios en atributos
|
|
51
|
-
this.field?.attributeChange.subscribe(event => {
|
|
52
|
-
const { name: componentAttr, value } = event;
|
|
53
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
54
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
55
|
-
});
|
|
56
|
-
this.start();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override defaultProcessAttributeChange(attribute: string, value?: any): boolean {
|
|
60
|
-
if (attribute === VALUE) {
|
|
61
|
-
this.updateValue();
|
|
62
|
-
} else if (attribute === FOCUS) {
|
|
63
|
-
this.focus();
|
|
64
|
-
} else {
|
|
65
|
-
return super.defaultProcessAttributeChange(attribute, value);
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
updateValue() { this.value = this.field?.value; }
|
|
71
|
-
onInputChange() { setTimeout(() => this.field?.notifyEditionPartial(), 50); }
|
|
72
|
-
onChangeContent() { setTimeout(() => this.field?.notifyEditionFinish(), 50); }
|
|
73
|
-
onShowInfo(detail = null) { setTimeout(() => this.field?.notifyEditionDetailRequest(detail), 50); }
|
|
74
|
-
|
|
75
|
-
focus() { }
|
|
76
|
-
updateObject(widgetUpdate = true) { this.field?.setValue(this.value, widgetUpdate); }
|
|
77
|
-
|
|
78
|
-
inputChanged() {
|
|
79
|
-
this.field?.setValue(this.value);
|
|
80
|
-
this.onChangeContent();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
inputTyped() {
|
|
84
|
-
this.updateObject(false);
|
|
85
|
-
this.onInputChange();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
numberInputValidation(event) {
|
|
89
|
-
const k = event.charCode;
|
|
90
|
-
return (k > 47 && k < 58);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
-
import { PieceComponent } from './piece.component';
|
|
3
|
-
|
|
4
|
-
@Component({
|
|
5
|
-
selector: 'lib-element',
|
|
6
|
-
template: `<ng-content></ng-content>`
|
|
7
|
-
})
|
|
8
|
-
export class ElementComponent extends PieceComponent {
|
|
9
|
-
@Input() element: any;
|
|
10
|
-
@Input() form: any;
|
|
11
|
-
|
|
12
|
-
start() { }
|
|
13
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'lib-form-error',
|
|
5
|
-
template: `<ng-content></ng-content>`
|
|
6
|
-
})
|
|
7
|
-
export class FormErrorComponent {
|
|
8
|
-
@Input() errorTitle: any;
|
|
9
|
-
@Input() errorMessage: any;
|
|
10
|
-
@Input() errorType: any;
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'lib-form-header',
|
|
5
|
-
template: `<ng-content></ng-content>`
|
|
6
|
-
})
|
|
7
|
-
export class FormHeaderComponent {
|
|
8
|
-
@Input() form: any;
|
|
9
|
-
@Input() canGoBack: boolean = false;
|
|
10
|
-
@Input() showTitle: any;
|
|
11
|
-
@Input() headerActions: any;
|
|
12
|
-
@Output() goBackEvent: EventEmitter<void> = new EventEmitter<void>();
|
|
13
|
-
|
|
14
|
-
goBackForm() {
|
|
15
|
-
this.goBackEvent.emit();
|
|
16
|
-
}
|
|
17
|
-
}
|