@c10t/nice-component-library 0.0.4-beta → 0.0.6-beta
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/components/base/base-search.component.d.ts +6 -6
- package/fesm2022/c10t-nice-component-library.mjs +50 -41
- package/fesm2022/c10t-nice-component-library.mjs.map +1 -1
- package/models/components/table-paging-response.model.d.ts +6 -3
- package/package.json +1 -1
- package/services/api.service.d.ts +1 -0
|
@@ -27,15 +27,15 @@ export declare class BaseSearchComponent extends BaseTableComponent implements O
|
|
|
27
27
|
protected activatedRoute: ActivatedRoute;
|
|
28
28
|
protected authoritiesService: AuthoritiesService;
|
|
29
29
|
protected formGroup: FormGroup;
|
|
30
|
-
protected moduleName: string;
|
|
31
|
-
protected unsubscribe$: Subject<void>;
|
|
32
|
-
protected isResetPaging: boolean;
|
|
33
30
|
isAdvancedSearch: boolean;
|
|
34
31
|
searchForm: FormGroup;
|
|
35
32
|
paging: TablePagingRequestModel;
|
|
36
33
|
results: MatTableDataSource<BaseModel>;
|
|
37
34
|
columns: ColumnModel[];
|
|
38
35
|
config: NiceComponentLibraryConfig;
|
|
36
|
+
protected moduleName: string;
|
|
37
|
+
protected unsubscribe$: Subject<void>;
|
|
38
|
+
protected isResetPaging: boolean;
|
|
39
39
|
constructor(router: Router, apiService: ApiService, utilsService: UtilsService, formStateService: FormStateService, translateService: TranslateService, injector: Injector, activatedRoute: ActivatedRoute, authoritiesService: AuthoritiesService, formGroup: FormGroup);
|
|
40
40
|
ngOnInit(): void;
|
|
41
41
|
ngAfterViewInit(): void;
|
|
@@ -43,9 +43,6 @@ export declare class BaseSearchComponent extends BaseTableComponent implements O
|
|
|
43
43
|
onSubmit(): void;
|
|
44
44
|
search(): void;
|
|
45
45
|
afterSearch: (data: TablePagingResponseModel) => void;
|
|
46
|
-
private afterFillData;
|
|
47
|
-
private removeEmptyParams;
|
|
48
|
-
private updateHttpParams;
|
|
49
46
|
_fillData(nativeUrl: string, params: HttpParams, baseUrl?: string): void;
|
|
50
47
|
_fillDataByPostMethod(nativeUrl: string, obj: any, options: {
|
|
51
48
|
headers?: HttpHeaders;
|
|
@@ -57,6 +54,9 @@ export declare class BaseSearchComponent extends BaseTableComponent implements O
|
|
|
57
54
|
resetSearchFormValue(): void;
|
|
58
55
|
toggleAdvancedSearch(): void;
|
|
59
56
|
params2Object(params: HttpParams): Object;
|
|
57
|
+
private afterFillData;
|
|
58
|
+
private removeEmptyParams;
|
|
59
|
+
private updateHttpParams;
|
|
60
60
|
static ɵfac: i0.ɵɵFactoryDeclaration<BaseSearchComponent, never>;
|
|
61
61
|
static ɵdir: i0.ɵɵDirectiveDeclaration<BaseSearchComponent, "BaseSearchComponent", never, {}, {}, never, never, false, never>;
|
|
62
62
|
}
|
|
@@ -241,9 +241,12 @@ class Authority {
|
|
|
241
241
|
|
|
242
242
|
class TablePagingResponseModel {
|
|
243
243
|
content = [];
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
page = {
|
|
245
|
+
size: null,
|
|
246
|
+
number: null,
|
|
247
|
+
totalElements: null,
|
|
248
|
+
totalPages: null,
|
|
249
|
+
};
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
class TablePagingRequestModel {
|
|
@@ -1023,6 +1026,12 @@ class ApiService {
|
|
|
1023
1026
|
getJSON(file) {
|
|
1024
1027
|
return this.http.get(file);
|
|
1025
1028
|
}
|
|
1029
|
+
getBlob(nativeUrl, params, baseUrl) {
|
|
1030
|
+
const url = baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl);
|
|
1031
|
+
return this.http.get(url, {
|
|
1032
|
+
responseType: 'blob', // Đặt responseType thành 'blob'
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1026
1035
|
post(nativeUrl, obj, options, baseUrl) {
|
|
1027
1036
|
return this.http.post(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, options ? {
|
|
1028
1037
|
headers: options.headers,
|
|
@@ -1139,15 +1148,15 @@ class BaseSearchComponent extends BaseTableComponent {
|
|
|
1139
1148
|
activatedRoute;
|
|
1140
1149
|
authoritiesService;
|
|
1141
1150
|
formGroup;
|
|
1142
|
-
moduleName = '';
|
|
1143
|
-
unsubscribe$ = new Subject();
|
|
1144
|
-
isResetPaging = true;
|
|
1145
1151
|
isAdvancedSearch = false;
|
|
1146
1152
|
searchForm;
|
|
1147
1153
|
paging;
|
|
1148
1154
|
results = new MatTableDataSource([]);
|
|
1149
1155
|
columns = [];
|
|
1150
1156
|
config;
|
|
1157
|
+
moduleName = '';
|
|
1158
|
+
unsubscribe$ = new Subject();
|
|
1159
|
+
isResetPaging = true;
|
|
1151
1160
|
constructor(router, apiService, utilsService, formStateService, translateService, injector, activatedRoute, authoritiesService, formGroup) {
|
|
1152
1161
|
super(activatedRoute, authoritiesService);
|
|
1153
1162
|
this.router = router;
|
|
@@ -1223,41 +1232,6 @@ class BaseSearchComponent extends BaseTableComponent {
|
|
|
1223
1232
|
afterSearch = (data) => {
|
|
1224
1233
|
// Form extends will be override custom by business
|
|
1225
1234
|
};
|
|
1226
|
-
afterFillData = (data) => {
|
|
1227
|
-
this.isResetPaging = false;
|
|
1228
|
-
if (data.content && data.content.length > 0) {
|
|
1229
|
-
this.columns.forEach((column) => {
|
|
1230
|
-
column.isShowHeader = false;
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
this.afterSearch(data);
|
|
1234
|
-
this.results = new MatTableDataSource(data.content);
|
|
1235
|
-
this.paging = new TablePagingRequestModel();
|
|
1236
|
-
this.paging.pageSize = data.size ? data.size : 0;
|
|
1237
|
-
this.paging.pageNumber = (data.number ? data.number : 0) + 1;
|
|
1238
|
-
this.paging.totalElements = data.totalElements ? data.totalElements : 0;
|
|
1239
|
-
};
|
|
1240
|
-
removeEmptyParams(params) {
|
|
1241
|
-
params.keys().forEach(key => {
|
|
1242
|
-
const value = params.get(key) ? params.get(key) + '' : '';
|
|
1243
|
-
if (value) {
|
|
1244
|
-
params = params.set(key, value.trim());
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
const emptyValuesKey = params.keys().filter(key => !params.get(key));
|
|
1248
|
-
emptyValuesKey.forEach(key => {
|
|
1249
|
-
params = params.delete(key);
|
|
1250
|
-
});
|
|
1251
|
-
return params;
|
|
1252
|
-
}
|
|
1253
|
-
updateHttpParams(params) {
|
|
1254
|
-
params = this.removeEmptyParams(params);
|
|
1255
|
-
if (!params.keys().includes('pageNumber')) {
|
|
1256
|
-
params = params.append('pageNumber', this.isResetPaging ? '1' : (this.paging ? this.paging.pageNumber.toString() : '1'))
|
|
1257
|
-
.append('pageSize', this.paging ? this.paging.pageSize.toString() : this.config.PAGE_SIZE.toString());
|
|
1258
|
-
}
|
|
1259
|
-
return params;
|
|
1260
|
-
}
|
|
1261
1235
|
_fillData(nativeUrl, params, baseUrl) {
|
|
1262
1236
|
params = this.updateHttpParams(params);
|
|
1263
1237
|
this.apiService.get(nativeUrl, params, baseUrl).subscribe(this.afterFillData);
|
|
@@ -1307,6 +1281,41 @@ class BaseSearchComponent extends BaseTableComponent {
|
|
|
1307
1281
|
});
|
|
1308
1282
|
return result;
|
|
1309
1283
|
}
|
|
1284
|
+
afterFillData = (data) => {
|
|
1285
|
+
this.isResetPaging = false;
|
|
1286
|
+
if (data.content && data.content.length > 0) {
|
|
1287
|
+
this.columns.forEach((column) => {
|
|
1288
|
+
column.isShowHeader = false;
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
this.afterSearch(data);
|
|
1292
|
+
this.results = new MatTableDataSource(data.content);
|
|
1293
|
+
this.paging = new TablePagingRequestModel();
|
|
1294
|
+
this.paging.pageSize = data.page.size ? data.page.size : 0;
|
|
1295
|
+
this.paging.pageNumber = (data.page.number ? data.page.number : 0) + 1;
|
|
1296
|
+
this.paging.totalElements = data.page.totalElements ? data.page.totalElements : 0;
|
|
1297
|
+
};
|
|
1298
|
+
removeEmptyParams(params) {
|
|
1299
|
+
params.keys().forEach(key => {
|
|
1300
|
+
const value = params.get(key) ? params.get(key) + '' : '';
|
|
1301
|
+
if (value) {
|
|
1302
|
+
params = params.set(key, value.trim());
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
const emptyValuesKey = params.keys().filter(key => !params.get(key));
|
|
1306
|
+
emptyValuesKey.forEach(key => {
|
|
1307
|
+
params = params.delete(key);
|
|
1308
|
+
});
|
|
1309
|
+
return params;
|
|
1310
|
+
}
|
|
1311
|
+
updateHttpParams(params) {
|
|
1312
|
+
params = this.removeEmptyParams(params);
|
|
1313
|
+
if (!params.keys().includes('pageNumber')) {
|
|
1314
|
+
params = params.append('pageNumber', this.isResetPaging ? '1' : (this.paging ? this.paging.pageNumber.toString() : '1'))
|
|
1315
|
+
.append('pageSize', this.paging ? this.paging.pageSize.toString() : this.config.PAGE_SIZE.toString());
|
|
1316
|
+
}
|
|
1317
|
+
return params;
|
|
1318
|
+
}
|
|
1310
1319
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: BaseSearchComponent, deps: [{ token: i1$4.Router }, { token: ApiService }, { token: UtilsService }, { token: FormStateService }, { token: i1.TranslateService }, { token: i0.Injector }, { token: i1$4.ActivatedRoute }, { token: AuthoritiesService }, { token: i1$2.FormGroup }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1311
1320
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: BaseSearchComponent, isStandalone: false, selector: "BaseSearchComponent", usesInheritance: true, ngImport: i0 });
|
|
1312
1321
|
}
|