tuain-ng-forms-lib 12.0.53 → 12.0.58

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.
@@ -612,26 +612,162 @@
612
612
  formManager: [{ type: core.Input }]
613
613
  };
614
614
 
615
- var FieldSearch = /** @class */ (function () {
616
- function FieldSearch(filterDefinition) {
617
- this.fieldCode = filterDefinition.fieldCode;
618
- this.fieldAlias = filterDefinition.fieldAlias || filterDefinition.fieldCode;
619
- this.fieldTitle = filterDefinition.fieldTitle;
620
- this.fieldTypeCode = filterDefinition.fieldTypeCode;
621
- this.operators = filterDefinition.operators;
622
- this.alignment = filterDefinition.alignment;
623
- this.format = filterDefinition.format;
615
+ var INLINE_ACTION$1 = 'INLINE';
616
+ var LibTableRecordActionComponent = /** @class */ (function () {
617
+ function LibTableRecordActionComponent() {
618
+ this.actionSelected = new core.EventEmitter();
619
+ }
620
+ LibTableRecordActionComponent.prototype.ngOnInit = function () {
621
+ this.start();
622
+ };
623
+ LibTableRecordActionComponent.prototype.start = function () { };
624
+ LibTableRecordActionComponent.prototype.onActivate = function () {
625
+ var tableEvent = {
626
+ actionCode: this.action.actionCode,
627
+ recordId: this.recordId,
628
+ recordData: this.recordData,
629
+ };
630
+ this.actionSelected.emit(tableEvent);
631
+ };
632
+ LibTableRecordActionComponent.prototype.class = function () { };
633
+ return LibTableRecordActionComponent;
634
+ }());
635
+ LibTableRecordActionComponent.decorators = [
636
+ { type: core.Component, args: [{
637
+ selector: 'lib-table-record-action',
638
+ template: "<ng-content></ng-content>",
639
+ changeDetection: core.ChangeDetectionStrategy.OnPush
640
+ },] }
641
+ ];
642
+ LibTableRecordActionComponent.ctorParameters = function () { return []; };
643
+ LibTableRecordActionComponent.propDecorators = {
644
+ recordId: [{ type: core.Input }],
645
+ recordData: [{ type: core.Input }],
646
+ action: [{ type: core.Input }],
647
+ actionSelected: [{ type: core.Output }]
648
+ };
649
+
650
+ var LibTableRecordFieldComponent = /** @class */ (function () {
651
+ function LibTableRecordFieldComponent() {
624
652
  }
625
- return FieldSearch;
653
+ LibTableRecordFieldComponent.prototype.ngOnInit = function () {
654
+ this.start();
655
+ };
656
+ LibTableRecordFieldComponent.prototype.start = function () { };
657
+ return LibTableRecordFieldComponent;
626
658
  }());
627
- var Filter = /** @class */ (function () {
628
- function Filter() {
629
- this.filterModeSimple = true;
630
- this.advancedFilter = [];
631
- this.simpleFilterWords = [];
659
+ LibTableRecordFieldComponent.decorators = [
660
+ { type: core.Component, args: [{
661
+ selector: 'lib-table-record-field',
662
+ template: "<ng-content></ng-content>",
663
+ changeDetection: core.ChangeDetectionStrategy.OnPush
664
+ },] }
665
+ ];
666
+ LibTableRecordFieldComponent.propDecorators = {
667
+ fieldCode: [{ type: core.Input }],
668
+ fieldType: [{ type: core.Input }],
669
+ fieldValue: [{ type: core.Input }]
670
+ };
671
+
672
+ var changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage', 'sorting'];
673
+ var LibTableComponent = /** @class */ (function () {
674
+ function LibTableComponent() {
675
+ this.currentPageRecords = [];
676
+ this.globalFilterString = '';
677
+ this.globalSearch = false;
678
+ this.selectedRecords = [];
679
+ this.selectionBackend = false;
680
+ this.allSelected = false;
681
+ this.currentPage = 1;
682
+ this.loaded = false;
683
+ this.selectable = false;
684
+ this.hasActions = false;
632
685
  }
633
- return Filter;
686
+ LibTableComponent.prototype.ngOnInit = function () {
687
+ var _this = this;
688
+ var _a;
689
+ if (this.table) {
690
+ this.formConfig = (_a = this.table) === null || _a === void 0 ? void 0 : _a._formConfig;
691
+ this.tableFieldStyles = this.formConfig.tableFieldStyles;
692
+ this.selectable = this.table.selectable;
693
+ this.hasActions = this.table.hasActions();
694
+ this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
695
+ this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
696
+ this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
697
+ // Inicialización de campos mapeados del objeto
698
+ var mapping = Object.entries(this.formConfig.componentTableAttrMap);
699
+ for (var index = 0; index < mapping.length; index++) {
700
+ var _c = __read(mapping[index], 2), tableAttrRaw = _c[0], compAttrRaw = _c[1];
701
+ var tableAttr = tableAttrRaw.toString();
702
+ var compAttr = compAttrRaw.toString();
703
+ this.syncAttribute(compAttr, this.table[tableAttr]);
704
+ }
705
+ // Subscripción a cambios en atributos
706
+ this.table.attributeChange.subscribe(function (event) {
707
+ var tableAttr = event.name, value = event.value;
708
+ var compAttr = _this.formConfig.componentTableAttrMap[tableAttr];
709
+ _this.syncAttribute(compAttr, value);
710
+ });
711
+ }
712
+ this.start();
713
+ };
714
+ LibTableComponent.prototype.start = function () { };
715
+ LibTableComponent.prototype.tableGlobalAction = function (actionCode) { this.table.notifyGlobalAction(actionCode); };
716
+ LibTableComponent.prototype.tableSelectionAction = function (actionCode) { this.table.notifySelectionAction(actionCode); };
717
+ LibTableComponent.prototype.tableActionSelected = function (actionEvent) { this.table.notifyInlineAction(actionEvent); };
718
+ LibTableComponent.prototype.changePage = function (requestedPage) { !this.clientPaging && this.table.notifyGetDataAction(requestedPage); };
719
+ LibTableComponent.prototype.tableSelectionToggle = function (recordId) { this.table.notifyRecordSelection(recordId); };
720
+ LibTableComponent.prototype.toggleSelectAll = function () { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); };
721
+ LibTableComponent.prototype.globalFilterCompleted = function () { this.changePage(1); };
722
+ LibTableComponent.prototype.syncAttribute = function (name, value) {
723
+ try {
724
+ // this.hasOwnProperty(name)
725
+ this[name] = value;
726
+ }
727
+ catch (e) {
728
+ console.log('Error asignando valor a un atributo del objeto');
729
+ }
730
+ if (changeViewAttributes.includes(name)) {
731
+ this.updateTableView();
732
+ }
733
+ };
734
+ LibTableComponent.prototype.globalFilterChanged = function () {
735
+ var _a, _b;
736
+ this.table.setGlobalFilterString((_b = (_a = this.globalFilterString) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
737
+ if (this.clientPaging) {
738
+ this.table.setAttr('currentPage', 1);
739
+ this.table.updateVisibleRecords();
740
+ }
741
+ };
742
+ LibTableComponent.prototype.tableColumnSort = function (columnName) {
743
+ this.table.setRequiredOrder(columnName);
744
+ return this.clientPaging ? this.table.localSortData() : this.table.notifyGetDataAction();
745
+ };
746
+ LibTableComponent.prototype.updateTableView = function () {
747
+ var currentPageRecords = this.visibleRecords;
748
+ if (this.clientPaging) {
749
+ currentPageRecords = currentPageRecords.map(function (record, i) { return (Object.assign({ id: i + 1 }, record)); })
750
+ .slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
751
+ this.totalRecordsNumber = this.visibleRecords.length;
752
+ }
753
+ this.currentPageRecords = currentPageRecords;
754
+ };
755
+ return LibTableComponent;
634
756
  }());
757
+ LibTableComponent.decorators = [
758
+ { type: core.Component, args: [{
759
+ selector: 'lib-table',
760
+ template: "<ng-content></ng-content>",
761
+ changeDetection: core.ChangeDetectionStrategy.OnPush
762
+ },] }
763
+ ];
764
+ LibTableComponent.propDecorators = {
765
+ table: [{ type: core.Input }],
766
+ tableRecords: [{ type: core.Input }],
767
+ disabled: [{ type: core.Input }],
768
+ state: [{ type: core.Input }],
769
+ waiting: [{ type: core.Input }]
770
+ };
635
771
 
636
772
  var NO_ERROR = '00';
637
773
  var HEADER$1 = 'HEADER';
@@ -656,6 +792,7 @@
656
792
  CONTENT: 'Contiene',
657
793
  NOT_CONTENT: 'No Contiene',
658
794
  BETWEEN: 'Entre',
795
+ IN: 'En'
659
796
  };
660
797
 
661
798
  var FormElement = /** @class */ (function () {
@@ -750,1326 +887,1029 @@
750
887
  return FormElement;
751
888
  }());
752
889
 
753
- var RecordTableColumn = /** @class */ (function () {
754
- function RecordTableColumn(recTableColReceived, formConfig) {
755
- var _a, _b, _c;
756
- this._formConfig = formConfig;
757
- if (recTableColReceived) {
758
- this.fieldCode = recTableColReceived.fieldCode;
759
- this.fieldTitle = recTableColReceived.fieldTitle;
760
- this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
761
- var defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
762
- this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
763
- this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
764
- this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
765
- this.fieldFormat = recTableColReceived.format || '';
766
- this.customAttributes = (_c = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.customAttributes) !== null && _c !== void 0 ? _c : {};
767
- }
768
- }
769
- return RecordTableColumn;
770
- }());
771
-
772
- var TableAction = /** @class */ (function () {
773
- function TableAction(actionDefinition) {
774
- var _a, _b;
775
- this.actionCode = actionDefinition.actionCode;
776
- this.actionTitle = actionDefinition.actionTitle;
777
- this.iconName = actionDefinition.iconName || this.actionCode;
778
- this.actionType = actionDefinition.actionType || 'STANDARD';
779
- this.actionClass = actionDefinition.actionClass || 'INLINE';
780
- this.newState = actionDefinition.newState;
781
- this.stateField = actionDefinition.stateField || '';
782
- this.visibleStates = actionDefinition.visibleStates || [];
783
- this.enabledStates = actionDefinition.enabledStates || [];
784
- this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
785
- this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
786
- this.restrictedOnValue = actionDefinition.valueRestricted || '';
787
- this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
788
- this.customAttributes = (_b = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _b !== void 0 ? _b : {};
789
- }
790
- TableAction.prototype.supportMode = function (state) { return this.viewOnState(state); };
791
- TableAction.prototype.viewOnState = function (state) { return this.visibleStates.includes(state); };
792
- TableAction.prototype.enabledOnState = function (state) { return this.enabledStates.includes(state); };
793
- return TableAction;
794
- }());
795
-
796
- var TableRecordData = /** @class */ (function () {
797
- function TableRecordData(recordReceived, recordDefinition, selectionFieldName) {
890
+ var HEADER = 'HEADER';
891
+ var FormAction = /** @class */ (function (_super) {
892
+ __extends(FormAction, _super);
893
+ function FormAction(actionDefinition, formConfig) {
798
894
  var _this = this;
799
- if (selectionFieldName === void 0) { selectionFieldName = null; }
800
- this.recordData = {};
801
- var tableRecordId = recordReceived.tableRecordId, recordData = recordReceived.recordData;
802
- this.recordId = tableRecordId;
803
- this.selected = false;
804
- this.recordData = {};
805
- if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
806
- return;
807
- }
808
- var fieldNames = recordDefinition.map(function (column) { return column.fieldCode; });
809
- if (Array.isArray(recordData)) {
810
- var rawRecordData = recordData.filter(function (fieldData) { return fieldData.fieldCode && fieldNames.includes(fieldData.fieldCode); });
811
- rawRecordData.forEach(function (fieldData) {
812
- var fieldCode = fieldData.fieldCode, fieldValue = fieldData.fieldValue;
813
- var fieldDef = recordDefinition.find(function (column) { return column.fieldCode === fieldCode; });
814
- _this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
815
- if (fieldCode === selectionFieldName) {
816
- _this.selected = fieldValue;
817
- }
818
- });
819
- }
820
- else {
821
- var fields = Object.keys(recordData);
822
- fields.forEach(function (fieldCode) {
823
- var fieldValue = recordData[fieldCode];
824
- var fieldDef = recordDefinition.find(function (column) { return column.fieldCode === fieldCode; });
825
- _this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
826
- });
827
- }
895
+ var _a;
896
+ _this = _super.call(this, actionDefinition, formConfig) || this;
897
+ _this._actionActivated = new rxjs.Subject();
898
+ _this.inProgress = false;
899
+ _this.elementType = elementTypes.action;
900
+ _this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
901
+ _this.actionName = actionDefinition.actionTitle;
902
+ _this.iconName = actionDefinition.iconName || _this.actionCode;
903
+ _this.setCustomAttribute('location', actionDefinition.position || HEADER);
904
+ _this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
905
+ _this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
906
+ _this.restrictedOnField = actionDefinition.fieldRestrictedCode ? actionDefinition.fieldRestrictedCode.toString() : '';
907
+ _this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
908
+ _this.restrictedOnValue = actionDefinition.valueRestricted || '';
909
+ _this.customValidation = function () { return true; };
910
+ return _this;
828
911
  }
829
- TableRecordData.prototype.toggleSelect = function () { this.selected = !this.selected; };
830
- TableRecordData.prototype.select = function () { this.selected = true; };
831
- TableRecordData.prototype.unselect = function () { this.selected = false; };
832
- Object.defineProperty(TableRecordData.prototype, "recordIdKey", {
833
- get: function () {
834
- return (typeof this.recordId === 'object')
835
- ? JSON.stringify(this.recordId) : this.recordId;
836
- },
912
+ Object.defineProperty(FormAction.prototype, "actionActivated", {
913
+ get: function () { return this._actionActivated; },
837
914
  enumerable: false,
838
915
  configurable: true
839
916
  });
840
- TableRecordData.prototype.getFieldValue = function (fieldCode) {
841
- return (fieldCode && this.recordData[fieldCode])
842
- ? this.recordData[fieldCode] : null;
843
- };
844
- TableRecordData.prototype.hasPattern = function (words) {
845
- var e_1, _b;
846
- if (!words || words.length === 0) {
847
- return true;
848
- }
849
- for (var fieldCode in this.recordData) {
850
- if (this.recordData.hasOwnProperty(fieldCode)) {
851
- try {
852
- for (var words_1 = (e_1 = void 0, __values(words)), words_1_1 = words_1.next(); !words_1_1.done; words_1_1 = words_1.next()) {
853
- var word = words_1_1.value;
854
- var term = word.toUpperCase();
855
- var fieldValue = this.recordData[fieldCode];
856
- if (fieldValue.toString().toUpperCase().includes(term)) {
857
- return true;
858
- }
859
- }
860
- }
861
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
862
- finally {
863
- try {
864
- if (words_1_1 && !words_1_1.done && (_b = words_1.return)) _b.call(words_1);
865
- }
866
- finally { if (e_1) throw e_1.error; }
867
- }
917
+ FormAction.prototype.start = function () { this.inProgress = true; };
918
+ FormAction.prototype.stop = function () { this.inProgress = false; };
919
+ FormAction.prototype.notifyActivation = function () { this._actionActivated.next(this.actionCode); };
920
+ FormAction.prototype.updateFromServer = function (receivedAction) {
921
+ for (var propertyName in receivedAction) {
922
+ if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
923
+ this[propertyName] = receivedAction[propertyName];
868
924
  }
869
925
  }
870
- return false;
871
926
  };
872
- TableRecordData.prototype.hasCondition = function (advancedFilter) {
873
- var e_2, _b;
874
- var _a;
875
- if (!advancedFilter || advancedFilter.length === 0) {
876
- return true;
877
- }
878
- try {
879
- for (var advancedFilter_1 = __values(advancedFilter), advancedFilter_1_1 = advancedFilter_1.next(); !advancedFilter_1_1.done; advancedFilter_1_1 = advancedFilter_1.next()) {
880
- var condition = advancedFilter_1_1.value;
881
- var fieldCode = condition.fieldSearch.fieldCode;
882
- if (this.recordData.hasOwnProperty(fieldCode)) {
883
- var fieldValue = this.recordData[fieldCode].toString().toUpperCase();
884
- var conditionField1Value = (_a = condition === null || condition === void 0 ? void 0 : condition.fieldValue1) === null || _a === void 0 ? void 0 : _a.toString().toUpperCase();
885
- var conditionField2Value = condition.fieldValue2.toString().toUpperCase();
886
- if (condition.operator === operators.G && fieldValue <= conditionField1Value) {
887
- return false;
888
- }
889
- if (condition.operator === operators.L && fieldValue >= conditionField1Value) {
890
- return false;
891
- }
892
- if (condition.operator === operators.GE && fieldValue < conditionField1Value) {
893
- return false;
894
- }
895
- if (condition.operator === operators.LE && fieldValue > conditionField1Value) {
896
- return false;
897
- }
898
- if (condition.operator === operators.EQ) {
899
- return fieldValue === conditionField1Value;
900
- }
901
- if (condition.operator === operators.NOT_EQ && fieldValue === conditionField1Value) {
902
- return false;
903
- }
904
- if (condition.operator === operators.CONTENT && !fieldValue.includes(conditionField1Value)) {
905
- return false;
906
- }
907
- if (condition.operator === operators.NOT_CONTENT && fieldValue.includes(conditionField1Value)) {
908
- return false;
909
- }
910
- if (condition.operator === operators.BETWEEN && (fieldValue < conditionField1Value
911
- || fieldValue > conditionField2Value)) {
912
- return false;
913
- }
914
- }
915
- }
916
- }
917
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
918
- finally {
919
- try {
920
- if (advancedFilter_1_1 && !advancedFilter_1_1.done && (_b = advancedFilter_1.return)) _b.call(advancedFilter_1);
921
- }
922
- finally { if (e_2) throw e_2.error; }
923
- }
924
- return true;
925
- };
926
- return TableRecordData;
927
- }());
927
+ FormAction.prototype.setCustomValidation = function (callback) { this.customValidation = function () { return callback(); }; };
928
+ return FormAction;
929
+ }(FormElement));
928
930
 
929
- var TABLE_SORT_ASCENDING = 'asc';
930
- var TABLE_SORT_DESCENDING = 'desc';
931
- var TABLE_FILTER_TYPES = {
932
- simpleFilterChange: 'SIMPLE_CHANGE',
933
- simpleFilterFinish: 'SIMPLE_FINISH',
934
- complexFilterAdd: 'COMPLEX_ADD',
935
- complexFilterRemove: 'COMPLEX_REMOVE',
931
+ var UNDEFINED = 'undefined';
932
+ var DEFAULT_ERROR_TYPE = 'error';
933
+ var DEFAULT_CAPTURE_TYPE = 'INPUT';
934
+ var DEFAULT_ALIGNMENT = 'left';
935
+ var STD_MAX_LENGTH = 50;
936
+ var BIG_MAX_LENGTH = 500;
937
+ var fldAttr = {
938
+ validateOnServer: 'validateOnServer',
939
+ value: '_value',
940
+ minValue: '_minValue',
941
+ maxValue: '_maxValue',
942
+ maxLength: '_maxLength',
943
+ onValidation: '_onValidation',
944
+ focus: 'focus',
945
+ intrinsicErrorMessage: '_intrinsicErrorMessage',
946
+ code: 'fieldCode',
947
+ info: 'fieldInfo',
948
+ defaultValue: 'defaultValue',
949
+ defaultEditable: 'defaultEditable',
950
+ visibleLabel: 'visibleLabel',
951
+ required: 'fieldRequired',
952
+ hasChanged: 'hasChanged',
953
+ outputOnly: 'outputOnly',
954
+ captureType: 'captureType',
955
+ title: 'fieldTitle',
956
+ type: 'fieldType',
957
+ alignment: 'fieldAlignment',
958
+ format: 'fieldFormat',
959
+ externalValue: 'externalValue',
960
+ tooltipText: 'tooltipText',
961
+ errorType: 'errorType',
962
+ errorCode: 'errorCode',
963
+ errorMessage: 'errorMessage',
964
+ options: 'fieldOptions',
936
965
  };
937
- var RecordTable = /** @class */ (function (_super) {
938
- __extends(RecordTable, _super);
939
- function RecordTable(tableReceived, formConfig) {
940
- var e_1, _g, e_2, _h, e_3, _j;
966
+ var FieldDescriptor = /** @class */ (function (_super) {
967
+ __extends(FieldDescriptor, _super);
968
+ function FieldDescriptor(inputFieldReceived, formConfig) {
941
969
  var _this = this;
942
- var _a, _b, _c, _d, _e, _f;
943
- _this = _super.call(this, tableReceived, formConfig) || this;
944
- _this._inlineActionTrigger = new rxjs.Subject();
945
- _this._globalActionTrigger = new rxjs.Subject();
946
- _this._recordSelectionTrigger = new rxjs.Subject();
947
- _this._selectionActionTrigger = new rxjs.Subject();
948
- _this._getDataTrigger = new rxjs.Subject();
970
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
971
+ _this = _super.call(this, inputFieldReceived, formConfig) || this;
972
+ _this._editionFinish = new rxjs.Subject();
973
+ _this._editionPartial = new rxjs.Subject();
974
+ _this._detailRequest = new rxjs.Subject();
949
975
  _this._attributeChange = new rxjs.Subject();
950
- _this._tableColumnObj = {};
951
- _this._actionsObj = {};
952
- _this.tableRecordObj = {};
953
- _this.allSelected = false;
954
- _this.elementType = elementTypes.table;
955
- _this.waiting = false;
956
- _this.currentPage = 1;
957
- _this.totalPages = 1;
958
- _this.requestedPage = 1;
959
- _this.columns = [];
960
- _this._tableColumnObj = {};
961
- _this._actions = [];
962
- _this._actionsObj = {};
963
- _this.tableRecords = [];
964
- _this.setAttr('allSelected', false);
965
- _this.setAttr('filterObject', new Filter());
966
- _this.setAttr('filterConfig', []);
967
- _this.setAttr('tableCode', tableReceived.tableCode);
968
- _this.tableTitle = tableReceived.tableTitle;
969
- _this.setAttr('clientPaging', (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _a !== void 0 ? _a : true);
970
- _this.setAttr('simpleFilter', (_b = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _b !== void 0 ? _b : false);
971
- _this.setAttr('complexFilter', false);
972
- _this._appendPages = (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _c !== void 0 ? _c : false;
973
- _this.selectable = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _d !== void 0 ? _d : false;
974
- _this.setAttr('selectionBackend', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _e !== void 0 ? _e : false);
975
- _this.setAttr('sortable', (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _f !== void 0 ? _f : false);
976
- _this.setAttr('sorting', { columnName: '', direction: '' });
977
- _this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
978
- if (tableReceived.fields) {
979
- var columns = [];
980
- try {
981
- for (var _k = __values(tableReceived.fields), _l = _k.next(); !_l.done; _l = _k.next()) {
982
- var columnReceived = _l.value;
983
- var columnDefinition = new RecordTableColumn(columnReceived, _this._formConfig);
984
- columns.push(columnDefinition);
985
- _this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
986
- }
987
- }
988
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
989
- finally {
990
- try {
991
- if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
992
- }
993
- finally { if (e_1) throw e_1.error; }
994
- }
995
- _this.setAttr('columns', columns);
996
- }
997
- if (tableReceived.actions) {
998
- var tableActions = tableReceived.actions.map(function (objDef) {
999
- var visibleStates = objDef.visibleStates;
1000
- var enabledStates = objDef.enabledStates;
1001
- if (!visibleStates) {
1002
- visibleStates = (objDef.actionModes || '').split(',')
1003
- .map(function (state) { return state.trim(); })
1004
- .filter(function (state) { return state.length > 0; });
1005
- enabledStates = (objDef.actionModes || '').split(',')
1006
- .map(function (state) { return state.trim(); })
1007
- .filter(function (state) { return state.length > 0; });
1008
- }
1009
- return Object.assign(Object.assign({}, objDef), { visibleStates: visibleStates, enabledStates: enabledStates });
1010
- });
1011
- try {
1012
- for (var tableActions_1 = __values(tableActions), tableActions_1_1 = tableActions_1.next(); !tableActions_1_1.done; tableActions_1_1 = tableActions_1.next()) {
1013
- var actionReceived = tableActions_1_1.value;
1014
- var inlineAction = new TableAction(actionReceived);
1015
- _this._actions.push(inlineAction);
1016
- _this._actionsObj[inlineAction.actionCode] = inlineAction;
1017
- }
1018
- }
1019
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1020
- finally {
1021
- try {
1022
- if (tableActions_1_1 && !tableActions_1_1.done && (_h = tableActions_1.return)) _h.call(tableActions_1);
1023
- }
1024
- finally { if (e_2) throw e_2.error; }
1025
- }
1026
- }
1027
- if (tableReceived.filters && tableReceived.filters.length > 0) {
1028
- _this.setAttr('complexFilter', true);
1029
- var filterConfig = _this.filterConfig;
1030
- try {
1031
- for (var _m = __values(tableReceived.filters), _o = _m.next(); !_o.done; _o = _m.next()) {
1032
- var filterReceived = _o.value;
1033
- var filterItem = new FieldSearch(filterReceived);
1034
- filterConfig.push(filterItem);
1035
- }
1036
- }
1037
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1038
- finally {
1039
- try {
1040
- if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
1041
- }
1042
- finally { if (e_3) throw e_3.error; }
1043
- }
1044
- _this.setAttr('filterConfig', filterConfig);
976
+ _this.elementType = elementTypes.field;
977
+ var fld = (inputFieldReceived) ? inputFieldReceived : {};
978
+ _this.setAttr(fldAttr.code, fld.fieldCode);
979
+ _this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : _this.fieldCode);
980
+ _this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
981
+ _this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
982
+ var defaultTypeAlignment = (_this._formConfig.tableFieldStyles[_this.fieldType] != null)
983
+ ? _this._formConfig.tableFieldStyles[_this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
984
+ var fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
985
+ _this.setAttr(fldAttr.alignment, fieldAlignment);
986
+ _this.setAttr(fldAttr.info, fld.info || '');
987
+ var fieldFormat;
988
+ try {
989
+ fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
1045
990
  }
1046
- if (_this.selectable) {
1047
- _this.selectionField = _this.columns
1048
- .find(function (column) { return column.fieldCode === (tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionField); });
991
+ catch (e) {
992
+ fieldFormat = null;
1049
993
  }
994
+ _this.setAttr(fldAttr.format, fieldFormat);
995
+ _this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
996
+ _this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
997
+ _this.setAttr(fldAttr.defaultEditable, _this.enabled);
998
+ _this.setAttr(fldAttr.required, (_e = fld.required) !== null && _e !== void 0 ? _e : false);
999
+ _this.setError(fld.errorCode, fld.errorMessage, (_f = fld.errorType) !== null && _f !== void 0 ? _f : DEFAULT_ERROR_TYPE);
1000
+ _this.setAttr(fldAttr.outputOnly, (_g = fld.outputOnly) !== null && _g !== void 0 ? _g : false);
1001
+ var maxLength = (_h = fld.maxLength) !== null && _h !== void 0 ? _h : (_this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1002
+ _this.setAttr(fldAttr.maxLength, maxLength);
1003
+ _this.setAttr(fldAttr.intrinsicErrorMessage, (_j = _this._formConfig.fieldTypeErrMsg[_this.fieldType]) !== null && _j !== void 0 ? _j : _this._formConfig.fieldTypeErrMsg.DEFAULT);
1004
+ _this.setFieldType(fld.fieldTypeCode);
1005
+ _this.setEditable((_k = fld.editable) !== null && _k !== void 0 ? _k : true);
1006
+ _this.setVisibleLabel((_l = fld.visibleLabel) !== null && _l !== void 0 ? _l : true);
1007
+ _this.setVisibility(fld.visible);
1008
+ _this.setFieldOptions(fld.fieldOptions);
1009
+ _this.setValue(fld.fieldValue || _this.defaultValue || '');
1050
1010
  return _this;
1051
1011
  }
1052
- Object.defineProperty(RecordTable.prototype, "inlineActionTrigger", {
1053
- get: function () { return this._inlineActionTrigger; },
1012
+ Object.defineProperty(FieldDescriptor.prototype, "name", {
1013
+ get: function () { return this.fieldCode; },
1054
1014
  enumerable: false,
1055
1015
  configurable: true
1056
1016
  });
1057
- Object.defineProperty(RecordTable.prototype, "globalActionTrigger", {
1058
- get: function () { return this._globalActionTrigger; },
1017
+ Object.defineProperty(FieldDescriptor.prototype, "editionFinish", {
1018
+ get: function () { return this._editionFinish; },
1059
1019
  enumerable: false,
1060
1020
  configurable: true
1061
1021
  });
1062
- Object.defineProperty(RecordTable.prototype, "selectionActionTrigger", {
1063
- get: function () { return this._selectionActionTrigger; },
1022
+ Object.defineProperty(FieldDescriptor.prototype, "attributeChange", {
1023
+ get: function () { return this._attributeChange; },
1064
1024
  enumerable: false,
1065
1025
  configurable: true
1066
1026
  });
1067
- Object.defineProperty(RecordTable.prototype, "recordSelectionTrigger", {
1068
- get: function () { return this._recordSelectionTrigger; },
1027
+ Object.defineProperty(FieldDescriptor.prototype, "editionPartial", {
1028
+ get: function () { return this._editionPartial; },
1069
1029
  enumerable: false,
1070
1030
  configurable: true
1071
1031
  });
1072
- Object.defineProperty(RecordTable.prototype, "getDataTrigger", {
1073
- get: function () { return this._getDataTrigger; },
1032
+ Object.defineProperty(FieldDescriptor.prototype, "detailRequest", {
1033
+ get: function () { return this._detailRequest; },
1074
1034
  enumerable: false,
1075
1035
  configurable: true
1076
1036
  });
1077
- Object.defineProperty(RecordTable.prototype, "attributeChange", {
1078
- get: function () { return this._attributeChange; },
1037
+ Object.defineProperty(FieldDescriptor.prototype, "info", {
1038
+ get: function () { return this.fieldInfo; },
1079
1039
  enumerable: false,
1080
1040
  configurable: true
1081
1041
  });
1082
- Object.defineProperty(RecordTable.prototype, "hasActions", {
1083
- get: function () { return (this._actions.length > 0); },
1042
+ Object.defineProperty(FieldDescriptor.prototype, "validating", {
1043
+ get: function () { return this._onValidation; },
1044
+ set: function (isValidating) { this.setAttr(fldAttr.onValidation, isValidating); },
1084
1045
  enumerable: false,
1085
1046
  configurable: true
1086
1047
  });
1087
- Object.defineProperty(RecordTable.prototype, "selectionFieldName", {
1088
- get: function () { var _a, _b; return (_b = (_a = this.selectionField) === null || _a === void 0 ? void 0 : _a.fieldCode) !== null && _b !== void 0 ? _b : null; },
1048
+ FieldDescriptor.prototype.focus = function () { this.setAttr(fldAttr.focus, true); };
1049
+ FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); };
1050
+ Object.defineProperty(FieldDescriptor.prototype, "intrinsicErrorMessage", {
1051
+ set: function (message) { this.setIntrinsicErrorMessage(message); },
1089
1052
  enumerable: false,
1090
1053
  configurable: true
1091
1054
  });
1092
- Object.defineProperty(RecordTable.prototype, "columnNames", {
1093
- get: function () { return Object.keys(this._tableColumnObj); },
1055
+ Object.defineProperty(FieldDescriptor.prototype, "fieldValue", {
1056
+ get: function () { return this.getValue(); },
1094
1057
  enumerable: false,
1095
1058
  configurable: true
1096
1059
  });
1097
- Object.defineProperty(RecordTable.prototype, "records", {
1098
- get: function () { return this.visibleRecords; },
1099
- set: function (records) { this.replaceRecords(records); },
1060
+ FieldDescriptor.prototype.getRequired = function () { return this.required; };
1061
+ FieldDescriptor.prototype.setRequired = function (required) { this.required = required; };
1062
+ Object.defineProperty(FieldDescriptor.prototype, "required", {
1063
+ get: function () { return this.fieldRequired; },
1064
+ set: function (required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); },
1100
1065
  enumerable: false,
1101
1066
  configurable: true
1102
1067
  });
1103
- Object.defineProperty(RecordTable.prototype, "selectedRecords", {
1104
- get: function () {
1105
- return this.tableRecords.filter(function (rec) { return rec.selected; })
1106
- .map(function (rec) { return rec.recordId; });
1068
+ Object.defineProperty(FieldDescriptor.prototype, "maxLength", {
1069
+ get: function () { return (this._maxLength > 0) ? this._maxLength.toString() : ''; },
1070
+ set: function (requiredMaxLength) {
1071
+ if (typeof requiredMaxLength === 'string') {
1072
+ this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
1073
+ }
1074
+ else if (typeof requiredMaxLength === 'number') {
1075
+ this.setAttr(fldAttr.maxLength, requiredMaxLength);
1076
+ }
1107
1077
  },
1108
1078
  enumerable: false,
1109
1079
  configurable: true
1110
1080
  });
1111
- RecordTable.prototype.setAttr = function (name, value) {
1112
- this[name] = value;
1113
- if (this._formConfig.monitoredTableAttributes.includes(name)) {
1114
- this._attributeChange.next({ name: name, value: value });
1115
- }
1116
- };
1117
- RecordTable.prototype.appendRecords = function (records) { this.setTableRecords(records, true); };
1118
- RecordTable.prototype.replaceRecords = function (records) { this.setTableRecords(records, false); };
1119
- RecordTable.prototype.columnDefinition = function (fieldCode) { return this._tableColumnObj[fieldCode]; };
1120
- RecordTable.prototype.putOnWait = function () { this.waiting = true; };
1121
- RecordTable.prototype.freeWaiting = function () { this.waiting = false; };
1122
- RecordTable.prototype.getActionObject = function (actionCode) { return this.getAction(actionCode); };
1123
- RecordTable.prototype.notifyGlobalAction = function (actionCode) {
1124
- var tableEvent = {
1125
- tableCode: this.tableCode,
1126
- actionCode: actionCode,
1127
- actionDetail: null
1128
- };
1129
- this._globalActionTrigger.next(tableEvent);
1130
- };
1131
- RecordTable.prototype.notifyInlineAction = function (tableActionEvent) {
1132
- var tableEvent = {
1133
- tableCode: this.tableCode,
1134
- actionCode: tableActionEvent.actionCode,
1135
- actionDetail: {
1136
- recordId: tableActionEvent.recordId,
1137
- recordData: tableActionEvent.recordData
1138
- }
1139
- };
1140
- this._inlineActionTrigger.next(tableEvent);
1141
- };
1142
- RecordTable.prototype.notifyRecordSelection = function (recordId) {
1143
- var record = this.getTableRecord(recordId);
1144
- if (!record) {
1145
- return;
1146
- }
1147
- record.toggleSelect();
1148
- var tableEvent = {
1149
- tableCode: this.tableCode,
1150
- actionCode: null,
1151
- actionDetail: {
1152
- recordId: record.recordId,
1153
- recordData: record.recordData
1154
- }
1155
- };
1156
- this.recordSelectionTrigger.next(tableEvent);
1157
- };
1158
- RecordTable.prototype.notifySelectionAction = function (actionCode) {
1159
- var tableEvent = {
1160
- tableCode: this.tableCode,
1161
- actionCode: actionCode,
1162
- actionDetail: {
1163
- selectedRecords: this.selectedRecords
1164
- }
1165
- };
1166
- this._selectionActionTrigger.next(tableEvent);
1167
- };
1168
- RecordTable.prototype.notifyGetDataAction = function (requestedPage) {
1169
- if (requestedPage === void 0) { requestedPage = null; }
1170
- this.updateVisibleRecords();
1171
- this.requestedPage = requestedPage || this.currentPage;
1172
- var tableEvent = {
1173
- tableCode: this.tableCode,
1174
- actionCode: null,
1175
- actionDetail: null,
1176
- };
1177
- this._getDataTrigger.next(tableEvent);
1178
- };
1179
- RecordTable.prototype.clean = function () {
1180
- this.visibleRecords = [];
1181
- this.tableRecords = [];
1182
- this.tableRecordObj = {};
1183
- };
1184
- RecordTable.prototype.selectAll = function () {
1185
- this.setAttr('allSelected', true);
1186
- this.tableRecords.forEach(function (record) { return record.select(); });
1187
- };
1188
- RecordTable.prototype.unSelectAll = function () {
1189
- this.setAttr('allSelected', false);
1190
- this.tableRecords.forEach(function (record) { return record.unselect(); });
1081
+ Object.defineProperty(FieldDescriptor.prototype, "value", {
1082
+ get: function () { return this.getValue(); },
1083
+ set: function (newValue) { this.setValue(newValue); },
1084
+ enumerable: false,
1085
+ configurable: true
1086
+ });
1087
+ FieldDescriptor.prototype.notifyEditionPartial = function () {
1088
+ var intrinsicValidation = true;
1089
+ this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
1191
1090
  };
1192
- RecordTable.prototype.setTableRecords = function (tableRecords, append) {
1193
- var e_4, _g;
1194
- var _a;
1195
- if (!append) {
1196
- this.clean();
1197
- }
1198
- var newRecordsObj = Object.assign({}, this.tableRecordObj);
1199
- var newRecords = __spreadArray([], __read(this.tableRecords));
1200
- try {
1201
- for (var tableRecords_1 = __values(tableRecords), tableRecords_1_1 = tableRecords_1.next(); !tableRecords_1_1.done; tableRecords_1_1 = tableRecords_1.next()) {
1202
- var tableRecord = tableRecords_1_1.value;
1203
- var recordReceived = new TableRecordData(tableRecord, this.columns, (_a = this.selectionField) === null || _a === void 0 ? void 0 : _a.fieldCode);
1204
- var recordIdKey = recordReceived.recordIdKey;
1205
- newRecords.push(recordReceived);
1206
- newRecordsObj[recordIdKey] = recordReceived;
1091
+ FieldDescriptor.prototype.notifyEditionFinish = function () {
1092
+ var _a, _b, _c, _d, _e;
1093
+ var intrinsicValidation = true;
1094
+ var fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
1095
+ var fieldValue = this.getValue();
1096
+ if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
1097
+ intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
1098
+ && ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
1099
+ if (!intrinsicValidation) {
1100
+ this.setError('99', this._intrinsicErrorMessage);
1207
1101
  }
1208
1102
  }
1209
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1210
- finally {
1211
- try {
1212
- if (tableRecords_1_1 && !tableRecords_1_1.done && (_g = tableRecords_1.return)) _g.call(tableRecords_1);
1213
- }
1214
- finally { if (e_4) throw e_4.error; }
1103
+ if (intrinsicValidation && fieldValue && this._minValue && fieldValue < this._minValue) {
1104
+ intrinsicValidation = false;
1105
+ this.setError('99', 'Campo con valor inferior al mínimo');
1215
1106
  }
1216
- this.tableRecords = newRecords;
1217
- this.tableRecordObj = newRecordsObj;
1218
- this.updateVisibleRecords();
1219
- };
1220
- RecordTable.prototype.updateVisibleRecords = function () {
1221
- var _this = this;
1222
- if (!this.clientPaging || !this.tableRecords || this.tableRecords.length === 0) {
1223
- this.setAttr('visibleRecords', this.tableRecords);
1107
+ if (intrinsicValidation && fieldValue && this._maxValue && fieldValue > this._maxValue) {
1108
+ intrinsicValidation = false;
1109
+ this.setError('99', 'Campo con valor superior al máximo');
1224
1110
  }
1225
- var recordsVisible = (this.filterObject.filterModeSimple)
1226
- ? this.tableRecords.filter(function (record) { return record.hasPattern(_this.filterObject.simpleFilterWords); })
1227
- : this.tableRecords.filter(function (record) { return record.hasCondition(_this.filterObject.advancedFilter); });
1228
- this.setAttr('visibleRecords', recordsVisible);
1111
+ this._editionFinish.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
1229
1112
  };
1230
- RecordTable.prototype.updateFromServer = function (tableReceived) {
1231
- this.visible = (tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.visible) || true;
1232
- this.setAttr('currentPage', parseInt(tableReceived.currentPage, 10) || 1);
1233
- this.totalPages = tableReceived.totalPages || 1;
1234
- this.setAttr('recordsPerPage', tableReceived.recordsPerPage);
1235
- this.recordsNumber = tableReceived.recordsNumber;
1236
- this.setAttr('totalRecordsNumber', tableReceived.totalRecordsNumber);
1237
- this.setAttr('sorting', {
1238
- columnName: tableReceived.sortingColumn || '',
1239
- direction: tableReceived.sortingDirection || ''
1240
- });
1241
- this.requestedPage = 1;
1242
- this.waiting = false;
1243
- this.clean();
1244
- if (this._appendPages) {
1245
- this.replaceRecords(tableReceived.tableRecords);
1246
- }
1247
- else {
1248
- this.appendRecords(tableReceived.tableRecords);
1113
+ FieldDescriptor.prototype.setAttr = function (name, value) {
1114
+ this[name] = value;
1115
+ if (this._formConfig.monitoredFieldAttributes.includes(name)) {
1116
+ this._attributeChange.next({ name: name, value: value });
1249
1117
  }
1250
1118
  };
1251
- RecordTable.prototype.getTableRecord = function (recordId) {
1252
- var recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
1253
- return (this.tableRecordObj && recordId && this.tableRecordObj[recordId])
1254
- ? this.tableRecordObj[recordId] : null;
1255
- };
1256
- RecordTable.prototype.getAction = function (actionCode) {
1257
- return (this._actionsObj && actionCode && this._actionsObj[actionCode])
1258
- ? this._actionsObj[actionCode] : null;
1259
- };
1260
- RecordTable.prototype.getActions = function (actionClass, actionTypes) {
1261
- if (actionClass === void 0) { actionClass = this._formConfig.tableActions.inline; }
1262
- if (actionTypes === void 0) { actionTypes = null; }
1263
- return this._actions.filter(function (actionDef) {
1264
- var typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
1265
- return actionDef.actionClass === actionClass && typeIncluded;
1266
- });
1119
+ FieldDescriptor.prototype.notifyEditionDetailRequest = function (detail) {
1120
+ var detailEvent = {
1121
+ code: this.fieldCode,
1122
+ detail: detail,
1123
+ };
1124
+ this._detailRequest.next(detailEvent);
1267
1125
  };
1268
- Object.defineProperty(RecordTable.prototype, "simpleFilterText", {
1269
- // Filtros
1270
- set: function (filterText) {
1271
- var terms = (filterText) ? filterText.split(' ') : null;
1272
- if (terms && terms.length > 0) {
1273
- terms = terms.filter(function (term) { return term !== ''; });
1274
- }
1275
- this.filterObject.filterModeSimple = true;
1276
- this.filterObject.simpleFilterWords = terms || [];
1277
- },
1126
+ FieldDescriptor.prototype.setVisibleLabel = function (visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); };
1127
+ FieldDescriptor.prototype.showLabel = function () { this.setVisibleLabel(true); };
1128
+ FieldDescriptor.prototype.hideLabel = function () { this.setVisibleLabel(false); };
1129
+ FieldDescriptor.prototype.setChanged = function (hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); };
1130
+ FieldDescriptor.prototype.changed = function () { this.setChanged(true); };
1131
+ FieldDescriptor.prototype.setLabel = function (label) { this.setAttr(fldAttr.title, label); };
1132
+ FieldDescriptor.prototype.clean = function () { this.setValue(this.defaultValue || ''); this.resetError(); };
1133
+ Object.defineProperty(FieldDescriptor.prototype, "backend", {
1134
+ get: function () { return this.validateOnServer; },
1278
1135
  enumerable: false,
1279
1136
  configurable: true
1280
1137
  });
1281
- RecordTable.prototype.changeFilterMode = function (toSimple) {
1282
- this.filterObject.filterModeSimple = toSimple;
1283
- };
1284
- RecordTable.prototype.addFilterRestriction = function (filterTerm) {
1285
- this.filterObject.advancedFilter.push(filterTerm);
1138
+ FieldDescriptor.prototype.setEditable = function (editable) {
1139
+ if (editable === void 0) { editable = true; }
1140
+ (editable) ? this.enable() : this.disable();
1286
1141
  };
1287
- RecordTable.prototype.removeFilterRestriction = function (fieldCode) {
1288
- var filterIndex = this.filterObject.advancedFilter.findIndex(function (filterDef) {
1289
- return filterDef.fieldSearch.fieldCode === fieldCode;
1290
- });
1291
- var filterToRemove = this.filterObject.advancedFilter[filterIndex];
1292
- this.filterObject.advancedFilter.splice(filterIndex, 1);
1293
- return filterToRemove;
1142
+ FieldDescriptor.prototype.hasError = function () { return this.errorCode !== NO_ERROR; };
1143
+ FieldDescriptor.prototype.resetError = function () { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); };
1144
+ FieldDescriptor.prototype.setError = function (code, message, type) {
1145
+ if (type === void 0) { type = DEFAULT_ERROR_TYPE; }
1146
+ this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
1147
+ this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
1148
+ this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
1294
1149
  };
1295
- Object.defineProperty(RecordTable.prototype, "availableFilters", {
1296
- get: function () {
1297
- var _this = this;
1298
- return this.filterConfig.filter(function (fieldSearch) {
1299
- var currentFilter = _this.filterObject.advancedFilter.find(function (filterItem) {
1300
- return filterItem.fieldSearch.fieldCode === fieldSearch.fieldCode;
1301
- });
1302
- return !currentFilter;
1303
- });
1304
- },
1150
+ FieldDescriptor.prototype.getError = function () { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; };
1151
+ Object.defineProperty(FieldDescriptor.prototype, "error", {
1152
+ get: function () { return this.getError(); },
1153
+ set: function (errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); },
1305
1154
  enumerable: false,
1306
1155
  configurable: true
1307
1156
  });
1308
- Object.defineProperty(RecordTable.prototype, "currentFilter", {
1309
- get: function () {
1310
- var compactFilter = {};
1311
- if (this.filterObject.filterModeSimple) {
1312
- compactFilter.simpleFilterWords = this.filterObject.simpleFilterWords;
1313
- }
1314
- else {
1315
- compactFilter.advancedFilter = [];
1316
- this.filterObject.advancedFilter.forEach(function (condition) {
1317
- var simplifiedCondition = {
1318
- fieldCode: condition.fieldSearch.fieldCode,
1319
- fieldAlias: condition.fieldSearch.fieldAlias,
1320
- operator: condition.operator,
1321
- fieldValue1: condition.fieldValue1,
1322
- fieldValue2: condition.fieldValue2,
1323
- };
1324
- compactFilter.advancedFilter.push(simplifiedCondition);
1325
- });
1326
- }
1327
- return compactFilter;
1328
- },
1157
+ FieldDescriptor.prototype.getErrorCode = function () { return this.getError().code; };
1158
+ FieldDescriptor.prototype.setErrorCode = function (code) { this.setError(code, this.errorMessage); };
1159
+ FieldDescriptor.prototype.getErrorMessage = function () { return this.getError().message; };
1160
+ FieldDescriptor.prototype.setErrorMessage = function (msg) { this.setError(this.errorCode, msg); };
1161
+ Object.defineProperty(FieldDescriptor.prototype, "empty", {
1162
+ get: function () { return this.isEmpty(); },
1329
1163
  enumerable: false,
1330
1164
  configurable: true
1331
1165
  });
1332
- // Ordenamiento
1333
- RecordTable.prototype.setRequiredOrder = function (columnField) {
1334
- if (columnField !== this.sorting.columnName) {
1335
- this.setAttr('sorting', {
1336
- columnName: columnField,
1337
- direction: TABLE_SORT_ASCENDING
1338
- });
1339
- }
1340
- else {
1341
- var tableSort = this.sorting;
1342
- tableSort.direction = (tableSort.direction === TABLE_SORT_ASCENDING) ? TABLE_SORT_DESCENDING : TABLE_SORT_ASCENDING;
1343
- this.setAttr('sorting', tableSort);
1166
+ FieldDescriptor.prototype.isEmpty = function () {
1167
+ var fieldCurrentValue = this.getValue();
1168
+ if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
1169
+ return true;
1344
1170
  }
1345
- };
1346
- RecordTable.prototype.localSortData = function () {
1347
- var _this = this;
1348
- if (!this.sorting.columnName || !this.sorting.direction) {
1349
- return;
1171
+ if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
1172
+ && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
1173
+ return true;
1350
1174
  }
1351
- this.tableRecords.sort(function (a, b) { return _this.recordCompare(a, b, _this.sorting.columnName, _this.sorting.direction); });
1352
- this.updateVisibleRecords();
1175
+ ;
1176
+ return fieldCurrentValue === '';
1353
1177
  };
1354
- RecordTable.prototype.recordCompare = function (recordA, recordB, columnCompare, direction) {
1355
- var recordAColumn = recordA.getFieldValue(columnCompare);
1356
- var recordBColumn = recordB.getFieldValue(columnCompare);
1357
- var result = 0;
1358
- if (recordAColumn < recordBColumn) {
1359
- result = -1;
1360
- }
1361
- else if (recordAColumn > recordBColumn) {
1362
- result = 1;
1178
+ FieldDescriptor.prototype.getValue = function () {
1179
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
1180
+ || this.fieldType === this._formConfig.fieldTypes.check) {
1181
+ return yn__default['default'](this._value);
1363
1182
  }
1364
- return direction === TABLE_SORT_ASCENDING ? result : -result;
1365
- };
1366
- return RecordTable;
1367
- }(FormElement));
1368
-
1369
- var LibTableFilterComponent = /** @class */ (function () {
1370
- function LibTableFilterComponent() {
1371
- this.simpleSearchString = '';
1372
- this.filterObject = new Filter();
1373
- this.complexIsCollapsed = true;
1374
- this.filterChanged = new core.EventEmitter();
1375
- }
1376
- LibTableFilterComponent.prototype.ngOnInit = function () {
1377
- this.start();
1378
- };
1379
- LibTableFilterComponent.prototype.start = function () { };
1380
- LibTableFilterComponent.prototype.filterHasChanged = function (changeType) {
1381
- this.complexIsCollapsed = true;
1382
- var eventType = (changeType === 'change')
1383
- ? TABLE_FILTER_TYPES.simpleFilterFinish
1384
- : TABLE_FILTER_TYPES.simpleFilterChange;
1385
- var tableFilterEvent = {
1386
- eventType: eventType,
1387
- simpleFilterString: this.simpleSearchString,
1388
- complexFilterItem: null,
1389
- itemName: null,
1390
- };
1391
- this.filterChanged.emit(tableFilterEvent);
1183
+ return this._value;
1392
1184
  };
1393
- LibTableFilterComponent.prototype.selectField = function () {
1185
+ FieldDescriptor.prototype.getOptionText = function () {
1394
1186
  var _this = this;
1395
- this.selectedOperator = '';
1396
- this.filterValue1 = '';
1397
- this.filterValue2 = '';
1398
- this.filterFieldConfig = this.complexFilterConfig.find(function (filterConfig) { return filterConfig.fieldCode === _this.selectedField; });
1399
- this.possibleOperators = [];
1400
- if (this.filterFieldConfig && this.filterFieldConfig.operators) {
1401
- this.possibleOperators = this.filterFieldConfig.operators;
1402
- }
1403
- };
1404
- LibTableFilterComponent.prototype.addFilterField = function () {
1405
- var filterCondition = {
1406
- fieldSearch: this.filterFieldConfig,
1407
- operator: this.selectedOperator,
1408
- fieldValue1: this.filterValue1,
1409
- fieldValue2: this.filterValue2,
1410
- };
1411
- var tableFilterEvent = {
1412
- eventType: TABLE_FILTER_TYPES.complexFilterAdd,
1413
- simpleFilterString: null,
1414
- complexFilterItem: filterCondition,
1415
- itemName: null,
1416
- };
1417
- this.filterChanged.emit(tableFilterEvent);
1418
- this.clearFilterField();
1419
- };
1420
- LibTableFilterComponent.prototype.clearFilterField = function () {
1421
- this.selectedField = '';
1422
- this.selectedOperator = '';
1423
- this.selectedOperator = '';
1424
- this.filterValue1 = '';
1425
- this.filterValue2 = '';
1426
- this.possibleOperators = [];
1427
- };
1428
- LibTableFilterComponent.prototype.removeFilterField = function (fieldCode) {
1429
- var tableFilterEvent = {
1430
- eventType: TABLE_FILTER_TYPES.complexFilterRemove,
1431
- simpleFilterString: null,
1432
- complexFilterItem: null,
1433
- itemName: fieldCode,
1434
- };
1435
- this.filterChanged.emit(tableFilterEvent);
1436
- // Se elimina de la configuración de filtro local
1437
- var idx = this.filterObject.advancedFilter.findIndex(function (def) { return def.fieldSearch.fieldCode === fieldCode; });
1438
- if (idx >= 0) {
1439
- var filterToRemove = this.filterObject.advancedFilter[idx];
1440
- this.selectedField = filterToRemove.fieldSearch.fieldCode;
1441
- this.selectField();
1442
- this.selectedOperator = filterToRemove.operator;
1443
- this.filterValue1 = filterToRemove.fieldValue1;
1444
- this.filterValue2 = filterToRemove.fieldValue2;
1445
- this.filterObject.advancedFilter.splice(idx, 1);
1446
- }
1447
- };
1448
- return LibTableFilterComponent;
1449
- }());
1450
- LibTableFilterComponent.decorators = [
1451
- { type: core.Component, args: [{
1452
- selector: 'lib-table-filter',
1453
- template: "<ng-content></ng-content>"
1454
- },] }
1455
- ];
1456
- LibTableFilterComponent.propDecorators = {
1457
- simpleFilter: [{ type: core.Input }],
1458
- complexFilter: [{ type: core.Input }],
1459
- complexFilterConfig: [{ type: core.Input }],
1460
- filterChanged: [{ type: core.Output }]
1461
- };
1462
-
1463
- var INLINE_ACTION$1 = 'INLINE';
1464
- var LibTableRecordActionComponent = /** @class */ (function () {
1465
- function LibTableRecordActionComponent() {
1466
- this.actionSelected = new core.EventEmitter();
1467
- }
1468
- LibTableRecordActionComponent.prototype.ngOnInit = function () {
1469
- this.start();
1470
- };
1471
- LibTableRecordActionComponent.prototype.start = function () { };
1472
- LibTableRecordActionComponent.prototype.onActivate = function () {
1473
- var tableEvent = {
1474
- actionCode: this.action.actionCode,
1475
- recordId: this.recordId,
1476
- recordData: this.recordData,
1477
- };
1478
- this.actionSelected.emit(tableEvent);
1479
- };
1480
- LibTableRecordActionComponent.prototype.class = function () { };
1481
- return LibTableRecordActionComponent;
1482
- }());
1483
- LibTableRecordActionComponent.decorators = [
1484
- { type: core.Component, args: [{
1485
- selector: 'lib-table-record-action',
1486
- template: "<ng-content></ng-content>",
1487
- changeDetection: core.ChangeDetectionStrategy.OnPush
1488
- },] }
1489
- ];
1490
- LibTableRecordActionComponent.ctorParameters = function () { return []; };
1491
- LibTableRecordActionComponent.propDecorators = {
1492
- recordId: [{ type: core.Input }],
1493
- recordData: [{ type: core.Input }],
1494
- action: [{ type: core.Input }],
1495
- actionSelected: [{ type: core.Output }]
1496
- };
1497
-
1498
- var LibTableRecordFieldComponent = /** @class */ (function () {
1499
- function LibTableRecordFieldComponent() {
1500
- }
1501
- LibTableRecordFieldComponent.prototype.ngOnInit = function () {
1502
- this.start();
1187
+ var _a, _b, _c;
1188
+ return (_c = (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.fieldOptionId === _this._value; })) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null;
1503
1189
  };
1504
- LibTableRecordFieldComponent.prototype.start = function () { };
1505
- return LibTableRecordFieldComponent;
1506
- }());
1507
- LibTableRecordFieldComponent.decorators = [
1508
- { type: core.Component, args: [{
1509
- selector: 'lib-table-record-field',
1510
- template: "<ng-content></ng-content>",
1511
- changeDetection: core.ChangeDetectionStrategy.OnPush
1512
- },] }
1513
- ];
1514
- LibTableRecordFieldComponent.propDecorators = {
1515
- fieldCode: [{ type: core.Input }],
1516
- fieldType: [{ type: core.Input }],
1517
- fieldValue: [{ type: core.Input }]
1518
- };
1519
-
1520
- var LibTableComponent = /** @class */ (function () {
1521
- function LibTableComponent() {
1522
- this.loaded = false;
1523
- this.selectable = false;
1524
- this.hasActions = false;
1525
- }
1526
- LibTableComponent.prototype.ngOnInit = function () {
1527
- var _this = this;
1528
- var _a, _b;
1529
- if (this.table) {
1530
- this.formConfig = (_a = this.table) === null || _a === void 0 ? void 0 : _a._formConfig;
1531
- this.tableFieldStyles = this.formConfig.tableFieldStyles;
1532
- this.selectable = this.table.selectable;
1533
- this.hasActions = this.table.hasActions;
1534
- this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
1535
- this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
1536
- this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
1537
- // Inicialización de campos mapeados del objeto
1538
- var mapping = Object.entries(this.formConfig.componentTableAttrMap);
1539
- for (var index = 0; index < mapping.length; index++) {
1540
- var _c = __read(mapping[index], 2), tableAttr = _c[0], compAttr = _c[1];
1541
- this[compAttr.toString()] = (_b = this.table) === null || _b === void 0 ? void 0 : _b[tableAttr.toString()];
1542
- }
1543
- // Subscripción a cambios en atributos
1544
- this.table.attributeChange.subscribe(function (event) {
1545
- var tableAttr = event.name, value = event.value;
1546
- var compAttr = _this.formConfig.componentTableAttrMap[tableAttr];
1547
- _this.hasOwnProperty(compAttr) && (_this[compAttr] = value);
1548
- });
1190
+ FieldDescriptor.prototype.updateFromServer = function (fld) {
1191
+ var _a;
1192
+ var fieldKeys = Object.keys(fld);
1193
+ for (var index = 0; index < fieldKeys.length; index++) {
1194
+ var attrName = fieldKeys[index];
1195
+ var attrValue = fld[attrName];
1196
+ (attrName === this._formConfig.apiFieldAttrs.visible) && this.setVisibility(attrValue);
1197
+ (attrName === this._formConfig.apiFieldAttrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
1198
+ (attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
1199
+ (attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
1200
+ (attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
1201
+ (attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
1202
+ (attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
1203
+ (attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
1204
+ (attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
1205
+ (attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
1206
+ (attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
1207
+ (attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
1208
+ (attrName === this._formConfig.apiFieldAttrs.type) && this.setFieldType(fld.fieldTypeCode);
1209
+ (attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
1549
1210
  }
1550
- this.start();
1551
1211
  };
1552
- LibTableComponent.prototype.start = function () { };
1553
- LibTableComponent.prototype.tableGlobalAction = function (actionCode) {
1554
- this.table.notifyGlobalAction(actionCode);
1555
- };
1556
- LibTableComponent.prototype.tableSelectionAction = function (actionCode) {
1557
- this.table.notifySelectionAction(actionCode);
1558
- };
1559
- LibTableComponent.prototype.tableActionSelected = function (actionEvent) {
1560
- this.table.notifyInlineAction(actionEvent);
1212
+ FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
1213
+ this.setAttr(fldAttr.type, inputFieldType);
1561
1214
  };
1562
- LibTableComponent.prototype.tableColumnSort = function (columnFieldCode) {
1563
- this.table.setRequiredOrder(columnFieldCode);
1564
- if (this.clientPaging) {
1565
- return this.table.localSortData();
1215
+ FieldDescriptor.prototype.setMinValue = function (inputMinValue) {
1216
+ var minValue = inputMinValue;
1217
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
1218
+ minValue = new Date(minValue);
1566
1219
  }
1567
- this.table.notifyGetDataAction();
1220
+ this.setAttr(fldAttr.minValue, minValue);
1568
1221
  };
1569
- LibTableComponent.prototype.changePage = function (requestedPage) {
1570
- if (!this.clientPaging) {
1571
- this.table.notifyGetDataAction(requestedPage);
1222
+ FieldDescriptor.prototype.setMaxValue = function (inputMaxValue) {
1223
+ var maxValue = inputMaxValue;
1224
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
1225
+ maxValue = new Date(maxValue);
1572
1226
  }
1227
+ this.setAttr(fldAttr.maxValue, maxValue);
1573
1228
  };
1574
- Object.defineProperty(LibTableComponent.prototype, "records", {
1575
- get: function () {
1576
- var currentPageRecords = this.visibleRecords;
1577
- if (this.clientPaging && currentPageRecords && currentPageRecords.length > 0) {
1578
- this.totalRecordsNumber = currentPageRecords.length;
1579
- return currentPageRecords.map(function (record, i) { return (Object.assign({ id: i + 1 }, record)); })
1580
- .slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
1229
+ FieldDescriptor.prototype.getFieldOptions = function () {
1230
+ return this.fieldOptions.map(function (option) {
1231
+ var optionCopy = Object.assign({}, option);
1232
+ return optionCopy;
1233
+ });
1234
+ };
1235
+ FieldDescriptor.prototype.setFieldOptions = function (newOptions) {
1236
+ var _this = this;
1237
+ var _a;
1238
+ if ((this.captureType !== 'LIST' && this.captureType !== 'RADIO')
1239
+ || typeof newOptions === UNDEFINED || !newOptions
1240
+ || !Array.isArray(newOptions)) {
1241
+ return;
1242
+ }
1243
+ var fieldOptions = newOptions.map(function (option) {
1244
+ if (option.text !== undefined && option.text !== null
1245
+ && option.value !== undefined && option.value !== null) {
1246
+ return { fieldOptionValue: option.text, fieldOptionId: option.value };
1581
1247
  }
1582
- return currentPageRecords;
1583
- },
1584
- enumerable: false,
1585
- configurable: true
1586
- });
1587
- LibTableComponent.prototype.applyCurrentFilter = function (tableFilterEvent) {
1588
- var eventType = tableFilterEvent.eventType;
1589
- var triggerDataUpdate = false;
1590
- if (eventType === TABLE_FILTER_TYPES.simpleFilterChange || eventType === TABLE_FILTER_TYPES.simpleFilterFinish) {
1591
- this.table.simpleFilterText = tableFilterEvent.simpleFilterString.trim();
1592
- if (this.clientPaging) {
1593
- this.table.setAttr('currentPage', 1);
1594
- this.table.updateVisibleRecords();
1248
+ return Object.assign({}, option);
1249
+ });
1250
+ fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
1251
+ && fieldOptions.length > 0) ? fieldOptions : [];
1252
+ this.setAttr(fldAttr.options, fieldOptions);
1253
+ if (this._value) {
1254
+ if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
1255
+ var fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
1256
+ this.setAttr(fldAttr.value, fieldValue);
1595
1257
  }
1596
- else if (eventType === TABLE_FILTER_TYPES.simpleFilterFinish) {
1597
- triggerDataUpdate = true;
1258
+ else {
1259
+ var valInOptions = this.fieldOptions
1260
+ .find(function (item) { return item.fieldOptionId === _this._value; });
1261
+ if (!valInOptions) {
1262
+ this.setValue('');
1263
+ }
1598
1264
  }
1599
1265
  }
1600
- if (eventType === TABLE_FILTER_TYPES.complexFilterAdd) {
1601
- this.table.addFilterRestriction(tableFilterEvent.complexFilterItem);
1266
+ if (this.fieldRequired && this.fieldOptions.length === 1) {
1267
+ this.setValue(this.fieldOptions[0].fieldOptionId);
1602
1268
  }
1603
- if (eventType === TABLE_FILTER_TYPES.complexFilterRemove) {
1604
- this.table.removeFilterRestriction(tableFilterEvent.itemName);
1269
+ };
1270
+ FieldDescriptor.prototype.setValue = function (newValue, widgetUpdate) {
1271
+ if (widgetUpdate === void 0) { widgetUpdate = true; }
1272
+ if (typeof newValue === UNDEFINED || newValue === null) {
1273
+ return true;
1605
1274
  }
1606
- if (triggerDataUpdate) {
1607
- var tableGetDataEvent = {
1608
- tableCode: this.table.tableCode,
1609
- requestedPage: 1,
1610
- };
1611
- this.table.notifyGetDataAction(tableGetDataEvent);
1275
+ var newFinalValue;
1276
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
1277
+ || this.fieldType === this._formConfig.fieldTypes.check) {
1278
+ newFinalValue = yn__default['default'](newValue);
1612
1279
  }
1613
- };
1614
- LibTableComponent.prototype.tableSelectionToggle = function (recordId) {
1615
- this.table.notifyRecordSelection(recordId);
1616
- };
1617
- LibTableComponent.prototype.toggleSelectAll = function () {
1618
- if (this.allSelected) {
1619
- this.table.unSelectAll();
1280
+ else if (this.fieldType === this._formConfig.fieldTypes.array
1281
+ || this.fieldType === this._formConfig.fieldTypes.map) {
1282
+ if (newValue === null || newValue === '') {
1283
+ newFinalValue = [];
1284
+ }
1285
+ else if (Array.isArray(newValue)) {
1286
+ newFinalValue = newValue;
1287
+ }
1288
+ else {
1289
+ newFinalValue = newValue.toString().split(',');
1290
+ }
1620
1291
  }
1621
1292
  else {
1622
- this.table.selectAll();
1293
+ newFinalValue = newValue;
1294
+ }
1295
+ if (this._value !== newFinalValue) {
1296
+ this.setChanged(true);
1297
+ if (widgetUpdate) {
1298
+ this.setAttr(fldAttr.value, newFinalValue);
1299
+ }
1300
+ else {
1301
+ this._value = newFinalValue;
1302
+ }
1303
+ }
1304
+ return true;
1305
+ };
1306
+ return FieldDescriptor;
1307
+ }(FormElement));
1308
+
1309
+ var RecordTableColumn = /** @class */ (function () {
1310
+ function RecordTableColumn(recTableColReceived, formConfig) {
1311
+ var _a, _b, _c;
1312
+ this._formConfig = formConfig;
1313
+ if (recTableColReceived) {
1314
+ this.fieldCode = recTableColReceived.fieldCode;
1315
+ this.fieldTitle = recTableColReceived.fieldTitle;
1316
+ this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
1317
+ var defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
1318
+ this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
1319
+ this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
1320
+ this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
1321
+ this.fieldFormat = recTableColReceived.format || '';
1322
+ this.customAttributes = (_c = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.customAttributes) !== null && _c !== void 0 ? _c : {};
1623
1323
  }
1324
+ }
1325
+ RecordTableColumn.prototype.addFilterDefinition = function (filterDefinition) {
1326
+ var _a;
1327
+ this.filterDef = {
1328
+ operators: filterDefinition.operators,
1329
+ options: (_a = filterDefinition.options) !== null && _a !== void 0 ? _a : null,
1330
+ };
1624
1331
  };
1625
- Object.defineProperty(LibTableComponent.prototype, "availableFilters", {
1332
+ Object.defineProperty(RecordTableColumn.prototype, "filterDefinition", {
1626
1333
  get: function () {
1627
- return this.table.availableFilters;
1334
+ return this.filterDef;
1628
1335
  },
1629
1336
  enumerable: false,
1630
1337
  configurable: true
1631
1338
  });
1632
- Object.defineProperty(LibTableComponent.prototype, "selectedRecords", {
1339
+ RecordTableColumn.prototype.addFilter = function (columnValues, operator) {
1340
+ this.filterSetup = {
1341
+ fieldCode: this.fieldCode,
1342
+ operator: operator !== null && operator !== void 0 ? operator : this.filterDef.operators[0],
1343
+ values: columnValues,
1344
+ };
1345
+ };
1346
+ Object.defineProperty(RecordTableColumn.prototype, "filter", {
1633
1347
  get: function () {
1634
- return this.table.selectedRecords;
1348
+ return this.filterSetup;
1635
1349
  },
1636
1350
  enumerable: false,
1637
1351
  configurable: true
1638
1352
  });
1639
- return LibTableComponent;
1353
+ RecordTableColumn.prototype.removeFilter = function () {
1354
+ this.filterSetup = null;
1355
+ };
1356
+ return RecordTableColumn;
1640
1357
  }());
1641
- LibTableComponent.decorators = [
1642
- { type: core.Component, args: [{
1643
- selector: 'lib-table',
1644
- template: "<ng-content></ng-content>",
1645
- changeDetection: core.ChangeDetectionStrategy.OnPush
1646
- },] }
1647
- ];
1648
- LibTableComponent.propDecorators = {
1649
- table: [{ type: core.Input }],
1650
- tableRecords: [{ type: core.Input }],
1651
- disabled: [{ type: core.Input }],
1652
- state: [{ type: core.Input }],
1653
- waiting: [{ type: core.Input }]
1654
- };
1655
1358
 
1656
- var HEADER = 'HEADER';
1657
- var FormAction = /** @class */ (function (_super) {
1658
- __extends(FormAction, _super);
1659
- function FormAction(actionDefinition, formConfig) {
1359
+ var TableAction = /** @class */ (function () {
1360
+ function TableAction(actionDefinition) {
1361
+ var _a, _b;
1362
+ this.actionCode = actionDefinition.actionCode;
1363
+ this.actionTitle = actionDefinition.actionTitle;
1364
+ this.iconName = actionDefinition.iconName || this.actionCode;
1365
+ this.actionType = actionDefinition.actionType || 'STANDARD';
1366
+ this.actionClass = actionDefinition.actionClass || 'INLINE';
1367
+ this.newState = actionDefinition.newState;
1368
+ this.stateField = actionDefinition.stateField || '';
1369
+ this.visibleStates = actionDefinition.visibleStates || [];
1370
+ this.enabledStates = actionDefinition.enabledStates || [];
1371
+ this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
1372
+ this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
1373
+ this.restrictedOnValue = actionDefinition.valueRestricted || '';
1374
+ this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
1375
+ this.customAttributes = (_b = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _b !== void 0 ? _b : {};
1376
+ }
1377
+ TableAction.prototype.supportMode = function (state) { return this.viewOnState(state); };
1378
+ TableAction.prototype.viewOnState = function (state) { return this.visibleStates.includes(state); };
1379
+ TableAction.prototype.enabledOnState = function (state) { return this.enabledStates.includes(state); };
1380
+ return TableAction;
1381
+ }());
1382
+
1383
+ var TableRecordData = /** @class */ (function () {
1384
+ function TableRecordData(recordReceived, recordDefinition, selectionFieldName) {
1660
1385
  var _this = this;
1661
- var _a;
1662
- _this = _super.call(this, actionDefinition, formConfig) || this;
1663
- _this._actionActivated = new rxjs.Subject();
1664
- _this.inProgress = false;
1665
- _this.elementType = elementTypes.action;
1666
- _this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
1667
- _this.actionName = actionDefinition.actionTitle;
1668
- _this.iconName = actionDefinition.iconName || _this.actionCode;
1669
- _this.setCustomAttribute('location', actionDefinition.position || HEADER);
1670
- _this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
1671
- _this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
1672
- _this.restrictedOnField = actionDefinition.fieldRestrictedCode ? actionDefinition.fieldRestrictedCode.toString() : '';
1673
- _this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
1674
- _this.restrictedOnValue = actionDefinition.valueRestricted || '';
1675
- _this.customValidation = function () { return true; };
1676
- return _this;
1386
+ if (selectionFieldName === void 0) { selectionFieldName = null; }
1387
+ this.recordData = {};
1388
+ var tableRecordId = recordReceived.tableRecordId, recordData = recordReceived.recordData;
1389
+ this.recordId = tableRecordId;
1390
+ this.selected = false;
1391
+ this.recordData = {};
1392
+ if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
1393
+ return;
1394
+ }
1395
+ var fieldNames = recordDefinition.map(function (column) { return column.fieldCode; });
1396
+ if (Array.isArray(recordData)) {
1397
+ var rawRecordData = recordData.filter(function (fieldData) { return fieldData.fieldCode && fieldNames.includes(fieldData.fieldCode); });
1398
+ rawRecordData.forEach(function (fieldData) {
1399
+ var fieldCode = fieldData.fieldCode, fieldValue = fieldData.fieldValue;
1400
+ var fieldDef = recordDefinition.find(function (column) { return column.fieldCode === fieldCode; });
1401
+ _this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
1402
+ if (fieldCode === selectionFieldName) {
1403
+ _this.selected = fieldValue;
1404
+ }
1405
+ });
1406
+ }
1407
+ else {
1408
+ var fields = Object.keys(recordData);
1409
+ fields.forEach(function (fieldCode) {
1410
+ var fieldValue = recordData[fieldCode];
1411
+ var fieldDef = recordDefinition.find(function (column) { return column.fieldCode === fieldCode; });
1412
+ _this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
1413
+ });
1414
+ }
1677
1415
  }
1678
- Object.defineProperty(FormAction.prototype, "actionActivated", {
1679
- get: function () { return this._actionActivated; },
1416
+ TableRecordData.prototype.toggleSelect = function () { this.selected = !this.selected; };
1417
+ TableRecordData.prototype.select = function () { this.selected = true; };
1418
+ TableRecordData.prototype.unselect = function () { this.selected = false; };
1419
+ Object.defineProperty(TableRecordData.prototype, "recordIdKey", {
1420
+ get: function () {
1421
+ return (typeof this.recordId === 'object')
1422
+ ? JSON.stringify(this.recordId) : this.recordId;
1423
+ },
1680
1424
  enumerable: false,
1681
1425
  configurable: true
1682
1426
  });
1683
- FormAction.prototype.start = function () { this.inProgress = true; };
1684
- FormAction.prototype.stop = function () { this.inProgress = false; };
1685
- FormAction.prototype.notifyActivation = function () { this._actionActivated.next(this.actionCode); };
1686
- FormAction.prototype.updateFromServer = function (receivedAction) {
1687
- for (var propertyName in receivedAction) {
1688
- if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
1689
- this[propertyName] = receivedAction[propertyName];
1427
+ TableRecordData.prototype.getFieldValue = function (fieldCode) {
1428
+ return (fieldCode && this.recordData[fieldCode])
1429
+ ? this.recordData[fieldCode] : null;
1430
+ };
1431
+ TableRecordData.prototype.hasPattern = function (words) {
1432
+ var e_1, _a;
1433
+ if (!words || words.length === 0) {
1434
+ return true;
1435
+ }
1436
+ for (var fieldCode in this.recordData) {
1437
+ if (this.recordData.hasOwnProperty(fieldCode)) {
1438
+ try {
1439
+ for (var words_1 = (e_1 = void 0, __values(words)), words_1_1 = words_1.next(); !words_1_1.done; words_1_1 = words_1.next()) {
1440
+ var word = words_1_1.value;
1441
+ var term = word.toUpperCase();
1442
+ var fieldValue = this.recordData[fieldCode];
1443
+ if (fieldValue.toString().toUpperCase().includes(term)) {
1444
+ return true;
1445
+ }
1446
+ }
1447
+ }
1448
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1449
+ finally {
1450
+ try {
1451
+ if (words_1_1 && !words_1_1.done && (_a = words_1.return)) _a.call(words_1);
1452
+ }
1453
+ finally { if (e_1) throw e_1.error; }
1454
+ }
1690
1455
  }
1691
1456
  }
1457
+ return false;
1692
1458
  };
1693
- FormAction.prototype.setCustomValidation = function (callback) { this.customValidation = function () { return callback(); }; };
1694
- return FormAction;
1695
- }(FormElement));
1459
+ TableRecordData.prototype.hasCondition = function (columnFilters) {
1460
+ var e_2, _a;
1461
+ if (!columnFilters || columnFilters.length === 0) {
1462
+ return true;
1463
+ }
1464
+ try {
1465
+ for (var columnFilters_1 = __values(columnFilters), columnFilters_1_1 = columnFilters_1.next(); !columnFilters_1_1.done; columnFilters_1_1 = columnFilters_1.next()) {
1466
+ var condition = columnFilters_1_1.value;
1467
+ var fieldCode = condition.fieldCode, operator = condition.operator, values = condition.values;
1468
+ if (this.recordData.hasOwnProperty(fieldCode)) {
1469
+ var fieldValue = this.recordData[fieldCode];
1470
+ var stringValue = fieldValue.toString().toUpperCase();
1471
+ if (operator === operators.G && fieldValue <= values[0]) {
1472
+ return false;
1473
+ }
1474
+ if (operator === operators.L && fieldValue >= values[0]) {
1475
+ return false;
1476
+ }
1477
+ if (operator === operators.GE && fieldValue < values[0]) {
1478
+ return false;
1479
+ }
1480
+ if (operator === operators.LE && fieldValue > values[0]) {
1481
+ return false;
1482
+ }
1483
+ if (operator === operators.IN && !values.include(fieldValue)) {
1484
+ return false;
1485
+ }
1486
+ if (operator === operators.EQ) {
1487
+ return fieldValue === values[0];
1488
+ }
1489
+ if (operator === operators.NOT_EQ && fieldValue === values[0]) {
1490
+ return false;
1491
+ }
1492
+ if (operator === operators.CONTENT && !stringValue.includes(values[0].toString().toUpperCase())) {
1493
+ return false;
1494
+ }
1495
+ if (operator === operators.NOT_CONTENT && stringValue.includes(values[0].toString().toUpperCase())) {
1496
+ return false;
1497
+ }
1498
+ if (operator === operators.BETWEEN && (fieldValue < values[0] || fieldValue > values[1])) {
1499
+ return false;
1500
+ }
1501
+ }
1502
+ }
1503
+ }
1504
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1505
+ finally {
1506
+ try {
1507
+ if (columnFilters_1_1 && !columnFilters_1_1.done && (_a = columnFilters_1.return)) _a.call(columnFilters_1);
1508
+ }
1509
+ finally { if (e_2) throw e_2.error; }
1510
+ }
1511
+ return true;
1512
+ };
1513
+ return TableRecordData;
1514
+ }());
1696
1515
 
1697
- var UNDEFINED = 'undefined';
1698
- var DEFAULT_ERROR_TYPE = 'error';
1699
- var DEFAULT_CAPTURE_TYPE = 'INPUT';
1700
- var DEFAULT_ALIGNMENT = 'left';
1701
- var STD_MAX_LENGTH = 50;
1702
- var BIG_MAX_LENGTH = 500;
1703
- var fldAttr = {
1704
- validateOnServer: 'validateOnServer',
1705
- value: '_value',
1706
- minValue: '_minValue',
1707
- maxValue: '_maxValue',
1708
- maxLength: '_maxLength',
1709
- onValidation: '_onValidation',
1710
- focus: 'focus',
1711
- intrinsicErrorMessage: '_intrinsicErrorMessage',
1712
- code: 'fieldCode',
1713
- info: 'fieldInfo',
1714
- defaultValue: 'defaultValue',
1715
- defaultEditable: 'defaultEditable',
1716
- visibleLabel: 'visibleLabel',
1717
- required: 'fieldRequired',
1718
- hasChanged: 'hasChanged',
1719
- outputOnly: 'outputOnly',
1720
- captureType: 'captureType',
1721
- title: 'fieldTitle',
1722
- type: 'fieldType',
1723
- alignment: 'fieldAlignment',
1724
- format: 'fieldFormat',
1725
- externalValue: 'externalValue',
1726
- tooltipText: 'tooltipText',
1727
- errorType: 'errorType',
1728
- errorCode: 'errorCode',
1729
- errorMessage: 'errorMessage',
1730
- options: 'fieldOptions',
1731
- };
1732
- var FieldDescriptor = /** @class */ (function (_super) {
1733
- __extends(FieldDescriptor, _super);
1734
- function FieldDescriptor(inputFieldReceived, formConfig) {
1516
+ var TABLE_SORT_ASCENDING = 'asc';
1517
+ var TABLE_SORT_DESCENDING = 'desc';
1518
+ var RecordTable = /** @class */ (function (_super) {
1519
+ __extends(RecordTable, _super);
1520
+ function RecordTable(tableReceived, formConfig) {
1521
+ var e_1, _g, e_2, _h;
1735
1522
  var _this = this;
1736
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1737
- _this = _super.call(this, inputFieldReceived, formConfig) || this;
1738
- _this._editionFinish = new rxjs.Subject();
1739
- _this._editionPartial = new rxjs.Subject();
1740
- _this._detailRequest = new rxjs.Subject();
1523
+ var _a, _b, _c, _d, _e, _f;
1524
+ _this = _super.call(this, tableReceived, formConfig) || this;
1525
+ _this._inlineActionTrigger = new rxjs.Subject();
1526
+ _this._globalActionTrigger = new rxjs.Subject();
1527
+ _this._recordSelectionTrigger = new rxjs.Subject();
1528
+ _this._selectionActionTrigger = new rxjs.Subject();
1529
+ _this._getDataTrigger = new rxjs.Subject();
1741
1530
  _this._attributeChange = new rxjs.Subject();
1742
- _this.elementType = elementTypes.field;
1743
- var fld = (inputFieldReceived) ? inputFieldReceived : {};
1744
- _this.setAttr(fldAttr.code, fld.fieldCode);
1745
- _this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : _this.fieldCode);
1746
- _this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
1747
- _this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
1748
- var defaultTypeAlignment = (_this._formConfig.tableFieldStyles[_this.fieldType] != null)
1749
- ? _this._formConfig.tableFieldStyles[_this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
1750
- var fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
1751
- _this.setAttr(fldAttr.alignment, fieldAlignment);
1752
- _this.setAttr(fldAttr.info, fld.info || '');
1753
- var fieldFormat;
1754
- try {
1755
- fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
1531
+ _this._tableColumnObj = {};
1532
+ _this._actionsObj = {};
1533
+ // Mecanismos de filtrado nueva versión
1534
+ _this.globalFilterStrings = [];
1535
+ _this.tableRecordObj = {};
1536
+ _this.allSelected = false;
1537
+ _this.elementType = elementTypes.table;
1538
+ _this.waiting = false;
1539
+ _this.currentPage = 1;
1540
+ _this.totalPages = 1;
1541
+ _this.requestedPage = 1;
1542
+ _this.columns = [];
1543
+ _this._tableColumnObj = {};
1544
+ _this._actions = [];
1545
+ _this._actionsObj = {};
1546
+ _this.tableRecords = [];
1547
+ _this.globalSearch = false;
1548
+ _this.tableTitle = tableReceived.tableTitle;
1549
+ _this._appendPages = (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _a !== void 0 ? _a : false;
1550
+ _this.selectable = (_b = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _b !== void 0 ? _b : false;
1551
+ _this.setAttr('allSelected', false);
1552
+ _this.setAttr('tableCode', tableReceived.tableCode);
1553
+ _this.setAttr('clientPaging', (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _c !== void 0 ? _c : true);
1554
+ _this.setAttr('globalSearch', (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _d !== void 0 ? _d : false);
1555
+ _this.setAttr('selectionBackend', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _e !== void 0 ? _e : false);
1556
+ _this.setAttr('sortable', (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _f !== void 0 ? _f : false);
1557
+ _this.setAttr('sorting', { columnName: '', direction: '' });
1558
+ _this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
1559
+ if (tableReceived.fields) {
1560
+ var columns = [];
1561
+ try {
1562
+ for (var _j = __values(tableReceived.fields), _k = _j.next(); !_k.done; _k = _j.next()) {
1563
+ var columnReceived = _k.value;
1564
+ var columnDefinition = new RecordTableColumn(columnReceived, _this._formConfig);
1565
+ columns.push(columnDefinition);
1566
+ _this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
1567
+ }
1568
+ }
1569
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1570
+ finally {
1571
+ try {
1572
+ if (_k && !_k.done && (_g = _j.return)) _g.call(_j);
1573
+ }
1574
+ finally { if (e_1) throw e_1.error; }
1575
+ }
1576
+ _this.setAttr('columns', columns);
1756
1577
  }
1757
- catch (e) {
1758
- fieldFormat = null;
1578
+ if (tableReceived.actions) {
1579
+ var tableActions = tableReceived.actions.map(function (objDef) {
1580
+ var visibleStates = objDef.visibleStates;
1581
+ var enabledStates = objDef.enabledStates;
1582
+ if (!visibleStates) {
1583
+ visibleStates = (objDef.actionModes || '').split(',')
1584
+ .map(function (state) { return state.trim(); })
1585
+ .filter(function (state) { return state.length > 0; });
1586
+ enabledStates = (objDef.actionModes || '').split(',')
1587
+ .map(function (state) { return state.trim(); })
1588
+ .filter(function (state) { return state.length > 0; });
1589
+ }
1590
+ return Object.assign(Object.assign({}, objDef), { visibleStates: visibleStates, enabledStates: enabledStates });
1591
+ });
1592
+ try {
1593
+ for (var tableActions_1 = __values(tableActions), tableActions_1_1 = tableActions_1.next(); !tableActions_1_1.done; tableActions_1_1 = tableActions_1.next()) {
1594
+ var actionReceived = tableActions_1_1.value;
1595
+ var inlineAction = new TableAction(actionReceived);
1596
+ _this._actions.push(inlineAction);
1597
+ _this._actionsObj[inlineAction.actionCode] = inlineAction;
1598
+ }
1599
+ }
1600
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1601
+ finally {
1602
+ try {
1603
+ if (tableActions_1_1 && !tableActions_1_1.done && (_h = tableActions_1.return)) _h.call(tableActions_1);
1604
+ }
1605
+ finally { if (e_2) throw e_2.error; }
1606
+ }
1607
+ }
1608
+ _this.selectionField = (_this.selectable) ? tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionField : null;
1609
+ // Filtros predefinidos en el formulario
1610
+ if (tableReceived.filters) {
1611
+ for (var index = 0; index < tableReceived.filters.length; index++) {
1612
+ _this.addFilterDefinition(tableReceived.filters[index]);
1613
+ }
1759
1614
  }
1760
- _this.setAttr(fldAttr.format, fieldFormat);
1761
- _this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
1762
- _this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
1763
- _this.setAttr(fldAttr.defaultEditable, _this.enabled);
1764
- _this.setAttr(fldAttr.required, (_e = fld.required) !== null && _e !== void 0 ? _e : false);
1765
- _this.setError(fld.errorCode, fld.errorMessage, (_f = fld.errorType) !== null && _f !== void 0 ? _f : DEFAULT_ERROR_TYPE);
1766
- _this.setAttr(fldAttr.outputOnly, (_g = fld.outputOnly) !== null && _g !== void 0 ? _g : false);
1767
- var maxLength = (_h = fld.maxLength) !== null && _h !== void 0 ? _h : (_this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1768
- _this.setAttr(fldAttr.maxLength, maxLength);
1769
- _this.setAttr(fldAttr.intrinsicErrorMessage, (_j = _this._formConfig.fieldTypeErrMsg[_this.fieldType]) !== null && _j !== void 0 ? _j : _this._formConfig.fieldTypeErrMsg.DEFAULT);
1770
- _this.setFieldType(fld.fieldTypeCode);
1771
- _this.setEditable((_k = fld.editable) !== null && _k !== void 0 ? _k : true);
1772
- _this.setVisibleLabel((_l = fld.visibleLabel) !== null && _l !== void 0 ? _l : true);
1773
- _this.setVisibility(fld.visible);
1774
- _this.setFieldOptions(fld.fieldOptions);
1775
- _this.setValue(fld.fieldValue || _this.defaultValue || '');
1776
1615
  return _this;
1777
1616
  }
1778
- Object.defineProperty(FieldDescriptor.prototype, "name", {
1779
- get: function () { return this.fieldCode; },
1780
- enumerable: false,
1781
- configurable: true
1782
- });
1783
- Object.defineProperty(FieldDescriptor.prototype, "editionFinish", {
1784
- get: function () { return this._editionFinish; },
1785
- enumerable: false,
1786
- configurable: true
1787
- });
1788
- Object.defineProperty(FieldDescriptor.prototype, "attributeChange", {
1789
- get: function () { return this._attributeChange; },
1790
- enumerable: false,
1791
- configurable: true
1792
- });
1793
- Object.defineProperty(FieldDescriptor.prototype, "editionPartial", {
1794
- get: function () { return this._editionPartial; },
1617
+ Object.defineProperty(RecordTable.prototype, "columnNames", {
1618
+ get: function () { return Object.keys(this._tableColumnObj); },
1795
1619
  enumerable: false,
1796
1620
  configurable: true
1797
1621
  });
1798
- Object.defineProperty(FieldDescriptor.prototype, "detailRequest", {
1799
- get: function () { return this._detailRequest; },
1622
+ Object.defineProperty(RecordTable.prototype, "inlineActionTrigger", {
1623
+ get: function () { return this._inlineActionTrigger; },
1800
1624
  enumerable: false,
1801
1625
  configurable: true
1802
1626
  });
1803
- Object.defineProperty(FieldDescriptor.prototype, "info", {
1804
- get: function () { return this.fieldInfo; },
1627
+ Object.defineProperty(RecordTable.prototype, "globalActionTrigger", {
1628
+ get: function () { return this._globalActionTrigger; },
1805
1629
  enumerable: false,
1806
1630
  configurable: true
1807
1631
  });
1808
- Object.defineProperty(FieldDescriptor.prototype, "validating", {
1809
- get: function () { return this._onValidation; },
1810
- set: function (isValidating) { this.setAttr(fldAttr.onValidation, isValidating); },
1632
+ Object.defineProperty(RecordTable.prototype, "selectionActionTrigger", {
1633
+ get: function () { return this._selectionActionTrigger; },
1811
1634
  enumerable: false,
1812
1635
  configurable: true
1813
1636
  });
1814
- FieldDescriptor.prototype.focus = function () { this.setAttr(fldAttr.focus, true); };
1815
- FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); };
1816
- Object.defineProperty(FieldDescriptor.prototype, "intrinsicErrorMessage", {
1817
- set: function (message) { this.setIntrinsicErrorMessage(message); },
1637
+ Object.defineProperty(RecordTable.prototype, "recordSelectionTrigger", {
1638
+ get: function () { return this._recordSelectionTrigger; },
1818
1639
  enumerable: false,
1819
1640
  configurable: true
1820
1641
  });
1821
- Object.defineProperty(FieldDescriptor.prototype, "fieldValue", {
1822
- get: function () { return this.getValue(); },
1642
+ Object.defineProperty(RecordTable.prototype, "getDataTrigger", {
1643
+ get: function () { return this._getDataTrigger; },
1823
1644
  enumerable: false,
1824
1645
  configurable: true
1825
1646
  });
1826
- FieldDescriptor.prototype.getRequired = function () { return this.required; };
1827
- FieldDescriptor.prototype.setRequired = function (required) { this.required = required; };
1828
- Object.defineProperty(FieldDescriptor.prototype, "required", {
1829
- get: function () { return this.fieldRequired; },
1830
- set: function (required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); },
1647
+ Object.defineProperty(RecordTable.prototype, "attributeChange", {
1648
+ get: function () { return this._attributeChange; },
1831
1649
  enumerable: false,
1832
1650
  configurable: true
1833
1651
  });
1834
- Object.defineProperty(FieldDescriptor.prototype, "maxLength", {
1835
- get: function () { return (this._maxLength > 0) ? this._maxLength.toString() : ''; },
1836
- set: function (requiredMaxLength) {
1837
- if (typeof requiredMaxLength === 'string') {
1838
- this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
1652
+ RecordTable.prototype.hasActions = function () { return (this._actions.length > 0); };
1653
+ RecordTable.prototype.getSelectedRecords = function () { return this.tableRecords.filter(function (rec) { return rec.selected; }).map(function (rec) { return rec.recordId; }); };
1654
+ RecordTable.prototype.activateGlobalSearch = function () { this.globalSearch = true; };
1655
+ RecordTable.prototype.inactivateGlobalSearch = function () { this.globalSearch = false; };
1656
+ RecordTable.prototype.columnDefinition = function (fieldCode) { return this._tableColumnObj[fieldCode]; };
1657
+ RecordTable.prototype.putOnWait = function () { this.waiting = true; };
1658
+ RecordTable.prototype.freeWaiting = function () { this.waiting = false; };
1659
+ RecordTable.prototype.setAttr = function (name, value) {
1660
+ this[name] = value;
1661
+ if (this._formConfig.monitoredTableAttributes.includes(name)) {
1662
+ this._attributeChange.next({ name: name, value: value });
1663
+ }
1664
+ };
1665
+ RecordTable.prototype.notifyGlobalAction = function (actionCode) {
1666
+ var tableEvent = {
1667
+ tableCode: this.tableCode,
1668
+ actionCode: actionCode,
1669
+ actionDetail: null
1670
+ };
1671
+ this._globalActionTrigger.next(tableEvent);
1672
+ };
1673
+ RecordTable.prototype.notifyInlineAction = function (tableActionEvent) {
1674
+ var tableEvent = {
1675
+ tableCode: this.tableCode,
1676
+ actionCode: tableActionEvent.actionCode,
1677
+ actionDetail: {
1678
+ recordId: tableActionEvent.recordId,
1679
+ recordData: tableActionEvent.recordData
1839
1680
  }
1840
- else if (typeof requiredMaxLength === 'number') {
1841
- this.setAttr(fldAttr.maxLength, requiredMaxLength);
1681
+ };
1682
+ this._inlineActionTrigger.next(tableEvent);
1683
+ };
1684
+ RecordTable.prototype.notifyRecordSelection = function (recordId) {
1685
+ var record = this.getTableRecord(recordId);
1686
+ if (!record) {
1687
+ return;
1688
+ }
1689
+ record.toggleSelect();
1690
+ var tableEvent = {
1691
+ tableCode: this.tableCode,
1692
+ actionCode: null,
1693
+ actionDetail: {
1694
+ recordId: record.recordId,
1695
+ recordData: record.recordData
1842
1696
  }
1843
- },
1844
- enumerable: false,
1845
- configurable: true
1846
- });
1847
- Object.defineProperty(FieldDescriptor.prototype, "value", {
1848
- get: function () { return this.getValue(); },
1849
- set: function (newValue) { this.setValue(newValue); },
1850
- enumerable: false,
1851
- configurable: true
1852
- });
1853
- FieldDescriptor.prototype.notifyEditionPartial = function () {
1854
- var intrinsicValidation = true;
1855
- this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
1697
+ };
1698
+ this.recordSelectionTrigger.next(tableEvent);
1856
1699
  };
1857
- FieldDescriptor.prototype.notifyEditionFinish = function () {
1858
- var _a, _b, _c, _d, _e;
1859
- var intrinsicValidation = true;
1860
- var fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
1861
- var fieldValue = this.getValue();
1862
- if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
1863
- intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
1864
- && ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
1865
- if (!intrinsicValidation) {
1866
- this.setError('99', this._intrinsicErrorMessage);
1700
+ RecordTable.prototype.notifySelectionAction = function (actionCode) {
1701
+ var tableEvent = {
1702
+ tableCode: this.tableCode,
1703
+ actionCode: actionCode,
1704
+ actionDetail: {
1705
+ selectedRecords: this.selectedRecords
1706
+ }
1707
+ };
1708
+ this._selectionActionTrigger.next(tableEvent);
1709
+ };
1710
+ RecordTable.prototype.notifyGetDataAction = function (requestedPage) {
1711
+ if (requestedPage === void 0) { requestedPage = null; }
1712
+ this.updateVisibleRecords();
1713
+ this.requestedPage = requestedPage || this.currentPage;
1714
+ var tableEvent = {
1715
+ tableCode: this.tableCode,
1716
+ actionCode: null,
1717
+ actionDetail: null,
1718
+ };
1719
+ this._getDataTrigger.next(tableEvent);
1720
+ return null;
1721
+ };
1722
+ RecordTable.prototype.clean = function () {
1723
+ this.visibleRecords = [];
1724
+ this.tableRecords = [];
1725
+ this.unSelectAll();
1726
+ this.tableRecordObj = {};
1727
+ };
1728
+ RecordTable.prototype.selectAll = function () {
1729
+ this.setAttr('allSelected', true);
1730
+ this.tableRecords.forEach(function (record) { return record.select(); });
1731
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1732
+ return true;
1733
+ };
1734
+ RecordTable.prototype.unSelectAll = function () {
1735
+ this.setAttr('allSelected', false);
1736
+ this.tableRecords.forEach(function (record) { return record.unselect(); });
1737
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1738
+ return true;
1739
+ };
1740
+ RecordTable.prototype.setTableRecords = function (tableRecords, append) {
1741
+ var e_3, _g;
1742
+ if (!append) {
1743
+ this.clean();
1744
+ }
1745
+ var newRecordsObj = Object.assign({}, this.tableRecordObj);
1746
+ var newRecords = __spreadArray([], __read(this.tableRecords));
1747
+ try {
1748
+ for (var tableRecords_1 = __values(tableRecords), tableRecords_1_1 = tableRecords_1.next(); !tableRecords_1_1.done; tableRecords_1_1 = tableRecords_1.next()) {
1749
+ var tableRecord = tableRecords_1_1.value;
1750
+ var recordReceived = new TableRecordData(tableRecord, this.columns, this.selectionField);
1751
+ var recordIdKey = recordReceived.recordIdKey;
1752
+ newRecords.push(recordReceived);
1753
+ newRecordsObj[recordIdKey] = recordReceived;
1867
1754
  }
1868
1755
  }
1869
- if (intrinsicValidation && fieldValue && this._minValue && fieldValue < this._minValue) {
1870
- intrinsicValidation = false;
1871
- this.setError('99', 'Campo con valor inferior al mínimo');
1756
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1757
+ finally {
1758
+ try {
1759
+ if (tableRecords_1_1 && !tableRecords_1_1.done && (_g = tableRecords_1.return)) _g.call(tableRecords_1);
1760
+ }
1761
+ finally { if (e_3) throw e_3.error; }
1762
+ }
1763
+ this.tableRecords = newRecords;
1764
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1765
+ this.tableRecordObj = newRecordsObj;
1766
+ this.updateVisibleRecords();
1767
+ };
1768
+ RecordTable.prototype.appendRecords = function (records) { this.setTableRecords(records, true); };
1769
+ RecordTable.prototype.replaceRecords = function (records) { this.setTableRecords(records, false); };
1770
+ RecordTable.prototype.updateVisibleRecords = function () {
1771
+ var _a;
1772
+ if (!this.clientPaging || !this.tableRecords || ((_a = this.tableRecords) === null || _a === void 0 ? void 0 : _a.length) === 0) {
1773
+ this.setAttr('visibleRecords', this.tableRecords);
1872
1774
  }
1873
- if (intrinsicValidation && fieldValue && this._maxValue && fieldValue > this._maxValue) {
1874
- intrinsicValidation = false;
1875
- this.setError('99', 'Campo con valor superior al máximo');
1775
+ else {
1776
+ this.setAttr('visibleRecords', this.getFilteredRecords());
1876
1777
  }
1877
- this._editionFinish.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
1878
1778
  };
1879
- FieldDescriptor.prototype.setAttr = function (name, value) {
1880
- this[name] = value;
1881
- if (this._formConfig.monitoredFieldAttributes.includes(name)) {
1882
- this._attributeChange.next({ name: name, value: value });
1779
+ RecordTable.prototype.updateFromServer = function (tableReceived) {
1780
+ var _a;
1781
+ this.requestedPage = 1;
1782
+ this.clean();
1783
+ this.visible = (tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.visible) || true;
1784
+ this.totalPages = tableReceived.totalPages || 1;
1785
+ this.recordsNumber = tableReceived.recordsNumber;
1786
+ this.setAttr('currentPage', (_a = +(tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.currentPage)) !== null && _a !== void 0 ? _a : 1);
1787
+ this.setAttr('recordsPerPage', +tableReceived.recordsPerPage);
1788
+ this.setAttr('totalRecordsNumber', +tableReceived.totalRecordsNumber);
1789
+ this.setAttr('sorting', {
1790
+ columnName: tableReceived.sortingColumn || '',
1791
+ direction: tableReceived.sortingDirection || ''
1792
+ });
1793
+ this.waiting = false;
1794
+ if (this._appendPages) {
1795
+ this.replaceRecords(tableReceived.tableRecords);
1796
+ }
1797
+ else {
1798
+ this.appendRecords(tableReceived.tableRecords);
1883
1799
  }
1800
+ this.updateVisibleRecords();
1884
1801
  };
1885
- FieldDescriptor.prototype.notifyEditionDetailRequest = function (detail) {
1886
- var detailEvent = {
1887
- code: this.fieldCode,
1888
- detail: detail,
1889
- };
1890
- this._detailRequest.next(detailEvent);
1802
+ RecordTable.prototype.getTableRecord = function (recordId) {
1803
+ var recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
1804
+ return (this.tableRecordObj && recordId && this.tableRecordObj[recordId])
1805
+ ? this.tableRecordObj[recordId] : null;
1891
1806
  };
1892
- FieldDescriptor.prototype.setVisibleLabel = function (visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); };
1893
- FieldDescriptor.prototype.showLabel = function () { this.setVisibleLabel(true); };
1894
- FieldDescriptor.prototype.hideLabel = function () { this.setVisibleLabel(false); };
1895
- FieldDescriptor.prototype.setChanged = function (hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); };
1896
- FieldDescriptor.prototype.changed = function () { this.setChanged(true); };
1897
- FieldDescriptor.prototype.setLabel = function (label) { this.setAttr(fldAttr.title, label); };
1898
- FieldDescriptor.prototype.clean = function () { this.setValue(this.defaultValue || ''); this.resetError(); };
1899
- Object.defineProperty(FieldDescriptor.prototype, "backend", {
1900
- get: function () { return this.validateOnServer; },
1901
- enumerable: false,
1902
- configurable: true
1903
- });
1904
- FieldDescriptor.prototype.setEditable = function (editable) {
1905
- if (editable === void 0) { editable = true; }
1906
- (editable) ? this.enable() : this.disable();
1807
+ RecordTable.prototype.getAction = function (actionCode) {
1808
+ return (this._actionsObj && actionCode && this._actionsObj[actionCode])
1809
+ ? this._actionsObj[actionCode] : null;
1907
1810
  };
1908
- FieldDescriptor.prototype.hasError = function () { return this.errorCode !== NO_ERROR; };
1909
- FieldDescriptor.prototype.resetError = function () { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); };
1910
- FieldDescriptor.prototype.setError = function (code, message, type) {
1911
- if (type === void 0) { type = DEFAULT_ERROR_TYPE; }
1912
- this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
1913
- this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
1914
- this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
1811
+ RecordTable.prototype.getActions = function (actionClass, actionTypes) {
1812
+ if (actionClass === void 0) { actionClass = this._formConfig.tableActions.inline; }
1813
+ if (actionTypes === void 0) { actionTypes = null; }
1814
+ return this._actions.filter(function (actionDef) {
1815
+ var typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
1816
+ return actionDef.actionClass === actionClass && typeIncluded;
1817
+ });
1915
1818
  };
1916
- FieldDescriptor.prototype.getError = function () { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; };
1917
- Object.defineProperty(FieldDescriptor.prototype, "error", {
1918
- get: function () { return this.getError(); },
1919
- set: function (errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); },
1920
- enumerable: false,
1921
- configurable: true
1922
- });
1923
- FieldDescriptor.prototype.getErrorCode = function () { return this.getError().code; };
1924
- FieldDescriptor.prototype.setErrorCode = function (code) { this.setError(code, this.errorMessage); };
1925
- FieldDescriptor.prototype.getErrorMessage = function () { return this.getError().message; };
1926
- FieldDescriptor.prototype.setErrorMessage = function (msg) { this.setError(this.errorCode, msg); };
1927
- Object.defineProperty(FieldDescriptor.prototype, "empty", {
1928
- get: function () { return this.isEmpty(); },
1929
- enumerable: false,
1930
- configurable: true
1931
- });
1932
- FieldDescriptor.prototype.isEmpty = function () {
1933
- var fieldCurrentValue = this.getValue();
1934
- if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
1935
- return true;
1936
- }
1937
- if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
1938
- && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
1939
- return true;
1940
- }
1941
- ;
1942
- return fieldCurrentValue === '';
1819
+ // Filtros
1820
+ RecordTable.prototype.setGlobalFilterString = function (text) {
1821
+ var _a;
1822
+ this.globalFilterStrings = (_a = text.split(' ').filter(function (t) { return t && t.trim().length > 0; }).map(function (t) { return t.trim(); })) !== null && _a !== void 0 ? _a : [];
1943
1823
  };
1944
- FieldDescriptor.prototype.getValue = function () {
1945
- if (this.fieldType === this._formConfig.fieldTypes.boolean
1946
- || this.fieldType === this._formConfig.fieldTypes.check) {
1947
- return yn__default['default'](this._value);
1948
- }
1949
- return this._value;
1824
+ RecordTable.prototype.addFilterDefinition = function (filterDefinition) {
1825
+ var tableColumn = this.columnDefinition(filterDefinition.fieldCode);
1826
+ tableColumn && tableColumn.addFilterDefinition(filterDefinition);
1950
1827
  };
1951
- FieldDescriptor.prototype.getOptionText = function () {
1828
+ RecordTable.prototype.getFilteredRecords = function () {
1952
1829
  var _this = this;
1953
- var _a, _b, _c;
1954
- return (_c = (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.fieldOptionId === _this._value; })) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null;
1830
+ var filteredRecords = this.tableRecords;
1831
+ if (this.globalFilterStrings.length > 0) {
1832
+ filteredRecords = filteredRecords.filter(function (record) { return record.hasPattern(_this.globalFilterStrings); });
1833
+ }
1834
+ var columnFilters = this.columns.filter(function (column) { return column.filter; }).map(function (column) { return column.filter; });
1835
+ if (columnFilters.length > 0) {
1836
+ filteredRecords = filteredRecords.filter(function (record) { return record.hasCondition(columnFilters); });
1837
+ }
1838
+ return filteredRecords;
1955
1839
  };
1956
- FieldDescriptor.prototype.updateFromServer = function (fld) {
1840
+ RecordTable.prototype.addColumnFilter = function (columnName, columnValues, operator) {
1841
+ if (operator === void 0) { operator = null; }
1957
1842
  var _a;
1958
- var fieldKeys = Object.keys(fld);
1959
- for (var index = 0; index < fieldKeys.length; index++) {
1960
- var attrName = fieldKeys[index];
1961
- var attrValue = fld[attrName];
1962
- (attrName === this._formConfig.apiFieldAttrs.visible) && this.setVisibility(attrValue);
1963
- (attrName === this._formConfig.apiFieldAttrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
1964
- (attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
1965
- (attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
1966
- (attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
1967
- (attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
1968
- (attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
1969
- (attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
1970
- (attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
1971
- (attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
1972
- (attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
1973
- (attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
1974
- (attrName === this._formConfig.apiFieldAttrs.type) && this.setFieldType(fld.fieldTypeCode);
1975
- (attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
1843
+ var tableColumn = this.columnDefinition(columnName);
1844
+ var columnFilterDefinition = (_a = tableColumn === null || tableColumn === void 0 ? void 0 : tableColumn.filterDefinition) !== null && _a !== void 0 ? _a : null;
1845
+ if (!columnFilterDefinition) {
1846
+ return null;
1976
1847
  }
1848
+ tableColumn && tableColumn.addFilter(columnValues, operator);
1849
+ this.updateVisibleRecords();
1977
1850
  };
1978
- FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
1979
- this.setAttr(fldAttr.type, inputFieldType);
1851
+ RecordTable.prototype.removeColumnFilter = function (columnName) {
1852
+ var tableColumn = this.columnDefinition(columnName);
1853
+ tableColumn && tableColumn.removeFilter();
1854
+ this.updateVisibleRecords();
1980
1855
  };
1981
- FieldDescriptor.prototype.setMinValue = function (inputMinValue) {
1982
- var minValue = inputMinValue;
1983
- if (this.fieldType === this._formConfig.fieldTypes.date) {
1984
- minValue = new Date(minValue);
1856
+ Object.defineProperty(RecordTable.prototype, "currentFilter", {
1857
+ get: function () {
1858
+ var compactFilter = {
1859
+ simpleFilterWords: this.globalFilterStrings,
1860
+ advancedFilter: [],
1861
+ };
1862
+ var columnFilters = this.columns.filter(function (column) { return column.filter; }).map(function (column) { return column.filter; });
1863
+ for (var index = 0; index < columnFilters.length; index++) {
1864
+ var columnFilter = columnFilters[index];
1865
+ compactFilter.advancedFilter.push({
1866
+ fieldCode: columnFilter.fieldCode,
1867
+ operator: columnFilter.operator,
1868
+ fieldValue1: columnFilter.values[0],
1869
+ fieldValue2: columnFilter.values[1],
1870
+ });
1871
+ }
1872
+ return compactFilter;
1873
+ },
1874
+ enumerable: false,
1875
+ configurable: true
1876
+ });
1877
+ // Ordenamiento de registros local
1878
+ RecordTable.prototype.setRequiredOrder = function (columnField) {
1879
+ if (columnField !== this.sorting.columnName) {
1880
+ this.setAttr('sorting', {
1881
+ columnName: columnField,
1882
+ direction: TABLE_SORT_ASCENDING
1883
+ });
1985
1884
  }
1986
- this.setAttr(fldAttr.minValue, minValue);
1987
- };
1988
- FieldDescriptor.prototype.setMaxValue = function (inputMaxValue) {
1989
- var maxValue = inputMaxValue;
1990
- if (this.fieldType === this._formConfig.fieldTypes.date) {
1991
- maxValue = new Date(maxValue);
1885
+ else {
1886
+ var tableSort = this.sorting;
1887
+ tableSort.direction = (tableSort.direction === TABLE_SORT_ASCENDING) ? TABLE_SORT_DESCENDING : TABLE_SORT_ASCENDING;
1888
+ this.setAttr('sorting', tableSort);
1992
1889
  }
1993
- this.setAttr(fldAttr.maxValue, maxValue);
1994
- };
1995
- FieldDescriptor.prototype.getFieldOptions = function () {
1996
- return this.fieldOptions.map(function (option) {
1997
- var optionCopy = Object.assign({}, option);
1998
- return optionCopy;
1999
- });
2000
1890
  };
2001
- FieldDescriptor.prototype.setFieldOptions = function (newOptions) {
1891
+ RecordTable.prototype.localSortData = function () {
2002
1892
  var _this = this;
2003
- var _a;
2004
- if ((this.captureType !== 'LIST' && this.captureType !== 'RADIO')
2005
- || typeof newOptions === UNDEFINED || !newOptions
2006
- || !Array.isArray(newOptions)) {
1893
+ if (!this.sorting.columnName || !this.sorting.direction) {
2007
1894
  return;
2008
1895
  }
2009
- var fieldOptions = newOptions.map(function (option) {
2010
- if (option.text !== undefined && option.text !== null
2011
- && option.value !== undefined && option.value !== null) {
2012
- return { fieldOptionValue: option.text, fieldOptionId: option.value };
2013
- }
2014
- return Object.assign({}, option);
2015
- });
2016
- fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
2017
- && fieldOptions.length > 0) ? fieldOptions : [];
2018
- this.setAttr(fldAttr.options, fieldOptions);
2019
- if (this._value) {
2020
- if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
2021
- var fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
2022
- this.setAttr(fldAttr.value, fieldValue);
2023
- }
2024
- else {
2025
- var valInOptions = this.fieldOptions
2026
- .find(function (item) { return item.fieldOptionId === _this._value; });
2027
- if (!valInOptions) {
2028
- this.setValue('');
2029
- }
2030
- }
2031
- }
2032
- if (this.fieldRequired && this.fieldOptions.length === 1) {
2033
- this.setValue(this.fieldOptions[0].fieldOptionId);
2034
- }
1896
+ this.tableRecords.sort(function (a, b) { return _this.recordCompare(a, b, _this.sorting.columnName, _this.sorting.direction); });
1897
+ this.unSelectAll();
1898
+ this.updateVisibleRecords();
2035
1899
  };
2036
- FieldDescriptor.prototype.setValue = function (newValue, widgetUpdate) {
2037
- if (widgetUpdate === void 0) { widgetUpdate = true; }
2038
- if (typeof newValue === UNDEFINED || newValue === null) {
2039
- return true;
2040
- }
2041
- var newFinalValue;
2042
- if (this.fieldType === this._formConfig.fieldTypes.boolean
2043
- || this.fieldType === this._formConfig.fieldTypes.check) {
2044
- newFinalValue = yn__default['default'](newValue);
2045
- }
2046
- else if (this.fieldType === this._formConfig.fieldTypes.array
2047
- || this.fieldType === this._formConfig.fieldTypes.map) {
2048
- if (newValue === null || newValue === '') {
2049
- newFinalValue = [];
2050
- }
2051
- else if (Array.isArray(newValue)) {
2052
- newFinalValue = newValue;
2053
- }
2054
- else {
2055
- newFinalValue = newValue.toString().split(',');
2056
- }
2057
- }
2058
- else {
2059
- newFinalValue = newValue;
1900
+ RecordTable.prototype.recordCompare = function (recordA, recordB, columnCompare, direction) {
1901
+ var recordAColumn = recordA.getFieldValue(columnCompare);
1902
+ var recordBColumn = recordB.getFieldValue(columnCompare);
1903
+ var result = 0;
1904
+ if (recordAColumn < recordBColumn) {
1905
+ result = -1;
2060
1906
  }
2061
- if (this._value !== newFinalValue) {
2062
- this.setChanged(true);
2063
- if (widgetUpdate) {
2064
- this.setAttr(fldAttr.value, newFinalValue);
2065
- }
2066
- else {
2067
- this._value = newFinalValue;
2068
- }
1907
+ else if (recordAColumn > recordBColumn) {
1908
+ result = 1;
2069
1909
  }
2070
- return true;
1910
+ return direction === TABLE_SORT_ASCENDING ? result : -result;
2071
1911
  };
2072
- return FieldDescriptor;
1912
+ return RecordTable;
2073
1913
  }(FormElement));
2074
1914
 
2075
1915
  var RecordFormSubSection = /** @class */ (function () {
@@ -5005,7 +4845,6 @@
5005
4845
  FormHeaderComponent,
5006
4846
  SectionComponent,
5007
4847
  SubSectionComponent,
5008
- LibTableFilterComponent,
5009
4848
  LibTableRecordActionComponent,
5010
4849
  LibTableRecordFieldComponent,
5011
4850
  LibTableComponent
@@ -5041,7 +4880,6 @@
5041
4880
  exports.LibFileManagementService = LibFileManagementService;
5042
4881
  exports.LibFormManagerService = LibFormManagerService;
5043
4882
  exports.LibTableComponent = LibTableComponent;
5044
- exports.LibTableFilterComponent = LibTableFilterComponent;
5045
4883
  exports.LibTableRecordActionComponent = LibTableRecordActionComponent;
5046
4884
  exports.LibTableRecordFieldComponent = LibTableRecordFieldComponent;
5047
4885
  exports.SectionComponent = SectionComponent;