tuain-ng-forms-lib 12.0.52 → 12.0.57

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