tnx-shared 5.1.202 → 5.1.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tnx-shared.umd.js +201 -110
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/classes/form-schema.d.ts +2 -0
- package/classes/form-schema.d.ts.map +1 -1
- package/components/dropdown/dropdown.component.d.ts +12 -4
- package/components/dropdown/dropdown.component.d.ts.map +1 -1
- package/esm2015/classes/form-schema.js +3 -1
- package/esm2015/components/dropdown/dropdown.component.js +134 -55
- package/esm2015/services/base.service.js +39 -36
- package/esm2015/services/crud.service.js +2 -2
- package/esm2015/services/master-data.service.js +1 -1
- package/fesm2015/tnx-shared.js +174 -89
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +3 -3
- package/services/base.service.d.ts +3 -0
- package/services/base.service.d.ts.map +1 -1
- package/services/master-data.service.d.ts.map +1 -1
- package/tnx-shared.metadata.json +1 -1
|
@@ -4186,6 +4186,7 @@
|
|
|
4186
4186
|
_this.multiple = false;
|
|
4187
4187
|
_this.maxSelectedLabels = 5;
|
|
4188
4188
|
_this.maxItemDisplay = 50;
|
|
4189
|
+
_this.fitPanel = true;
|
|
4189
4190
|
_this.enableCaching = true;
|
|
4190
4191
|
_this.needClone = false; // Sử dụng trong table schema, khi datasource của một cột trên mỗi dòng là khác nhau cần set needClone = true
|
|
4191
4192
|
_this.quickAdd = false;
|
|
@@ -4397,6 +4398,7 @@
|
|
|
4397
4398
|
this.sortField = '';
|
|
4398
4399
|
this.sortDir = 1;
|
|
4399
4400
|
this.fieldPlus = '';
|
|
4401
|
+
this.page = 1;
|
|
4400
4402
|
this.pageSize = 666;
|
|
4401
4403
|
this.isServerLoad = false;
|
|
4402
4404
|
this.refFields = [];
|
|
@@ -5786,7 +5788,7 @@
|
|
|
5786
5788
|
});
|
|
5787
5789
|
if (result.isServerLoad) {
|
|
5788
5790
|
result.pageSize = schema.pageSize;
|
|
5789
|
-
// result.pageSize =
|
|
5791
|
+
// result.pageSize = 2;
|
|
5790
5792
|
}
|
|
5791
5793
|
return result;
|
|
5792
5794
|
};
|
|
@@ -6775,15 +6777,19 @@
|
|
|
6775
6777
|
BaseService.prototype.generateGridInfoDropdown = function (filters, options) {
|
|
6776
6778
|
var gridInfo = {
|
|
6777
6779
|
pageInfo: {
|
|
6778
|
-
page:
|
|
6780
|
+
page: options.page,
|
|
6779
6781
|
pageSize: options.pageSize
|
|
6780
6782
|
},
|
|
6781
6783
|
filters: filters,
|
|
6782
6784
|
sorts: [],
|
|
6783
6785
|
fields: null
|
|
6784
6786
|
};
|
|
6785
|
-
var
|
|
6786
|
-
|
|
6787
|
+
var lstField = [
|
|
6788
|
+
options.valueField,
|
|
6789
|
+
options.displayField
|
|
6790
|
+
];
|
|
6791
|
+
lstField.push.apply(lstField, __spread(options.fieldPlus.split(',').filter(function (q) { return !!q; })));
|
|
6792
|
+
gridInfo.fields = this._commonService.addDistinct(lstField, []).toString();
|
|
6787
6793
|
if (options.sorts != null && options.sorts.length > 0) {
|
|
6788
6794
|
gridInfo.sorts = __spread(options.sorts);
|
|
6789
6795
|
}
|
|
@@ -6793,7 +6799,7 @@
|
|
|
6793
6799
|
return gridInfo;
|
|
6794
6800
|
};
|
|
6795
6801
|
BaseService.prototype.setDefaultOptions = function (options) {
|
|
6796
|
-
if (options.fieldPlus.length
|
|
6802
|
+
if (options.fieldPlus.length && !options.fieldPlus.startsWith(',')) {
|
|
6797
6803
|
options.fieldPlus = ',' + options.fieldPlus;
|
|
6798
6804
|
}
|
|
6799
6805
|
if (options.sortField == '') {
|
|
@@ -6801,43 +6807,47 @@
|
|
|
6801
6807
|
}
|
|
6802
6808
|
};
|
|
6803
6809
|
BaseService.prototype.setDefaultOptionsTree = function (options, fieldParent) {
|
|
6810
|
+
if (options.fieldPlus.length && !options.fieldPlus.startsWith(',')) {
|
|
6811
|
+
options.fieldPlus = ',' + options.fieldPlus;
|
|
6812
|
+
}
|
|
6804
6813
|
if (options.fieldPlus.length > 0) {
|
|
6805
6814
|
options.fieldPlus += ',';
|
|
6806
6815
|
}
|
|
6807
6816
|
options.fieldPlus += fieldParent;
|
|
6808
|
-
if (options.fieldPlus.length > 0 && !options.fieldPlus.startsWith(',')) {
|
|
6809
|
-
options.fieldPlus = ',' + options.fieldPlus;
|
|
6810
|
-
}
|
|
6811
6817
|
};
|
|
6812
6818
|
BaseService.prototype.getDataDropdown = function (options) {
|
|
6819
|
+
return this.getDataDropdownByFilter([], options);
|
|
6820
|
+
};
|
|
6821
|
+
BaseService.prototype.getDataDropdownByFilter = function (filters, options) {
|
|
6813
6822
|
var _this = this;
|
|
6814
|
-
if (options == null)
|
|
6815
|
-
options = new DropdownOptions();
|
|
6816
|
-
this.setDefaultOptions(options);
|
|
6817
6823
|
return new Promise(function (resolve, reject) {
|
|
6818
|
-
_this.
|
|
6824
|
+
_this.getDataDropdownByFilterRaw(filters, options)
|
|
6819
6825
|
.then(function (res) {
|
|
6820
6826
|
resolve(res.data);
|
|
6821
|
-
})
|
|
6827
|
+
})
|
|
6828
|
+
.catch(function (err) { return reject(err); });
|
|
6822
6829
|
});
|
|
6823
6830
|
};
|
|
6824
|
-
BaseService.prototype.
|
|
6825
|
-
var _this = this;
|
|
6831
|
+
BaseService.prototype.getDataDropdownByFilterRaw = function (filters, options) {
|
|
6826
6832
|
if (options == null)
|
|
6827
6833
|
options = new DropdownOptions();
|
|
6828
6834
|
this.setDefaultOptions(options);
|
|
6835
|
+
return this._getDataDropdownByFilter(filters, options);
|
|
6836
|
+
};
|
|
6837
|
+
BaseService.prototype._getDataDropdownByFilter = function (filters, options) {
|
|
6838
|
+
var _this = this;
|
|
6829
6839
|
return new Promise(function (resolve, reject) {
|
|
6830
6840
|
var gridInfo = _this.generateGridInfoDropdown(filters, options);
|
|
6831
6841
|
if (options.isServerLoad) {
|
|
6832
6842
|
_this.getByGridRequest(gridInfo, options.plusUrl)
|
|
6833
6843
|
.then(function (res) {
|
|
6834
|
-
resolve(res
|
|
6844
|
+
resolve(res);
|
|
6835
6845
|
}).catch(function (err) { return reject(err); });
|
|
6836
6846
|
}
|
|
6837
6847
|
else {
|
|
6838
6848
|
_this.getAllByGridInfo(gridInfo, options.plusUrl)
|
|
6839
6849
|
.then(function (res) {
|
|
6840
|
-
resolve(res
|
|
6850
|
+
resolve(res);
|
|
6841
6851
|
}).catch(function (err) { return reject(err); });
|
|
6842
6852
|
}
|
|
6843
6853
|
});
|
|
@@ -6870,38 +6880,34 @@
|
|
|
6870
6880
|
return result;
|
|
6871
6881
|
};
|
|
6872
6882
|
BaseService.prototype.getTreeDataDropdown = function (fieldParent, valueParentRoot, options) {
|
|
6883
|
+
if (valueParentRoot === void 0) { valueParentRoot = -1; }
|
|
6884
|
+
return this.getTreeDataDropdownByFilter([], fieldParent, valueParentRoot, options);
|
|
6885
|
+
};
|
|
6886
|
+
BaseService.prototype.getTreeDataDropdownByFilter = function (filters, fieldParent, valueParentRoot, options) {
|
|
6873
6887
|
var _this = this;
|
|
6874
6888
|
if (valueParentRoot === void 0) { valueParentRoot = -1; }
|
|
6875
|
-
if (options == null)
|
|
6876
|
-
options = new DropdownOptions();
|
|
6877
|
-
this.setDefaultOptionsTree(options, fieldParent);
|
|
6878
6889
|
return new Promise(function (resolve, reject) {
|
|
6879
|
-
_this.
|
|
6890
|
+
_this.getTreeDataDropdownByFilterRaw(filters, fieldParent, valueParentRoot, options)
|
|
6880
6891
|
.then(function (res) {
|
|
6881
|
-
resolve(
|
|
6882
|
-
})
|
|
6892
|
+
resolve(res.data);
|
|
6893
|
+
})
|
|
6894
|
+
.catch(function (err) { return reject(err); });
|
|
6883
6895
|
});
|
|
6884
6896
|
};
|
|
6885
|
-
BaseService.prototype.
|
|
6897
|
+
BaseService.prototype.getTreeDataDropdownByFilterRaw = function (filters, fieldParent, valueParentRoot, options) {
|
|
6886
6898
|
var _this = this;
|
|
6887
6899
|
if (valueParentRoot === void 0) { valueParentRoot = -1; }
|
|
6888
6900
|
if (options == null)
|
|
6889
6901
|
options = new DropdownOptions();
|
|
6890
6902
|
this.setDefaultOptionsTree(options, fieldParent);
|
|
6891
6903
|
return new Promise(function (resolve, reject) {
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
_this.
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
else {
|
|
6900
|
-
_this.getAllByGridInfo(gridInfo, options.plusUrl)
|
|
6901
|
-
.then(function (res) {
|
|
6902
|
-
resolve(_this.getTreeData(res.data, fieldParent, valueParentRoot, options));
|
|
6903
|
-
}).catch(function (err) { return reject(err); });
|
|
6904
|
-
}
|
|
6904
|
+
_this._getDataDropdownByFilter(filters, options)
|
|
6905
|
+
.then(function (res) {
|
|
6906
|
+
var treeData = _this.getTreeData(res.data, fieldParent, valueParentRoot, options);
|
|
6907
|
+
res.data = treeData;
|
|
6908
|
+
resolve(res);
|
|
6909
|
+
})
|
|
6910
|
+
.catch(function (err) { return reject(err); });
|
|
6905
6911
|
});
|
|
6906
6912
|
};
|
|
6907
6913
|
BaseService.prototype.getDetail = function (id) {
|
|
@@ -33968,9 +33974,8 @@
|
|
|
33968
33974
|
|
|
33969
33975
|
var DropdownComponent = /** @class */ (function (_super) {
|
|
33970
33976
|
__extends(DropdownComponent, _super);
|
|
33971
|
-
function DropdownComponent(
|
|
33977
|
+
function DropdownComponent(_deviceDetectorService, injector, _crudService) {
|
|
33972
33978
|
var _this = _super.call(this, injector) || this;
|
|
33973
|
-
_this._dropDownService = _dropDownService;
|
|
33974
33979
|
_this._deviceDetectorService = _deviceDetectorService;
|
|
33975
33980
|
_this.disableDisplayFieldServerSearch = false;
|
|
33976
33981
|
_this.control = new DropdownControlSchema();
|
|
@@ -33997,14 +34002,19 @@
|
|
|
33997
34002
|
_this.funcReturnValue = function (value) { return value; };
|
|
33998
34003
|
_this.hideTransitionOptions = '195ms ease-in';
|
|
33999
34004
|
_this.showTransitionOptions = '225ms ease-out';
|
|
34005
|
+
_this.virtualScroll = true;
|
|
34000
34006
|
_this.valueSearchServer = '';
|
|
34001
34007
|
_this.keyUp = new rxjs.Subject();
|
|
34002
34008
|
_this._hasLoadedDatasource = false;
|
|
34003
34009
|
_this.showQuickAddForm = false;
|
|
34004
34010
|
_this.formModel = {};
|
|
34005
34011
|
_this.flashCacheParent = [];
|
|
34012
|
+
_this.filterFromParents = [];
|
|
34006
34013
|
_this.dropdownOptions = [];
|
|
34007
34014
|
_this.delayFilter = 100;
|
|
34015
|
+
_this.loading = false;
|
|
34016
|
+
_this.page = 1;
|
|
34017
|
+
_this.totalPage = 2;
|
|
34008
34018
|
_this.modifyOptionWhenFilter = function (options) {
|
|
34009
34019
|
_this.dropdownOptions = _this.dropdown._options;
|
|
34010
34020
|
_this._modifyOptionWhenFilter(options);
|
|
@@ -34013,6 +34023,16 @@
|
|
|
34013
34023
|
_this.dropdownOptions = _this.multiSelect._options;
|
|
34014
34024
|
_this._modifyOptionWhenFilter(options);
|
|
34015
34025
|
};
|
|
34026
|
+
_this.handleScroll = function (evt) {
|
|
34027
|
+
if (evt.srcElement.scrollTop > 0
|
|
34028
|
+
&& evt.srcElement.offsetHeight + evt.srcElement.scrollTop == evt.srcElement.scrollHeight) {
|
|
34029
|
+
if (_this.timeoutScroll)
|
|
34030
|
+
clearTimeout(_this.timeoutScroll);
|
|
34031
|
+
_this.timeoutScroll = setTimeout(function (f) {
|
|
34032
|
+
_this.getDataNextPage();
|
|
34033
|
+
}, 150);
|
|
34034
|
+
}
|
|
34035
|
+
};
|
|
34016
34036
|
return _this;
|
|
34017
34037
|
}
|
|
34018
34038
|
Object.defineProperty(DropdownComponent.prototype, "showClear", {
|
|
@@ -34035,7 +34055,7 @@
|
|
|
34035
34055
|
});
|
|
34036
34056
|
Object.defineProperty(DropdownComponent.prototype, "dataSource", {
|
|
34037
34057
|
set: function (value) {
|
|
34038
|
-
this.combineDataSource(value);
|
|
34058
|
+
this.combineDataSource(value, 1);
|
|
34039
34059
|
this.checkAndFireEvent();
|
|
34040
34060
|
},
|
|
34041
34061
|
enumerable: false,
|
|
@@ -34070,6 +34090,15 @@
|
|
|
34070
34090
|
});
|
|
34071
34091
|
DropdownComponent.prototype.ngOnInit = function () {
|
|
34072
34092
|
var _this = this;
|
|
34093
|
+
if (this.control.fitPanel) {
|
|
34094
|
+
var classWrapContent = '--wrap-content';
|
|
34095
|
+
if (!this.control.panelClass) {
|
|
34096
|
+
this.control.panelClass = classWrapContent;
|
|
34097
|
+
}
|
|
34098
|
+
else {
|
|
34099
|
+
this.control.panelClass += " " + classWrapContent;
|
|
34100
|
+
}
|
|
34101
|
+
}
|
|
34073
34102
|
this.control._component = this;
|
|
34074
34103
|
if (this.control.placeholder == null && this.control.multiple) {
|
|
34075
34104
|
this.control.placeholder = 'Chưa chọn bản ghi';
|
|
@@ -34077,6 +34106,7 @@
|
|
|
34077
34106
|
this.setDefaultSetting();
|
|
34078
34107
|
if (this.control.baseService) {
|
|
34079
34108
|
if (this.control.isServerLoad) {
|
|
34109
|
+
this.virtualScroll = false;
|
|
34080
34110
|
this.createFilterFunction();
|
|
34081
34111
|
this.subscription = this.keyUp.pipe(operators.map(function (event) { return event.target.value; }), operators.debounceTime(500), operators.distinctUntilChanged()).subscribe(function (value) {
|
|
34082
34112
|
_this._getData();
|
|
@@ -34221,49 +34251,35 @@
|
|
|
34221
34251
|
}
|
|
34222
34252
|
};
|
|
34223
34253
|
DropdownComponent.prototype.getData = function (filterParents) {
|
|
34224
|
-
|
|
34254
|
+
if (!filterParents)
|
|
34255
|
+
filterParents = [];
|
|
34256
|
+
this.filterFromParents = filterParents;
|
|
34257
|
+
this._getData();
|
|
34225
34258
|
};
|
|
34226
|
-
DropdownComponent.prototype.combineDataSource = function (dataSource) {
|
|
34227
|
-
var _this = this;
|
|
34259
|
+
DropdownComponent.prototype.combineDataSource = function (dataSource, page) {
|
|
34228
34260
|
if (!dataSource)
|
|
34229
34261
|
dataSource = [];
|
|
34230
34262
|
if (this.control.isServerLoad) {
|
|
34231
|
-
|
|
34232
|
-
|
|
34263
|
+
if (page > 1) {
|
|
34264
|
+
if (this.dropdown)
|
|
34265
|
+
this.dropdown.selectedOptionUpdated = false;
|
|
34266
|
+
// Append thêm datasource
|
|
34267
|
+
var tmpDataSource_1 = __spread(this.dataSourceInternal);
|
|
34268
|
+
this.appendDataSource(tmpDataSource_1, dataSource);
|
|
34269
|
+
if (tmpDataSource_1.length == this.dataSourceInternal.length) {
|
|
34270
|
+
return this.getDataNextPage();
|
|
34271
|
+
}
|
|
34272
|
+
this.dataSourceInternal = tmpDataSource_1;
|
|
34273
|
+
return;
|
|
34274
|
+
}
|
|
34275
|
+
var tmpDataSource = __spread(dataSource);
|
|
34276
|
+
if (this.dataSourceSelected && this.dataSourceSelected.length) {
|
|
34233
34277
|
this._hasLoadedDatasource = true;
|
|
34234
34278
|
if (!this.valueSearchServer) {
|
|
34235
|
-
|
|
34236
|
-
this.dataSourceSelected.forEach(function (source) {
|
|
34237
|
-
var index = tmpDataSource_1.findIndex(function (q) { return q.value[_this.control.fieldMaPhanCap] > source.value[_this.control.fieldMaPhanCap]; });
|
|
34238
|
-
if (index == -1) {
|
|
34239
|
-
tmpDataSource_1.push(source);
|
|
34240
|
-
}
|
|
34241
|
-
else if (index == 0) {
|
|
34242
|
-
tmpDataSource_1.unshift(source);
|
|
34243
|
-
}
|
|
34244
|
-
else {
|
|
34245
|
-
// Nếu bản ghi ngay trước vị trí cần insert là bản ghi hiện tại thì k insert
|
|
34246
|
-
if (tmpDataSource_1[index - 1].value[_this.control.valueField] == source.value[_this.control.valueField]) {
|
|
34247
|
-
if (!source.disabled) {
|
|
34248
|
-
tmpDataSource_1[index - 1].disabled = false;
|
|
34249
|
-
}
|
|
34250
|
-
return;
|
|
34251
|
-
}
|
|
34252
|
-
tmpDataSource_1.splice(index, 0, source);
|
|
34253
|
-
}
|
|
34254
|
-
});
|
|
34255
|
-
}
|
|
34256
|
-
else {
|
|
34257
|
-
this.dataSourceSelected.forEach(function (source) {
|
|
34258
|
-
var index = tmpDataSource_1.findIndex(function (q) { return q.value[_this.control.valueField] == source.value[_this.control.valueField]; });
|
|
34259
|
-
if (index == -1) {
|
|
34260
|
-
tmpDataSource_1.unshift(source);
|
|
34261
|
-
}
|
|
34262
|
-
});
|
|
34263
|
-
}
|
|
34279
|
+
this.appendDataSource(tmpDataSource, this.dataSourceSelected, -1);
|
|
34264
34280
|
}
|
|
34265
34281
|
}
|
|
34266
|
-
this.dataSourceInternal =
|
|
34282
|
+
this.dataSourceInternal = tmpDataSource;
|
|
34267
34283
|
}
|
|
34268
34284
|
else {
|
|
34269
34285
|
this.dataSourceInternal = dataSource;
|
|
@@ -34272,6 +34288,49 @@
|
|
|
34272
34288
|
}
|
|
34273
34289
|
}
|
|
34274
34290
|
};
|
|
34291
|
+
DropdownComponent.prototype.appendDataSource = function (destSource, dataSource, direction) {
|
|
34292
|
+
var _this = this;
|
|
34293
|
+
if (direction === void 0) { direction = 1; }
|
|
34294
|
+
if (this.control.isTree) {
|
|
34295
|
+
dataSource.forEach(function (source) {
|
|
34296
|
+
var index = destSource.findIndex(function (q) { return q.value[_this.control.fieldMaPhanCap] > source.value[_this.control.fieldMaPhanCap]; });
|
|
34297
|
+
if (index == -1) {
|
|
34298
|
+
if (direction == -1) {
|
|
34299
|
+
destSource.unshift(source);
|
|
34300
|
+
}
|
|
34301
|
+
else {
|
|
34302
|
+
destSource.push(source);
|
|
34303
|
+
}
|
|
34304
|
+
}
|
|
34305
|
+
else if (index == 0) {
|
|
34306
|
+
destSource.unshift(source);
|
|
34307
|
+
}
|
|
34308
|
+
else {
|
|
34309
|
+
// Nếu bản ghi ngay trước vị trí cần insert là bản ghi hiện tại thì k insert
|
|
34310
|
+
if (destSource[index - 1].value[_this.control.valueField] == source.value[_this.control.valueField]) {
|
|
34311
|
+
if (!source.disabled) {
|
|
34312
|
+
destSource[index - 1].disabled = false;
|
|
34313
|
+
}
|
|
34314
|
+
return;
|
|
34315
|
+
}
|
|
34316
|
+
destSource.splice(index, 0, source);
|
|
34317
|
+
}
|
|
34318
|
+
});
|
|
34319
|
+
}
|
|
34320
|
+
else {
|
|
34321
|
+
dataSource.forEach(function (source) {
|
|
34322
|
+
var index = destSource.findIndex(function (q) { return q.value[_this.control.valueField] == source.value[_this.control.valueField]; });
|
|
34323
|
+
if (index == -1) {
|
|
34324
|
+
if (direction == -1) {
|
|
34325
|
+
destSource.unshift(source);
|
|
34326
|
+
}
|
|
34327
|
+
else {
|
|
34328
|
+
destSource.push(source);
|
|
34329
|
+
}
|
|
34330
|
+
}
|
|
34331
|
+
});
|
|
34332
|
+
}
|
|
34333
|
+
};
|
|
34275
34334
|
DropdownComponent.prototype.checkAndFireEvent = function (force) {
|
|
34276
34335
|
if (force === void 0) { force = false; }
|
|
34277
34336
|
if (!this._hasLoadedDatasource) {
|
|
@@ -34322,9 +34381,9 @@
|
|
|
34322
34381
|
};
|
|
34323
34382
|
DropdownComponent.prototype.setSelectedValue = function () {
|
|
34324
34383
|
return __awaiter(this, void 0, void 0, function () {
|
|
34325
|
-
var filters, length,
|
|
34326
|
-
return __generator(this, function (
|
|
34327
|
-
switch (
|
|
34384
|
+
var filters, length, dataSource;
|
|
34385
|
+
return __generator(this, function (_a) {
|
|
34386
|
+
switch (_a.label) {
|
|
34328
34387
|
case 0:
|
|
34329
34388
|
if (!this.control.isServerLoad) return [3 /*break*/, 2];
|
|
34330
34389
|
filters = [];
|
|
@@ -34336,12 +34395,12 @@
|
|
|
34336
34395
|
else {
|
|
34337
34396
|
filters.push(this.newFilter(this.control.valueField, exports.Operator.equal, this._value));
|
|
34338
34397
|
}
|
|
34339
|
-
|
|
34340
|
-
return [4 /*yield*/, this._getDataSourceByService(filters, length)];
|
|
34398
|
+
return [4 /*yield*/, this._getDataSourceByService(filters, 1, length)];
|
|
34341
34399
|
case 1:
|
|
34342
|
-
|
|
34343
|
-
this.
|
|
34344
|
-
|
|
34400
|
+
dataSource = (_a.sent()).dataSource;
|
|
34401
|
+
this.dataSourceSelected = dataSource;
|
|
34402
|
+
this.combineDataSource(this.dataSourceInternal, 1);
|
|
34403
|
+
_a.label = 2;
|
|
34345
34404
|
case 2:
|
|
34346
34405
|
this.checkAndFireEvent();
|
|
34347
34406
|
return [2 /*return*/];
|
|
@@ -34446,15 +34505,14 @@
|
|
|
34446
34505
|
this.dataSourceInternal = [];
|
|
34447
34506
|
this._hasLoadedDatasource = false;
|
|
34448
34507
|
};
|
|
34449
|
-
DropdownComponent.prototype._getData = function (
|
|
34508
|
+
DropdownComponent.prototype._getData = function (page) {
|
|
34509
|
+
if (page === void 0) { page = 1; }
|
|
34450
34510
|
return __awaiter(this, void 0, void 0, function () {
|
|
34451
34511
|
return __generator(this, function (_a) {
|
|
34452
34512
|
switch (_a.label) {
|
|
34453
34513
|
case 0:
|
|
34454
34514
|
if (!this.control.baseService) return [3 /*break*/, 2];
|
|
34455
|
-
|
|
34456
|
-
filterParents = [];
|
|
34457
|
-
return [4 /*yield*/, this._getDataSource(filterParents)];
|
|
34515
|
+
return [4 /*yield*/, this._getDataSource(page)];
|
|
34458
34516
|
case 1:
|
|
34459
34517
|
_a.sent();
|
|
34460
34518
|
_a.label = 2;
|
|
@@ -34463,23 +34521,29 @@
|
|
|
34463
34521
|
});
|
|
34464
34522
|
});
|
|
34465
34523
|
};
|
|
34466
|
-
DropdownComponent.prototype._getDataSource = function (
|
|
34524
|
+
DropdownComponent.prototype._getDataSource = function (page) {
|
|
34467
34525
|
return __awaiter(this, void 0, void 0, function () {
|
|
34468
|
-
var filters, dataSource;
|
|
34469
|
-
return __generator(this, function (
|
|
34470
|
-
switch (
|
|
34471
|
-
case 0:
|
|
34526
|
+
var filters, _a, dataSource, totalPage;
|
|
34527
|
+
return __generator(this, function (_b) {
|
|
34528
|
+
switch (_b.label) {
|
|
34529
|
+
case 0:
|
|
34530
|
+
this.page = page;
|
|
34531
|
+
this.loading = true;
|
|
34532
|
+
return [4 /*yield*/, this.filterProcess(this.filterFromParents)];
|
|
34472
34533
|
case 1:
|
|
34473
|
-
filters =
|
|
34534
|
+
filters = _b.sent();
|
|
34474
34535
|
if (filters == null) {
|
|
34475
|
-
this.
|
|
34536
|
+
this.loading = false;
|
|
34537
|
+
this.combineDataSource([], page);
|
|
34476
34538
|
this.checkAndFireEvent(false);
|
|
34477
34539
|
return [2 /*return*/];
|
|
34478
34540
|
}
|
|
34479
|
-
return [4 /*yield*/, this._getDataSourceByService(filters)];
|
|
34541
|
+
return [4 /*yield*/, this._getDataSourceByService(filters, page)];
|
|
34480
34542
|
case 2:
|
|
34481
|
-
|
|
34482
|
-
this.
|
|
34543
|
+
_a = _b.sent(), dataSource = _a.dataSource, totalPage = _a.totalPage;
|
|
34544
|
+
this.totalPage = totalPage;
|
|
34545
|
+
this.loading = false;
|
|
34546
|
+
this.combineDataSource(dataSource, page);
|
|
34483
34547
|
if (!this.control.isServerLoad) {
|
|
34484
34548
|
this.checkAndFireEvent(true);
|
|
34485
34549
|
}
|
|
@@ -34503,16 +34567,19 @@
|
|
|
34503
34567
|
});
|
|
34504
34568
|
});
|
|
34505
34569
|
};
|
|
34506
|
-
DropdownComponent.prototype._getDataSourceByService = function (filters, pageSize) {
|
|
34570
|
+
DropdownComponent.prototype._getDataSourceByService = function (filters, page, pageSize) {
|
|
34571
|
+
if (page === void 0) { page = 1; }
|
|
34507
34572
|
if (pageSize === void 0) { pageSize = null; }
|
|
34508
34573
|
return __awaiter(this, void 0, void 0, function () {
|
|
34509
|
-
var dataSource, dropdownOptions, result, dataSource_3, dataSource_3_1, item;
|
|
34574
|
+
var dataSource, totalPage, dropdownOptions, response, result, dataSource_3, dataSource_3_1, item;
|
|
34510
34575
|
var e_4, _a;
|
|
34511
34576
|
return __generator(this, function (_b) {
|
|
34512
34577
|
switch (_b.label) {
|
|
34513
34578
|
case 0:
|
|
34514
34579
|
dataSource = null;
|
|
34580
|
+
totalPage = 1;
|
|
34515
34581
|
dropdownOptions = this._crudService.createDropdownOptions(this.control);
|
|
34582
|
+
dropdownOptions.page = page;
|
|
34516
34583
|
if (pageSize) {
|
|
34517
34584
|
dropdownOptions.pageSize = pageSize;
|
|
34518
34585
|
}
|
|
@@ -34520,19 +34587,24 @@
|
|
|
34520
34587
|
return [4 /*yield*/, this.control.baseService.getDataDropdownByFilter(this.control.groupCode, null, filters, dropdownOptions)];
|
|
34521
34588
|
case 1:
|
|
34522
34589
|
dataSource = _b.sent();
|
|
34523
|
-
return [3 /*break*/,
|
|
34590
|
+
return [3 /*break*/, 7];
|
|
34524
34591
|
case 2:
|
|
34592
|
+
response = null;
|
|
34525
34593
|
if (!this.control.isTree) return [3 /*break*/, 4];
|
|
34526
|
-
return [4 /*yield*/, this.control.baseService.
|
|
34594
|
+
return [4 /*yield*/, this.control.baseService.getTreeDataDropdownByFilterRaw(filters, this.control.fieldTree, this.control.valueParentRoot, dropdownOptions)];
|
|
34527
34595
|
case 3:
|
|
34528
|
-
|
|
34596
|
+
response = _b.sent();
|
|
34529
34597
|
return [3 /*break*/, 6];
|
|
34530
|
-
case 4: return [4 /*yield*/, this.control.baseService.
|
|
34598
|
+
case 4: return [4 /*yield*/, this.control.baseService.getDataDropdownByFilterRaw(filters, dropdownOptions)];
|
|
34531
34599
|
case 5:
|
|
34532
|
-
|
|
34600
|
+
response = _b.sent();
|
|
34533
34601
|
_b.label = 6;
|
|
34534
|
-
case 6:
|
|
34535
|
-
|
|
34602
|
+
case 6:
|
|
34603
|
+
dataSource = response.data;
|
|
34604
|
+
totalPage = Math.ceil(response.totalRecord / dropdownOptions.pageSize);
|
|
34605
|
+
_b.label = 7;
|
|
34606
|
+
case 7: return [4 /*yield*/, this._crudService.getRefData(dataSource, dropdownOptions)];
|
|
34607
|
+
case 8:
|
|
34536
34608
|
_b.sent();
|
|
34537
34609
|
if (!dataSource)
|
|
34538
34610
|
dataSource = [];
|
|
@@ -34550,7 +34622,7 @@
|
|
|
34550
34622
|
}
|
|
34551
34623
|
finally { if (e_4) throw e_4.error; }
|
|
34552
34624
|
}
|
|
34553
|
-
return [2 /*return*/, result];
|
|
34625
|
+
return [2 /*return*/, { dataSource: result, totalPage: totalPage }];
|
|
34554
34626
|
}
|
|
34555
34627
|
});
|
|
34556
34628
|
});
|
|
@@ -34561,7 +34633,7 @@
|
|
|
34561
34633
|
return __generator(this, function (_a) {
|
|
34562
34634
|
switch (_a.label) {
|
|
34563
34635
|
case 0:
|
|
34564
|
-
filters = filterFromParents;
|
|
34636
|
+
filters = __spread(filterFromParents);
|
|
34565
34637
|
return [4 /*yield*/, appendDefaultFilter(filters, this.control.defaultFilters)];
|
|
34566
34638
|
case 1:
|
|
34567
34639
|
_a.sent();
|
|
@@ -34717,9 +34789,15 @@
|
|
|
34717
34789
|
component: this,
|
|
34718
34790
|
event: evt
|
|
34719
34791
|
});
|
|
34792
|
+
if (this.control.panelClass) {
|
|
34793
|
+
this.dropdown.overlay.style.width = this.dropdown.overlay.style.minWidth;
|
|
34794
|
+
}
|
|
34720
34795
|
if (!this.control.isServerLoad) {
|
|
34721
34796
|
return;
|
|
34722
34797
|
}
|
|
34798
|
+
// this.scrollContainer = this.dropdown.overlay.querySelector('.cdk-virtual-scroll-viewport');
|
|
34799
|
+
this.scrollContainer = this.dropdown.overlay.querySelector('.p-dropdown-items-wrapper');
|
|
34800
|
+
this.scrollContainer.addEventListener('scroll', this.handleScroll);
|
|
34723
34801
|
var defaultInput = this.dropdown.filterViewChild.nativeElement;
|
|
34724
34802
|
this._insertTextboxAndFocus(defaultInput);
|
|
34725
34803
|
this.onShowSmartEvent.emit(evt);
|
|
@@ -34729,14 +34807,25 @@
|
|
|
34729
34807
|
component: this,
|
|
34730
34808
|
event: evt
|
|
34731
34809
|
});
|
|
34810
|
+
if (this.control.panelClass) {
|
|
34811
|
+
this.multiSelect.overlay.style.width = this.multiSelect.overlay.style.minWidth;
|
|
34812
|
+
}
|
|
34732
34813
|
this.selectedValueBefore = this._value;
|
|
34733
34814
|
if (!this.control.isServerLoad) {
|
|
34734
34815
|
return;
|
|
34735
34816
|
}
|
|
34817
|
+
this.scrollContainer = this.multiSelect.overlay.querySelector('.p-multiselect-items-wrapper');
|
|
34818
|
+
this.scrollContainer.addEventListener('scroll', this.handleScroll);
|
|
34736
34819
|
var defaultInput = this.multiSelect.filterInputChild.nativeElement;
|
|
34737
34820
|
this._insertTextboxAndFocus(defaultInput);
|
|
34738
34821
|
this.onShowSmartEvent.emit(evt);
|
|
34739
34822
|
};
|
|
34823
|
+
DropdownComponent.prototype.getDataNextPage = function () {
|
|
34824
|
+
if (this.loading || this.page >= this.totalPage)
|
|
34825
|
+
return;
|
|
34826
|
+
this.page++;
|
|
34827
|
+
this._getData(this.page);
|
|
34828
|
+
};
|
|
34740
34829
|
DropdownComponent.prototype._insertTextboxAndFocus = function (defaultInput) {
|
|
34741
34830
|
this.input.nativeElement.classList.remove('hide');
|
|
34742
34831
|
// defaultInput.disabled = true;
|
|
@@ -34762,6 +34851,9 @@
|
|
|
34762
34851
|
}
|
|
34763
34852
|
this.selectedValueBefore = this._value;
|
|
34764
34853
|
}
|
|
34854
|
+
if (this.scrollContainer) {
|
|
34855
|
+
this.scrollContainer.removeEventListener('scroll', this.handleScroll);
|
|
34856
|
+
}
|
|
34765
34857
|
};
|
|
34766
34858
|
DropdownComponent.prototype.handleFocus = function (evt) {
|
|
34767
34859
|
this.onFocus.emit(evt);
|
|
@@ -34786,13 +34878,12 @@
|
|
|
34786
34878
|
DropdownComponent.decorators = [
|
|
34787
34879
|
{ type: i0.Component, args: [{
|
|
34788
34880
|
selector: 'dropdown',
|
|
34789
|
-
template: "<div #el class=\"tn-dropdown\" [pTooltip]=\"tooltip\" tooltipPosition=\"top\" tooltipStyleClass=\"wrap\">\r\n <p-dropdown *ngIf=\"!control.multiple\" [options]=\"dataSourceInternal\" [placeholder]=\"control.placeholder\"\r\n [filter]=\"control.filter\" [panelStyleClass]=\"getPanelClass()\" [appendTo]=\"control.appendTo\"\r\n [styleClass]=\"'tn-dropdown'\" [emptyFilterMessage]=\"'Kh\u00F4ng t\u00ECm th\u1EA5y k\u1EBFt qu\u1EA3' | translate\"\r\n [disabled]=\"control.disabled ? true : null\" [autoZIndex]=\"true\" [showClear]=\"control.showClear\"\r\n [showTransitionOptions]=\"showTransitionOptions\" [autoDisplayFirst]=\"control.autoDisplayFirst\"\r\n [maxItemDisplay]=\"control.maxItemDisplay\" [hideTransitionOptions]=\"hideTransitionOptions\"\r\n [modifyOptionsWhenFilter]=\"modifyOptionWhenFilter\" [delayFilter]=\"delayFilter\" [(ngModel)]=\"_value\"\r\n (onFocus)=\"handleFocus($event)\" (onBlur)=\"handleBlur($event)\" (onChange)=\"onChangeSelected($event)\"\r\n (onClick)=\"onDropdownClickHandler($event)\" (onShow)=\"onShowHandler($event)\" (onHide)=\"onHideHandler($event)\">\r\n <ng-template *ngIf=\"control.templateSelectedItem\" let-item pTemplate=\"selectedItem\">\r\n <ng-container\r\n *ngTemplateOutlet=\"control.templateSelectedItem; context: {$implicit: item, selectedValue: _value}\">\r\n </ng-container>\r\n </ng-template>\r\n <ng-template *ngIf=\"control.templateItem\" let-item pTemplate=\"item\">\r\n <ng-container *ngTemplateOutlet=\"control.templateItem; context: {$implicit: item}\"></ng-container>\r\n </ng-template>\r\n </p-dropdown>\r\n <p-multiSelect *ngIf=\"control.multiple\" [options]=\"dataSourceInternal\" [filter]=\"control.filter\"\r\n [defaultLabel]=\"control.placeholder\" [placeholder]=\"control.placeholder\" [panelStyleClass]=\"getPanelClass()\"\r\n [appendTo]=\"control.appendTo\" [styleClass]=\"'tn-dropdown'\"\r\n [emptyFilterMessage]=\"'Kh\u00F4ng t\u00ECm th\u1EA5y k\u1EBFt qu\u1EA3' | translate\" [disabled]=\"control.disabled ? true : null\"\r\n [autoZIndex]=\"true\" [showTransitionOptions]=\"showTransitionOptions\"\r\n [hideTransitionOptions]=\"hideTransitionOptions\" [maxItemDisplay]=\"control.maxItemDisplay\"\r\n [selectedItemsLabel]=\"control.selectedItemsLabel\" [maxSelectedLabels]=\"control.maxSelectedLabels\"\r\n [modifyOptionsWhenFilter]=\"modifyOptionWhenFilterMultiple\" [delayFilter]=\"delayFilter\" [(ngModel)]=\"_value\"\r\n (onChange)=\"onChangeSelected($event)\" (onClick)=\"onDropdownClickHandler($event)\"\r\n (onPanelShow)=\"onPanelShowHandler($event)\" (onPanelHide)=\"onHideHandler($event)\">\r\n <ng-template pTemplate=\"selectedItems\" let-value>\r\n <ng-container *ngIf=\"!value || value.length == 0\">{{control.placeholder}}</ng-container>\r\n <ng-container *ngIf=\"value && value.length > 0\">\r\n <span *ngFor=\"let selectedItem of value\" [class]=\"_itemSelectedStyleClass\">\r\n {{selectedItem[control.displayField]}}<span class=\"remove-item\"\r\n (click)=\"removeItem($event, selectedItem)\"><i class=\"fas fa-times\"></i></span>\r\n </span>\r\n </ng-container>\r\n </ng-template>\r\n </p-multiSelect>\r\n <input #inputMask class=\"input-mask hide p-inputtext\" type=\"text\" [
|
|
34881
|
+
template: "<div #el class=\"tn-dropdown\" [pTooltip]=\"tooltip\" tooltipPosition=\"top\" tooltipStyleClass=\"wrap\">\r\n <p-dropdown *ngIf=\"!control.multiple\" [options]=\"dataSourceInternal\" [placeholder]=\"control.placeholder\"\r\n [filter]=\"control.filter\" [panelStyleClass]=\"getPanelClass()\" [appendTo]=\"control.appendTo\"\r\n [styleClass]=\"'tn-dropdown'\" [emptyFilterMessage]=\"'Kh\u00F4ng t\u00ECm th\u1EA5y k\u1EBFt qu\u1EA3' | translate\"\r\n [disabled]=\"control.disabled ? true : null\" [autoZIndex]=\"true\" [showClear]=\"control.showClear\"\r\n [showTransitionOptions]=\"showTransitionOptions\" [autoDisplayFirst]=\"control.autoDisplayFirst\"\r\n [virtualScroll]=\"virtualScroll\" itemSize=\"30\" [maxItemDisplay]=\"control.maxItemDisplay\"\r\n [autofocusSelectedItem]=\"false\" [hideTransitionOptions]=\"hideTransitionOptions\"\r\n [modifyOptionsWhenFilter]=\"modifyOptionWhenFilter\" [delayFilter]=\"delayFilter\" [(ngModel)]=\"_value\"\r\n (onFocus)=\"handleFocus($event)\" (onBlur)=\"handleBlur($event)\" (onChange)=\"onChangeSelected($event)\"\r\n (onClick)=\"onDropdownClickHandler($event)\" (onShow)=\"onShowHandler($event)\" (onHide)=\"onHideHandler($event)\">\r\n <ng-template *ngIf=\"control.templateSelectedItem\" let-item pTemplate=\"selectedItem\">\r\n <ng-container\r\n *ngTemplateOutlet=\"control.templateSelectedItem; context: {$implicit: item, selectedValue: _value}\">\r\n </ng-container>\r\n </ng-template>\r\n <ng-template *ngIf=\"control.templateItem\" let-item pTemplate=\"item\">\r\n <ng-container *ngTemplateOutlet=\"control.templateItem; context: {$implicit: item}\"></ng-container>\r\n </ng-template>\r\n </p-dropdown>\r\n <p-multiSelect *ngIf=\"control.multiple\" [options]=\"dataSourceInternal\" [filter]=\"control.filter\"\r\n [defaultLabel]=\"control.placeholder\" [placeholder]=\"control.placeholder\" [panelStyleClass]=\"getPanelClass()\"\r\n [appendTo]=\"control.appendTo\" [styleClass]=\"'tn-dropdown'\"\r\n [emptyFilterMessage]=\"'Kh\u00F4ng t\u00ECm th\u1EA5y k\u1EBFt qu\u1EA3' | translate\" [disabled]=\"control.disabled ? true : null\"\r\n [autoZIndex]=\"true\" [showTransitionOptions]=\"showTransitionOptions\"\r\n [hideTransitionOptions]=\"hideTransitionOptions\" [maxItemDisplay]=\"control.maxItemDisplay\"\r\n [selectedItemsLabel]=\"control.selectedItemsLabel\" [maxSelectedLabels]=\"control.maxSelectedLabels\"\r\n [modifyOptionsWhenFilter]=\"modifyOptionWhenFilterMultiple\" [delayFilter]=\"delayFilter\" [(ngModel)]=\"_value\"\r\n (onChange)=\"onChangeSelected($event)\" (onClick)=\"onDropdownClickHandler($event)\"\r\n (onPanelShow)=\"onPanelShowHandler($event)\" (onPanelHide)=\"onHideHandler($event)\">\r\n <ng-template pTemplate=\"selectedItems\" let-value>\r\n <ng-container *ngIf=\"!value || value.length == 0\">{{control.placeholder}}</ng-container>\r\n <ng-container *ngIf=\"value && value.length > 0\">\r\n <span *ngFor=\"let selectedItem of value\" [class]=\"_itemSelectedStyleClass\">\r\n {{selectedItem[control.displayField]}}<span class=\"remove-item\"\r\n (click)=\"removeItem($event, selectedItem)\"><i class=\"fas fa-times\"></i></span>\r\n </span>\r\n </ng-container>\r\n </ng-template>\r\n </p-multiSelect>\r\n <input #inputMask class=\"input-mask hide p-inputtext\" type=\"text\" [disabled]=\"loading\"\r\n [(ngModel)]=\"valueSearchServer\" (keyup)=\"keyUp.next($event)\" />\r\n <button *ngIf=\"control.quickAdd && control.cols\" type=\"button\" pButton icon=\"pi pi-plus\"\r\n class=\"p-button-text p-button-rounded button-quick-add\" pTooltip=\"Th\u00EAm nhanh\" tooltipPosition=\"top\"\r\n (click)=\"showFormQuickAdd()\"></button>\r\n</div>\r\n<tn-dialog *ngIf=\"showQuickAddForm\" #dialog [styleClass]=\"'address-form'\"\r\n [header]=\"'Th\u00EAm m\u1EDBi ' + control.label | translate\" [popupSize]=\"control.popupSize\"\r\n (onHide)=\"showQuickAddForm = false\">\r\n <quick-add-form #formBase [parentModel]=\"model\" [parentContext]=\"context\" [model]=\"formModel\" [control]=\"control\"\r\n [baseService]=\"control.baseService\" (onSaved)=\"handleSaved()\" (onCancel)=\"handleCancel()\">\r\n </quick-add-form>\r\n</tn-dialog>",
|
|
34790
34882
|
providers: [ComponentContextService],
|
|
34791
34883
|
styles: [".tn-dropdown{display:flex}.tn-dropdown p-dropdown,.tn-dropdown p-multiSelect{flex:1 1;width:100%}.tn-dropdown>.button-quick-add{flex:0 0 auto}.input-mask{background:transparent;border:1px solid transparent;border-radius:3px;box-sizing:border-box;outline:none;padding-left:12px;position:absolute;width:100%;z-index:1}.input-mask.hide{display:none}.input-mask:focus{border-color:#2196f3;box-shadow:0 0 0 .2rem #a6d5fa}.custom-select-item{align-items:center;background:#d2eefb;border:1px solid #a9d8ff;border-radius:3px;display:inline-flex;margin:0 0 0 3px;padding:3px 5px}.custom-select-item>span{color:#555;font-size:12px;margin-left:3px}.custom-select-item>span i{font-size:10px}.custom-select-item.min{margin-left:2px;padding:1px 5px}.custom-select-item:first-child{margin-left:0}::ng-deep .tn-dropdown.ui-state-disabled .custom-select-item{background:#e1e1e1;border-color:#d4d4d4}::ng-deep .tn-dropdown.ui-state-disabled .custom-select-item>span{display:none}::ng-deep .ui-multiselect-filter-container .input-mask{box-sizing:border-box;height:22px;left:1px;padding:.2em;text-indent:1.5em;top:1px;width:calc(100% - 2px)}::ng-deep .ui-multiselect-filter-container .input-mask:focus{left:1px;width:calc(100% - 2px)}"]
|
|
34792
34884
|
},] }
|
|
34793
34885
|
];
|
|
34794
34886
|
DropdownComponent.ctorParameters = function () { return [
|
|
34795
|
-
{ type: DropdownService },
|
|
34796
34887
|
{ type: ngxDeviceDetector.DeviceDetectorService },
|
|
34797
34888
|
{ type: i0.Injector },
|
|
34798
34889
|
{ type: CrudService }
|