@zeedhi/teknisa-components-common 1.109.0 → 1.110.0
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/coverage/clover.xml +603 -601
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +9 -9
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +1048 -1044
- package/dist/tek-components-common.esm.js +10 -2
- package/dist/tek-components-common.umd.js +10 -2
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +33 -4
- package/types/components/tek-datasource/rest-datasource.d.ts +7 -6
- package/types/components/tek-grid/grid.d.ts +2 -1
- package/types/components/tek-grid/interfaces.d.ts +2 -1
|
@@ -966,6 +966,13 @@ class GridBase {
|
|
|
966
966
|
},
|
|
967
967
|
children: this.grid.exportActions || this.exportConfigButtons,
|
|
968
968
|
}),
|
|
969
|
+
actionsDivider: (index) => ({
|
|
970
|
+
name: `${this.grid.name}_divider${index}`,
|
|
971
|
+
component: 'ZdDivider',
|
|
972
|
+
cssClass: 'toolbar-divider',
|
|
973
|
+
vertical: true,
|
|
974
|
+
isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
|
|
975
|
+
}),
|
|
969
976
|
actionsDropdown: () => ({
|
|
970
977
|
name: `${this.grid.name}_actions_dropdown`,
|
|
971
978
|
component: 'ZdDropdown',
|
|
@@ -1074,7 +1081,7 @@ class GridBase {
|
|
|
1074
1081
|
addDefaultToolbarItems(toolbarDivChildren) {
|
|
1075
1082
|
const defaultItems = [
|
|
1076
1083
|
'addButton', 'deleteButton', 'divider', 'refreshButton', 'divider',
|
|
1077
|
-
'columnsButton', 'layoutOptions', 'exportDropdown', '
|
|
1084
|
+
'columnsButton', 'layoutOptions', 'exportDropdown', 'actionsDivider', 'actionsDropdown',
|
|
1078
1085
|
'saveButton', 'cancelButton', 'divider', 'gridSearch', 'filterButton',
|
|
1079
1086
|
];
|
|
1080
1087
|
defaultItems.forEach((itemName, index) => {
|
|
@@ -2402,6 +2409,7 @@ class TekGrid extends GridEditable {
|
|
|
2402
2409
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2403
2410
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2404
2411
|
this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);
|
|
2412
|
+
this.reportLabelFormatter = this.getInitValue('reportLabelFormatter', props.reportLabelFormatter, this.reportLabelFormatter);
|
|
2405
2413
|
this.actions = props.actions || this.actions;
|
|
2406
2414
|
this.toolbarSlotProps = props.toolbarSlot !== undefined;
|
|
2407
2415
|
if (this.deleteButton === 'selection') {
|
|
@@ -2587,7 +2595,7 @@ class TekGrid extends GridEditable {
|
|
|
2587
2595
|
columns: reportAggregations,
|
|
2588
2596
|
xlsDefaultType: this.xlsDefaultType,
|
|
2589
2597
|
}),
|
|
2590
|
-
}, beforeOpen);
|
|
2598
|
+
}, beforeOpen, this.reportLabelFormatter);
|
|
2591
2599
|
window.open(reportUrl);
|
|
2592
2600
|
}
|
|
2593
2601
|
catch (e) {
|
|
@@ -970,6 +970,13 @@
|
|
|
970
970
|
},
|
|
971
971
|
children: this.grid.exportActions || this.exportConfigButtons,
|
|
972
972
|
}),
|
|
973
|
+
actionsDivider: (index) => ({
|
|
974
|
+
name: `${this.grid.name}_divider${index}`,
|
|
975
|
+
component: 'ZdDivider',
|
|
976
|
+
cssClass: 'toolbar-divider',
|
|
977
|
+
vertical: true,
|
|
978
|
+
isVisible: `{{GridController_${this.grid.componentId}.showActionsButton}}`,
|
|
979
|
+
}),
|
|
973
980
|
actionsDropdown: () => ({
|
|
974
981
|
name: `${this.grid.name}_actions_dropdown`,
|
|
975
982
|
component: 'ZdDropdown',
|
|
@@ -1078,7 +1085,7 @@
|
|
|
1078
1085
|
addDefaultToolbarItems(toolbarDivChildren) {
|
|
1079
1086
|
const defaultItems = [
|
|
1080
1087
|
'addButton', 'deleteButton', 'divider', 'refreshButton', 'divider',
|
|
1081
|
-
'columnsButton', 'layoutOptions', 'exportDropdown', '
|
|
1088
|
+
'columnsButton', 'layoutOptions', 'exportDropdown', 'actionsDivider', 'actionsDropdown',
|
|
1082
1089
|
'saveButton', 'cancelButton', 'divider', 'gridSearch', 'filterButton',
|
|
1083
1090
|
];
|
|
1084
1091
|
defaultItems.forEach((itemName, index) => {
|
|
@@ -2406,6 +2413,7 @@
|
|
|
2406
2413
|
this.editNewRowsOnly = this.getInitValue('editNewRowsOnly', props.editNewRowsOnly, this.editNewRowsOnly);
|
|
2407
2414
|
this.mainGrid = this.getInitValue('mainGrid', props.mainGrid, this.mainGrid);
|
|
2408
2415
|
this.reportTitle = this.getInitValue('reportTitle', props.reportTitle, this.reportTitle);
|
|
2416
|
+
this.reportLabelFormatter = this.getInitValue('reportLabelFormatter', props.reportLabelFormatter, this.reportLabelFormatter);
|
|
2409
2417
|
this.actions = props.actions || this.actions;
|
|
2410
2418
|
this.toolbarSlotProps = props.toolbarSlot !== undefined;
|
|
2411
2419
|
if (this.deleteButton === 'selection') {
|
|
@@ -2591,7 +2599,7 @@
|
|
|
2591
2599
|
columns: reportAggregations,
|
|
2592
2600
|
xlsDefaultType: this.xlsDefaultType,
|
|
2593
2601
|
}),
|
|
2594
|
-
}, beforeOpen);
|
|
2602
|
+
}, beforeOpen, this.reportLabelFormatter);
|
|
2595
2603
|
window.open(reportUrl);
|
|
2596
2604
|
}
|
|
2597
2605
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.110.0",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@zeedhi/core": "^1.97.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "5dc8ed0a31eac861718475f4fd2e65ab0da772cc"
|
|
36
36
|
}
|
|
@@ -311,6 +311,34 @@ describe('TekGrid', () => {
|
|
|
311
311
|
spy.mockReset();
|
|
312
312
|
});
|
|
313
313
|
|
|
314
|
+
it('when reportLabelFormatter is defined, it should be passed to getReport', async () => {
|
|
315
|
+
(window as any).open = jest.fn();
|
|
316
|
+
const reportLabelFormatter = jest.fn();
|
|
317
|
+
const spy = jest.spyOn(Report.prototype, 'getReport').mockImplementationOnce(async () => '');
|
|
318
|
+
|
|
319
|
+
const instance = new TekGrid({
|
|
320
|
+
reportLabelFormatter,
|
|
321
|
+
name: 'grid',
|
|
322
|
+
component: 'TekGrid',
|
|
323
|
+
columns: [
|
|
324
|
+
{
|
|
325
|
+
name: 'id',
|
|
326
|
+
label: 'ID',
|
|
327
|
+
aggregation: 'COUNT',
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'department_id',
|
|
331
|
+
label: 'Department ID',
|
|
332
|
+
grouped: true,
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await instance.getReport('pdf');
|
|
338
|
+
|
|
339
|
+
expect(spy).toHaveBeenLastCalledWith('pdf', undefined, expect.any(Object), undefined, reportLabelFormatter);
|
|
340
|
+
});
|
|
341
|
+
|
|
314
342
|
it('when called with a dynamicFilter, should format the filter values', async () => {
|
|
315
343
|
(window as any).open = jest.fn();
|
|
316
344
|
const spy = jest.spyOn(Report.prototype, 'getReport').mockImplementationOnce(async () => '');
|
|
@@ -399,7 +427,7 @@ describe('TekGrid', () => {
|
|
|
399
427
|
metaData: expect.objectContaining({
|
|
400
428
|
filter,
|
|
401
429
|
}),
|
|
402
|
-
}), undefined);
|
|
430
|
+
}), undefined, undefined);
|
|
403
431
|
(window as any).open.mockClear();
|
|
404
432
|
spy.mockReset();
|
|
405
433
|
});
|
|
@@ -465,7 +493,7 @@ describe('TekGrid', () => {
|
|
|
465
493
|
metaData: {
|
|
466
494
|
columns: {}, filter: undefined, groups: [], xlsDefaultType: undefined,
|
|
467
495
|
},
|
|
468
|
-
}, undefined);
|
|
496
|
+
}, undefined, undefined);
|
|
469
497
|
});
|
|
470
498
|
|
|
471
499
|
it('when data is empty, should show alert', async () => {
|
|
@@ -2846,10 +2874,11 @@ describe('TekGrid', () => {
|
|
|
2846
2874
|
],
|
|
2847
2875
|
},
|
|
2848
2876
|
});
|
|
2877
|
+
await instance.datasource.get();
|
|
2849
2878
|
const newRow1 = { id: 2 };
|
|
2850
2879
|
await instance.addNewRow(newRow1, 'start');
|
|
2851
|
-
expect(instance.datasource.data[0]).
|
|
2852
|
-
expect(instance.datasource.data[1]).
|
|
2880
|
+
expect(instance.datasource.data[0]).toMatchObject({ id: 2, __added_row: true });
|
|
2881
|
+
expect(instance.datasource.data[1]).toMatchObject({ id: 1 });
|
|
2853
2882
|
});
|
|
2854
2883
|
|
|
2855
2884
|
it('should add a new row to the groupedData array', async () => {
|
|
@@ -32,36 +32,36 @@ export declare class TekRestDatasource extends RestDatasource implements ITekRes
|
|
|
32
32
|
* @param filtroDinamico
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
|
-
setBaseFilter(filtroDinamico: any): Promise<any>;
|
|
35
|
+
setBaseFilter(filtroDinamico: any): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
36
36
|
/**
|
|
37
37
|
* Adds a new dynamic filter position or replace if exists
|
|
38
38
|
* @param column Dynamic Filter column name
|
|
39
39
|
* @param value Dynamic Filter value
|
|
40
40
|
* @returns Promise with data collection
|
|
41
41
|
*/
|
|
42
|
-
addDynamicFilter(column: string, value: any): Promise<any>;
|
|
42
|
+
addDynamicFilter(column: string, value: any): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
43
43
|
/**
|
|
44
44
|
* Removes a dynamic filter position
|
|
45
45
|
* @param column Dynamic Filter column name
|
|
46
46
|
* @returns Promise with data collection
|
|
47
47
|
*/
|
|
48
|
-
removeDynamicFilter(column: string): Promise<any>;
|
|
48
|
+
removeDynamicFilter(column: string): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
49
49
|
/**
|
|
50
50
|
* Sets new dynamic filter value
|
|
51
51
|
* @param filter Dynamic Filter value
|
|
52
52
|
* @returns Promise with data collection
|
|
53
53
|
*/
|
|
54
|
-
setDynamicFilter(filter: IDictionary<any>): Promise<any>;
|
|
54
|
+
setDynamicFilter(filter: IDictionary<any>): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
55
55
|
/**
|
|
56
56
|
* Clears Dynamic filter value
|
|
57
57
|
* @returns Promise with data collection
|
|
58
58
|
*/
|
|
59
|
-
clearDynamicFilter(): Promise<any>;
|
|
59
|
+
clearDynamicFilter(): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
60
60
|
/**
|
|
61
61
|
* Resets page and selected rows and tries to update the url
|
|
62
62
|
* @returns Promise with data collection
|
|
63
63
|
*/
|
|
64
|
-
updateDynamicFilter(): Promise<any>;
|
|
64
|
+
updateDynamicFilter(): Promise<IDictionary<any> | IDictionary<any>[]>;
|
|
65
65
|
/**
|
|
66
66
|
* Checks if a filter value is valid
|
|
67
67
|
* @param value Filter value
|
|
@@ -81,6 +81,7 @@ export declare class TekRestDatasource extends RestDatasource implements ITekRes
|
|
|
81
81
|
arrayFormat?: "indices" | "brackets" | "repeat" | "comma" | undefined;
|
|
82
82
|
find?: IDictionary<any> | undefined;
|
|
83
83
|
localSearch?: boolean | undefined;
|
|
84
|
+
searchPost?: boolean | undefined;
|
|
84
85
|
currentRow?: IDictionary<any> | undefined;
|
|
85
86
|
data?: IDictionary<any>[] | undefined;
|
|
86
87
|
filter?: IDictionary<any> | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridEditable, IComponentRender, IGridColumnEditable, Input } from '@zeedhi/common';
|
|
1
|
+
import { GridEditable, IComponentRender, IGridColumnEditable, Input, LabelFormatter } from '@zeedhi/common';
|
|
2
2
|
import { Datasource, IDictionary, IEventParam } from '@zeedhi/core';
|
|
3
3
|
import { ITekGridAtoms } from '../../utils';
|
|
4
4
|
import { TekGridColumn } from './grid-column';
|
|
@@ -81,6 +81,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
81
81
|
defaultFilter: IDictionary;
|
|
82
82
|
toolbarOpened: boolean;
|
|
83
83
|
reportTitle: string;
|
|
84
|
+
reportLabelFormatter?: LabelFormatter;
|
|
84
85
|
/**
|
|
85
86
|
* TekGrid class constructor
|
|
86
87
|
* @param props TekGrid properties
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBeforeReportEvent, IComponent, IComponentEvents, IComponentRender, IGridColumnEditable, IGridEditable, IIterableColumnsButton, EventDef, IModal, IButton } from '@zeedhi/common';
|
|
1
|
+
import { IBeforeReportEvent, IComponent, IComponentEvents, IComponentRender, IGridColumnEditable, IGridEditable, IIterableColumnsButton, EventDef, IModal, IButton, LabelFormatter } from '@zeedhi/common';
|
|
2
2
|
import { IDictionary, IEvent, IEventParam, IDateHelperValue, IDateHelperValues } from '@zeedhi/core';
|
|
3
3
|
import { IDynamicFilterItem, TekGrid, TekGridLayoutOptions, TekTreeGrid } from '..';
|
|
4
4
|
export interface ITekGridLayoutEventParams extends IEventParam<ITekGrid> {
|
|
@@ -64,6 +64,7 @@ export interface ITekGrid extends IGridEditable {
|
|
|
64
64
|
xlsDefaultType?: string;
|
|
65
65
|
toolbarOpened?: boolean;
|
|
66
66
|
reportTitle?: string;
|
|
67
|
+
reportLabelFormatter?: LabelFormatter;
|
|
67
68
|
}
|
|
68
69
|
export declare type MultiOptionParams = {
|
|
69
70
|
iconName: string;
|