tuain-ng-forms-lib 14.3.0 → 14.3.20

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.
@@ -312,13 +312,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
312
312
  }] } });
313
313
 
314
314
  class LibTableRecordFieldComponent {
315
+ constructor() {
316
+ this.column = null;
317
+ }
315
318
  ngOnInit() {
316
319
  this.start();
317
320
  }
318
321
  start() { }
319
322
  }
320
323
  LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
321
- LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
324
+ LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue", column: "column" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
322
325
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
323
326
  type: Component,
324
327
  args: [{
@@ -332,6 +335,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
332
335
  type: Input
333
336
  }], fieldValue: [{
334
337
  type: Input
338
+ }], column: [{
339
+ type: Input
335
340
  }] } });
336
341
 
337
342
  const changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
@@ -479,6 +484,11 @@ class FormElement {
479
484
  this.customAttributes[name] = value;
480
485
  }
481
486
  }
487
+ setCustomAttributes(attributes) {
488
+ Object.entries(attributes).forEach(([name, value]) => {
489
+ this.setCustomAttribute(name, value);
490
+ });
491
+ }
482
492
  matchAttribute(name, value) { var _a; return ((_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) === value; }
483
493
  isField() { return this.elementType === elementTypes.field; }
484
494
  isAction() { return this.elementType === elementTypes.action; }
@@ -806,7 +816,7 @@ class FieldDescriptor extends FormElement {
806
816
  get required() { return this._fieldRequired; }
807
817
  set required(required) { this.setAttr(attrs._fieldRequired, required !== null && required !== void 0 ? required : false); }
808
818
  get title() { return this._fieldTitle; }
809
- set title(title) { this.setAttr(attrs._fieldTitle, title.toString()); }
819
+ set title(title) { var _a; this.setAttr(attrs._fieldTitle, (_a = title === null || title === void 0 ? void 0 : title.toString()) !== null && _a !== void 0 ? _a : ''); }
810
820
  get tooltip() { return this._tooltipText; }
811
821
  set tooltip(tooltip) { this.setAttr(attrs._tooltipText, tooltip); }
812
822
  get type() { return this._fieldType; }
@@ -1027,8 +1037,19 @@ class FieldDescriptor extends FormElement {
1027
1037
  class RecordTableColumn {
1028
1038
  constructor(recTableColReceived, formConfig) {
1029
1039
  var _a, _b, _c;
1040
+ this.fieldCode = '';
1041
+ this.fieldTitle = '';
1042
+ this.fieldType = '';
1043
+ this.fieldAlignment = '';
1044
+ this.fieldFormat = '';
1045
+ this.visible = true;
1046
+ this.sortable = true;
1047
+ this.sortDirections = [];
1048
+ this.customAttributes = {};
1030
1049
  // Filtros
1031
1050
  this.filterVisible = false;
1051
+ this.filterDef = null;
1052
+ this.filterSetup = null;
1032
1053
  this._formConfig = formConfig;
1033
1054
  this.filterDef = null;
1034
1055
  if (recTableColReceived) {
@@ -1039,11 +1060,22 @@ class RecordTableColumn {
1039
1060
  this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
1040
1061
  this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
1041
1062
  this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
1042
- this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [null];
1063
+ this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [];
1043
1064
  this.fieldFormat = recTableColReceived.format || '';
1044
1065
  this.customAttributes = (_c = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.customAttributes) !== null && _c !== void 0 ? _c : {};
1045
1066
  }
1046
1067
  }
1068
+ getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
1069
+ setCustomAttribute(name, value) {
1070
+ if (name) {
1071
+ this.customAttributes[name] = value;
1072
+ }
1073
+ }
1074
+ setCustomAttributes(attributes) {
1075
+ Object.entries(attributes).forEach(([name, value]) => {
1076
+ this.setCustomAttribute(name, value);
1077
+ });
1078
+ }
1047
1079
  hideFilter() {
1048
1080
  this.filterVisible = false;
1049
1081
  }
@@ -1058,9 +1090,10 @@ class RecordTableColumn {
1058
1090
  return this.filterDef;
1059
1091
  }
1060
1092
  addFilter(columnValues, operator) {
1093
+ var _a;
1061
1094
  this.filterSetup = {
1062
1095
  fieldCode: this.fieldCode,
1063
- operator: operator !== null && operator !== void 0 ? operator : this.filterDef.operators[0],
1096
+ operator: operator !== null && operator !== void 0 ? operator : (_a = this.filterDef) === null || _a === void 0 ? void 0 : _a.operators[0],
1064
1097
  values: columnValues,
1065
1098
  };
1066
1099
  }
@@ -1106,6 +1139,17 @@ class TableAction {
1106
1139
  this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
1107
1140
  this.customAttributes = (_c = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
1108
1141
  }
1142
+ getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
1143
+ setCustomAttribute(name, value) {
1144
+ if (name) {
1145
+ this.customAttributes[name] = value;
1146
+ }
1147
+ }
1148
+ setCustomAttributes(attributes) {
1149
+ Object.entries(attributes).forEach(([name, value]) => {
1150
+ this.setCustomAttribute(name, value);
1151
+ });
1152
+ }
1109
1153
  supportMode(state) { return this.viewOnState(state); }
1110
1154
  viewOnState(state) { return this.visibleStates.includes(state); }
1111
1155
  enabledOnState(state) { return this.enabledStates.includes(state); }
@@ -1350,11 +1394,13 @@ class RecordTable extends FormElement {
1350
1394
  this._inlineActionTrigger.next(tableEvent);
1351
1395
  }
1352
1396
  notifyRecordSelection(recordId) {
1397
+ var _a;
1353
1398
  const record = this.getTableRecord(recordId);
1354
1399
  if (!record) {
1355
1400
  return;
1356
1401
  }
1357
1402
  record.toggleSelect();
1403
+ this.requestedPage = (_a = this.currentPage) !== null && _a !== void 0 ? _a : 1;
1358
1404
  const tableEvent = {
1359
1405
  tableCode: this.tableCode,
1360
1406
  actionCode: null,
@@ -1406,7 +1452,11 @@ class RecordTable extends FormElement {
1406
1452
  }
1407
1453
  setTableRecords(tableRecords, append) {
1408
1454
  if (!append) {
1409
- this.clean();
1455
+ this.tableRecords = [];
1456
+ this.setAttr('allSelected', false);
1457
+ this.tableRecords.forEach(record => record.unselect());
1458
+ this.setAttr('selectedRecords', []);
1459
+ this.tableRecordObj = {};
1410
1460
  }
1411
1461
  const newRecordsObj = Object.assign({}, this.tableRecordObj);
1412
1462
  const newRecords = [...this.tableRecords];
@@ -1439,9 +1489,11 @@ class RecordTable extends FormElement {
1439
1489
  if (this.clientPaging) {
1440
1490
  let filteredRecords = this.getFilteredRecords();
1441
1491
  this.setAttr('totalRecordsNumber', filteredRecords.length);
1442
- visibleRecords = filteredRecords.slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
1492
+ const sliceNumber1 = (this.currentPage - 1) * this.recordsPerPage;
1493
+ const sliceNumber2 = (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage;
1494
+ visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
1443
1495
  const recordsLastPage = this.totalRecordsNumber % this.recordsPerPage;
1444
- const totalPages = this.totalRecordsNumber / this.recordsPerPage + (recordsLastPage ? 1 : 0);
1496
+ const totalPages = Math.trunc(this.totalRecordsNumber / this.recordsPerPage + (recordsLastPage ? 1 : 0));
1445
1497
  if (this.currentPage > totalPages) {
1446
1498
  this.currentPage = totalPages || 1;
1447
1499
  }
@@ -1724,6 +1776,11 @@ class RecordFormSection {
1724
1776
  }
1725
1777
  getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
1726
1778
  setCustomAttribute(name, value) { return name && (this.customAttributes[name] = value); }
1779
+ setCustomAttributes(attributes) {
1780
+ Object.entries(attributes).forEach(([name, value]) => {
1781
+ this.setCustomAttribute(name, value);
1782
+ });
1783
+ }
1727
1784
  matchAttribute(name, value) { var _a; return ((_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) === value; }
1728
1785
  get code() { return this.sectionCode; }
1729
1786
  get activation() { return this._activation; }
@@ -2856,14 +2913,14 @@ class BasicFormComponent {
2856
2913
  });
2857
2914
  }
2858
2915
  }
2859
- formInit(params) {
2916
+ formInit(params, forceReload = false) {
2860
2917
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2861
2918
  return __awaiter(this, void 0, void 0, function* () {
2862
2919
  let initialState = this.preocessInputParams(params);
2863
2920
  if (!this.name) {
2864
2921
  return;
2865
2922
  }
2866
- if (!this._definitionObtained) {
2923
+ if (forceReload || !this._definitionObtained) {
2867
2924
  this.busy = true;
2868
2925
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2869
2926
  this.busy = false;