tuain-ng-forms-lib 13.0.15 → 14.0.1
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/.browserslistrc +16 -0
- package/.yarn/cache/nanoid-npm-4.0.0-924f5c6312-7d5946df5c.zip +0 -0
- package/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.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 +44 -0
- package/ng-package.json +11 -0
- package/package.json +6 -26
- package/src/lib/classes/forms/action.ts +55 -0
- package/src/lib/classes/forms/element.ts +98 -0
- package/src/lib/classes/forms/field.ts +408 -0
- package/src/lib/classes/forms/form.constants.ts +28 -0
- package/src/lib/classes/forms/form.ts +495 -0
- package/src/lib/classes/forms/section.ts +154 -0
- package/src/lib/classes/forms/subsection.ts +91 -0
- package/src/lib/classes/forms/table/action.ts +41 -0
- package/src/lib/classes/forms/table/column.ts +91 -0
- package/src/lib/classes/forms/table/row-data.ts +118 -0
- package/src/lib/classes/forms/table/table.ts +438 -0
- package/src/lib/components/elements/action.component.ts +53 -0
- package/src/lib/components/elements/field.component.ts +118 -0
- package/src/lib/components/elements/layout/element.component.ts +28 -0
- package/src/lib/components/elements/layout/form-error.component.ts +11 -0
- package/src/lib/components/elements/layout/form-header.component.ts +17 -0
- package/src/lib/components/elements/layout/section.component.ts +16 -0
- package/src/lib/components/elements/layout/sub-section.component.ts +17 -0
- package/src/lib/components/elements/tables/table-record-action.component.ts +37 -0
- package/src/lib/components/elements/tables/table-record-field.component.ts +19 -0
- package/src/lib/components/elements/tables/table.component.ts +102 -0
- package/src/lib/components/forms/basic-form.ts +1496 -0
- package/src/lib/services/event-manager.service.ts +21 -0
- package/src/lib/services/file-manager.service.ts +6 -0
- package/src/lib/services/form-manager.service.ts +89 -0
- package/src/lib/services/icon-dictionary.service.ts +159 -0
- package/src/lib/tuain-ng-forms-lib.module.ts +40 -0
- package/{public-api.d.ts → src/public-api.ts} +5 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2020/lib/classes/forms/action.mjs +0 -35
- package/esm2020/lib/classes/forms/element.mjs +0 -76
- package/esm2020/lib/classes/forms/field.mjs +0 -321
- package/esm2020/lib/classes/forms/form.constants.mjs +0 -26
- package/esm2020/lib/classes/forms/form.mjs +0 -422
- package/esm2020/lib/classes/forms/section.mjs +0 -132
- package/esm2020/lib/classes/forms/subsection.mjs +0 -70
- package/esm2020/lib/classes/forms/table/action.mjs +0 -22
- package/esm2020/lib/classes/forms/table/column.mjs +0 -61
- package/esm2020/lib/classes/forms/table/row-data.mjs +0 -111
- package/esm2020/lib/classes/forms/table/table.mjs +0 -372
- package/esm2020/lib/components/elements/action.component.mjs +0 -58
- package/esm2020/lib/components/elements/field.component.mjs +0 -90
- package/esm2020/lib/components/elements/layout/element.component.mjs +0 -31
- package/esm2020/lib/components/elements/layout/form-error.component.mjs +0 -20
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +0 -30
- package/esm2020/lib/components/elements/layout/section.component.mjs +0 -22
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +0 -24
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +0 -40
- package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +0 -25
- package/esm2020/lib/components/elements/tables/table.component.mjs +0 -95
- package/esm2020/lib/components/forms/basic-form.mjs +0 -1425
- package/esm2020/lib/services/event-manager.service.mjs +0 -18
- package/esm2020/lib/services/file-manager.service.mjs +0 -6
- package/esm2020/lib/services/form-manager.service.mjs +0 -80
- package/esm2020/lib/tuain-ng-forms-lib.module.mjs +0 -73
- package/esm2020/public-api.mjs +0 -19
- package/esm2020/tuain-ng-forms-lib.mjs +0 -5
- package/fesm2015/tuain-ng-forms-lib.mjs +0 -3805
- package/fesm2015/tuain-ng-forms-lib.mjs.map +0 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +0 -3636
- package/fesm2020/tuain-ng-forms-lib.mjs.map +0 -1
- package/lib/classes/forms/action.d.ts +0 -22
- package/lib/classes/forms/element.d.ts +0 -41
- package/lib/classes/forms/field.d.ts +0 -109
- package/lib/classes/forms/form.constants.d.ts +0 -25
- package/lib/classes/forms/form.d.ts +0 -134
- package/lib/classes/forms/section.d.ts +0 -39
- package/lib/classes/forms/subsection.d.ts +0 -26
- package/lib/classes/forms/table/action.d.ts +0 -20
- package/lib/classes/forms/table/column.d.ts +0 -33
- package/lib/classes/forms/table/row-data.d.ts +0 -14
- package/lib/classes/forms/table/table.d.ts +0 -100
- package/lib/components/elements/action.component.d.ts +0 -21
- package/lib/components/elements/field.component.d.ts +0 -43
- package/lib/components/elements/layout/element.component.d.ts +0 -14
- package/lib/components/elements/layout/form-error.component.d.ts +0 -8
- package/lib/components/elements/layout/form-header.component.d.ts +0 -12
- package/lib/components/elements/layout/section.component.d.ts +0 -10
- package/lib/components/elements/layout/sub-section.component.d.ts +0 -11
- package/lib/components/elements/tables/table-record-action.component.d.ts +0 -15
- package/lib/components/elements/tables/table-record-field.component.d.ts +0 -11
- package/lib/components/elements/tables/table.component.d.ts +0 -47
- package/lib/components/forms/basic-form.d.ts +0 -307
- package/lib/services/event-manager.service.d.ts +0 -9
- package/lib/services/file-manager.service.d.ts +0 -5
- package/lib/services/form-manager.service.d.ts +0 -28
- package/lib/tuain-ng-forms-lib.module.d.ts +0 -20
- package/tuain-ng-forms-lib.d.ts +0 -5
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component, Input, Output, OnInit, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
import { TableEvent, TableActionEvent } from '../../../classes/forms/table/table';
|
|
3
|
+
|
|
4
|
+
const INLINE_ACTION = 'INLINE';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'lib-table-record-action',
|
|
8
|
+
template: `<ng-content></ng-content>`,
|
|
9
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export class LibTableRecordActionComponent implements OnInit {
|
|
13
|
+
@Input() recordId: any;
|
|
14
|
+
@Input() recordData: any;
|
|
15
|
+
@Input() action: any;
|
|
16
|
+
|
|
17
|
+
@Output() actionSelected: EventEmitter<object> = new EventEmitter<object>();
|
|
18
|
+
|
|
19
|
+
constructor() { }
|
|
20
|
+
|
|
21
|
+
ngOnInit() {
|
|
22
|
+
this.start();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
start() { }
|
|
26
|
+
|
|
27
|
+
onActivate() {
|
|
28
|
+
const tableEvent: TableActionEvent = {
|
|
29
|
+
actionCode: this.action.actionCode,
|
|
30
|
+
recordId: this.recordId,
|
|
31
|
+
recordData: this.recordData,
|
|
32
|
+
};
|
|
33
|
+
this.actionSelected.emit(tableEvent);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class() { }
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'lib-table-record-field',
|
|
5
|
+
template: `<ng-content></ng-content>`,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export class LibTableRecordFieldComponent implements OnInit {
|
|
10
|
+
@Input() fieldCode: any;
|
|
11
|
+
@Input() fieldType: any;
|
|
12
|
+
@Input() fieldValue: any;
|
|
13
|
+
|
|
14
|
+
ngOnInit() {
|
|
15
|
+
this.start();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
start() { }
|
|
19
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
import { TableRecordData } from '../../../classes/forms/table/row-data';
|
|
3
|
+
import { TableActionEvent } from '../../../classes/forms/table/table';
|
|
4
|
+
import { RecordTable, TableEvent } from '../../../classes/forms/table/table';
|
|
5
|
+
|
|
6
|
+
const changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'lib-table',
|
|
10
|
+
template: `<ng-content></ng-content>`,
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export class LibTableComponent implements OnInit {
|
|
15
|
+
formConfig: any;
|
|
16
|
+
globalFilterString: string = '';
|
|
17
|
+
|
|
18
|
+
// Atributos sincronizados del objeto
|
|
19
|
+
code: any;
|
|
20
|
+
columns: any;
|
|
21
|
+
currentPage: number = 1;
|
|
22
|
+
globalSearch: boolean = false;
|
|
23
|
+
visibleRecords: any[];
|
|
24
|
+
selectedRecords: any[] = [];
|
|
25
|
+
recordsPerPage: any;
|
|
26
|
+
totalRecordsNumber: number = 0;
|
|
27
|
+
allSelected: boolean = false;
|
|
28
|
+
layout: string;
|
|
29
|
+
|
|
30
|
+
tableFieldStyles: any;
|
|
31
|
+
loaded = false;
|
|
32
|
+
selectable = false;
|
|
33
|
+
hasActions = false;
|
|
34
|
+
inlineActions: any;
|
|
35
|
+
globalActions: any;
|
|
36
|
+
selectionActions: any;
|
|
37
|
+
|
|
38
|
+
@Input() table: RecordTable;
|
|
39
|
+
@Input() tableRecords: TableRecordData[];
|
|
40
|
+
@Input() disabled: boolean = false;
|
|
41
|
+
@Input() state: string;
|
|
42
|
+
@Input() waiting: boolean;
|
|
43
|
+
|
|
44
|
+
ngOnInit() {
|
|
45
|
+
if (this.table) {
|
|
46
|
+
this.formConfig = this.table?._formConfig;
|
|
47
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
48
|
+
this.selectable = this.table.selectable;
|
|
49
|
+
this.hasActions = this.table.hasActions();
|
|
50
|
+
this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
|
|
51
|
+
this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
|
|
52
|
+
this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
|
|
53
|
+
// Inicialización de campos mapeados del objeto
|
|
54
|
+
const mapping = Object.entries(this.formConfig.componentTableAttrMap);
|
|
55
|
+
for (let index = 0; index < mapping.length; index++) {
|
|
56
|
+
const [tableAttrRaw, compAttrRaw] = mapping[index];
|
|
57
|
+
const tableAttr = tableAttrRaw.toString();
|
|
58
|
+
const compAttr = compAttrRaw.toString();
|
|
59
|
+
this.syncAttribute(compAttr, this.table[tableAttr]);
|
|
60
|
+
}
|
|
61
|
+
// Subscripción a cambios en atributos
|
|
62
|
+
this.table.attributeChange.subscribe(event => {
|
|
63
|
+
const { name: tableAttr, value } = event;
|
|
64
|
+
const compAttr = this.formConfig.componentTableAttrMap[tableAttr];
|
|
65
|
+
this.syncAttribute(compAttr, value);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
this.start();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
start() { }
|
|
72
|
+
updateTableData() { }
|
|
73
|
+
tableGlobalAction(actionCode: string) { this.table.notifyGlobalAction(actionCode); }
|
|
74
|
+
tableSelectionAction(actionCode: string) { this.table.notifySelectionAction(actionCode); }
|
|
75
|
+
tableActionSelected(actionEvent: TableActionEvent) { this.table.notifyInlineAction(actionEvent); }
|
|
76
|
+
tableSelectionToggle(recordId: any) { this.table.notifyRecordSelection(recordId); }
|
|
77
|
+
toggleSelectAll() { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); }
|
|
78
|
+
globalFilterCompleted() { this.changePage(1); }
|
|
79
|
+
changePage(requestedPage: number) { this.table.changePage(requestedPage); }
|
|
80
|
+
tableColumnSort(columnName: string, direction = null) { this.table.sort(columnName, direction ?? 'ascend'); }
|
|
81
|
+
globalFilterChanged() { this.table.setGlobalFilterString(this.globalFilterString?.trim() ?? ''); }
|
|
82
|
+
|
|
83
|
+
syncAttribute(name: string, value: any) {
|
|
84
|
+
try {
|
|
85
|
+
if (name === 'visibleRecords') {
|
|
86
|
+
this.updateTableData();
|
|
87
|
+
}
|
|
88
|
+
this[name] = value;
|
|
89
|
+
return true;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
filterHasChanged(column, values) {
|
|
96
|
+
if (!values || values.length === 0) {
|
|
97
|
+
this.table.removeColumnFilter(column.fieldCode);
|
|
98
|
+
} else {
|
|
99
|
+
this.table.addColumnFilter(column.fieldCode, values);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|