@zeedhi/teknisa-components-common 1.100.0 → 1.101.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 +364 -363
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
- 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 +677 -674
- package/dist/tek-components-common.esm.js +3 -0
- package/dist/tek-components-common.umd.js +3 -0
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +180 -0
- package/types/components/tek-grid/grid.d.ts +1 -0
|
@@ -2345,6 +2345,9 @@ class TekGrid extends GridEditable {
|
|
|
2345
2345
|
return undefined;
|
|
2346
2346
|
return Metadata.getInstance(`${this.name}_layout_options`);
|
|
2347
2347
|
}
|
|
2348
|
+
instantiateCancelColumn() {
|
|
2349
|
+
return new TekGridColumn(this.getCancelColumnProps(), this);
|
|
2350
|
+
}
|
|
2348
2351
|
/**
|
|
2349
2352
|
* Get Grid columns objects
|
|
2350
2353
|
* @param columns Grid columns parameter
|
|
@@ -2349,6 +2349,9 @@
|
|
|
2349
2349
|
return undefined;
|
|
2350
2350
|
return core.Metadata.getInstance(`${this.name}_layout_options`);
|
|
2351
2351
|
}
|
|
2352
|
+
instantiateCancelColumn() {
|
|
2353
|
+
return new TekGridColumn(this.getCancelColumnProps(), this);
|
|
2354
|
+
}
|
|
2352
2355
|
/**
|
|
2353
2356
|
* Get Grid columns objects
|
|
2354
2357
|
* @param columns Grid columns parameter
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.101.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": "3f82864e80221862860677508fae4f57d07837ad"
|
|
36
36
|
}
|
|
@@ -2034,6 +2034,79 @@ describe('TekGrid', () => {
|
|
|
2034
2034
|
});
|
|
2035
2035
|
});
|
|
2036
2036
|
|
|
2037
|
+
describe('rowDoubleClick', () => {
|
|
2038
|
+
it('rowDoubleClick method should call events.rowDoubleClick', () => {
|
|
2039
|
+
const rowDoubleClick = jest.fn();
|
|
2040
|
+
|
|
2041
|
+
const data = [
|
|
2042
|
+
{ id: '1', name: 'First' },
|
|
2043
|
+
{ id: '2', name: 'Second' },
|
|
2044
|
+
{ id: '3', name: 'Third' },
|
|
2045
|
+
];
|
|
2046
|
+
const grid = new TekGrid({
|
|
2047
|
+
name: 'grid',
|
|
2048
|
+
component: 'TekGrid',
|
|
2049
|
+
columns: [
|
|
2050
|
+
{ name: 'id' },
|
|
2051
|
+
{ name: 'name' },
|
|
2052
|
+
],
|
|
2053
|
+
datasource: {
|
|
2054
|
+
data,
|
|
2055
|
+
},
|
|
2056
|
+
events: {
|
|
2057
|
+
rowDoubleClick,
|
|
2058
|
+
},
|
|
2059
|
+
});
|
|
2060
|
+
|
|
2061
|
+
const event = new Event('dblclick');
|
|
2062
|
+
const element = document.createElement('div');
|
|
2063
|
+
grid.rowDoubleClick(data[0], event, element);
|
|
2064
|
+
|
|
2065
|
+
expect(rowDoubleClick).toHaveBeenCalledWith({
|
|
2066
|
+
event,
|
|
2067
|
+
element,
|
|
2068
|
+
row: data[0],
|
|
2069
|
+
component: grid,
|
|
2070
|
+
});
|
|
2071
|
+
expect(grid.datasource.currentRow).toEqual(data[0]);
|
|
2072
|
+
});
|
|
2073
|
+
|
|
2074
|
+
it('should not call events.rowDoubleClick if preventRowDoubleClick is true', () => {
|
|
2075
|
+
const rowDoubleClick = jest.fn();
|
|
2076
|
+
const cellDoubleClickHandler = jest.fn(() => true);
|
|
2077
|
+
|
|
2078
|
+
const data = [
|
|
2079
|
+
{ id: '1', name: 'First' },
|
|
2080
|
+
{ id: '2', name: 'Second' },
|
|
2081
|
+
{ id: '3', name: 'Third' },
|
|
2082
|
+
];
|
|
2083
|
+
const grid = new TekGrid({
|
|
2084
|
+
name: 'grid',
|
|
2085
|
+
component: 'TekGrid',
|
|
2086
|
+
columns: [
|
|
2087
|
+
{ name: 'id' },
|
|
2088
|
+
{ name: 'name' },
|
|
2089
|
+
],
|
|
2090
|
+
datasource: {
|
|
2091
|
+
data,
|
|
2092
|
+
},
|
|
2093
|
+
events: {
|
|
2094
|
+
rowDoubleClick,
|
|
2095
|
+
cellDoubleClick: cellDoubleClickHandler,
|
|
2096
|
+
},
|
|
2097
|
+
});
|
|
2098
|
+
|
|
2099
|
+
const event = new Event('dblclick');
|
|
2100
|
+
const element = document.createElement('div');
|
|
2101
|
+
|
|
2102
|
+
grid.cellDoubleClick(grid.groupedData[0], grid.getColumn('id') as any, event, element);
|
|
2103
|
+
grid.rowDoubleClick(data[0], event, element);
|
|
2104
|
+
|
|
2105
|
+
expect(rowDoubleClick).not.toHaveBeenCalled();
|
|
2106
|
+
expect(grid.datasource.currentRow).toEqual({});
|
|
2107
|
+
});
|
|
2108
|
+
});
|
|
2109
|
+
|
|
2037
2110
|
describe('groupRowClick', () => {
|
|
2038
2111
|
it('groupRowClick method should call events.groupRowClick', async () => {
|
|
2039
2112
|
const groupRowClick = jest.fn();
|
|
@@ -2109,6 +2182,84 @@ describe('TekGrid', () => {
|
|
|
2109
2182
|
});
|
|
2110
2183
|
});
|
|
2111
2184
|
|
|
2185
|
+
describe('groupRowDoubleClick', () => {
|
|
2186
|
+
it('groupRowDoubleClick method should call events.groupRowDoubleClick', async () => {
|
|
2187
|
+
const groupRowDoubleClick = jest.fn();
|
|
2188
|
+
|
|
2189
|
+
const data = [
|
|
2190
|
+
{ id: '1', name: 'First', department: 1 },
|
|
2191
|
+
{ id: '2', name: 'Second', department: 1 },
|
|
2192
|
+
{ id: '3', name: 'Third', department: 1 },
|
|
2193
|
+
];
|
|
2194
|
+
const grid = new TekGrid({
|
|
2195
|
+
name: 'grid',
|
|
2196
|
+
component: 'TekGrid',
|
|
2197
|
+
columns: [
|
|
2198
|
+
{ name: 'id' },
|
|
2199
|
+
{ name: 'name' },
|
|
2200
|
+
{ name: 'department', grouped: true },
|
|
2201
|
+
],
|
|
2202
|
+
datasource: {
|
|
2203
|
+
data,
|
|
2204
|
+
},
|
|
2205
|
+
events: {
|
|
2206
|
+
groupRowDoubleClick,
|
|
2207
|
+
},
|
|
2208
|
+
});
|
|
2209
|
+
|
|
2210
|
+
await flushPromises();
|
|
2211
|
+
|
|
2212
|
+
const event = new Event('dblclick');
|
|
2213
|
+
const element = document.createElement('div');
|
|
2214
|
+
grid.groupRowDoubleClick(grid.groupedData[0], event, element);
|
|
2215
|
+
|
|
2216
|
+
expect(groupRowDoubleClick).toHaveBeenCalledWith({
|
|
2217
|
+
event,
|
|
2218
|
+
element,
|
|
2219
|
+
row: grid.groupedData[0],
|
|
2220
|
+
component: grid,
|
|
2221
|
+
});
|
|
2222
|
+
expect(grid.datasource.currentRow).toEqual({});
|
|
2223
|
+
});
|
|
2224
|
+
|
|
2225
|
+
it('should not call events.groupRowDoubleClick if cellDoubleClick prevents it', async () => {
|
|
2226
|
+
const groupRowDoubleClick = jest.fn();
|
|
2227
|
+
const cellDoubleClickHandler = jest.fn(() => true);
|
|
2228
|
+
|
|
2229
|
+
const data = [
|
|
2230
|
+
{ id: '1', name: 'First', department: 1 },
|
|
2231
|
+
{ id: '2', name: 'Second', department: 1 },
|
|
2232
|
+
{ id: '3', name: 'Third', department: 1 },
|
|
2233
|
+
];
|
|
2234
|
+
const grid = new TekGrid({
|
|
2235
|
+
name: 'grid',
|
|
2236
|
+
component: 'TekGrid',
|
|
2237
|
+
columns: [
|
|
2238
|
+
{ name: 'id' },
|
|
2239
|
+
{ name: 'name' },
|
|
2240
|
+
{ name: 'department', grouped: true },
|
|
2241
|
+
],
|
|
2242
|
+
datasource: {
|
|
2243
|
+
data,
|
|
2244
|
+
},
|
|
2245
|
+
events: {
|
|
2246
|
+
groupRowDoubleClick,
|
|
2247
|
+
cellDoubleClick: cellDoubleClickHandler,
|
|
2248
|
+
},
|
|
2249
|
+
});
|
|
2250
|
+
|
|
2251
|
+
await flushPromises();
|
|
2252
|
+
|
|
2253
|
+
const event = new Event('dblclick');
|
|
2254
|
+
const element = document.createElement('div');
|
|
2255
|
+
|
|
2256
|
+
grid.cellDoubleClick(grid.groupedData[0], grid.getColumn('id') as any, event, element);
|
|
2257
|
+
grid.groupRowDoubleClick(grid.groupedData[0], event, element);
|
|
2258
|
+
|
|
2259
|
+
expect(groupRowDoubleClick).not.toHaveBeenCalled();
|
|
2260
|
+
});
|
|
2261
|
+
});
|
|
2262
|
+
|
|
2112
2263
|
describe('selectGroupClick', () => {
|
|
2113
2264
|
it('should trigger events', async () => {
|
|
2114
2265
|
const groupSelected = jest.fn();
|
|
@@ -2365,4 +2516,33 @@ describe('TekGrid', () => {
|
|
|
2365
2516
|
expect(instance.isColumnSearchable(column)).toBeTruthy();
|
|
2366
2517
|
});
|
|
2367
2518
|
});
|
|
2519
|
+
|
|
2520
|
+
describe('cancel column', () => {
|
|
2521
|
+
it('should instantiate grid with a cancel column', () => {
|
|
2522
|
+
const grid = new TekGrid({
|
|
2523
|
+
name: 'grid',
|
|
2524
|
+
component: 'TekGrid',
|
|
2525
|
+
showCancelColumn: true,
|
|
2526
|
+
columns: [
|
|
2527
|
+
{ name: 'name' },
|
|
2528
|
+
],
|
|
2529
|
+
datasource: { data: [{ id: '1' }], uniqueKey: 'id' },
|
|
2530
|
+
});
|
|
2531
|
+
const spy = jest.fn();
|
|
2532
|
+
grid.cancelAddedRow = spy;
|
|
2533
|
+
|
|
2534
|
+
expect(grid.columns.length).toBe(2);
|
|
2535
|
+
expect(grid.columns[1].name).toBe('cancel_action_grid');
|
|
2536
|
+
|
|
2537
|
+
const comp: any = grid.getActionComponent(
|
|
2538
|
+
grid.columns[1].children[0],
|
|
2539
|
+
grid.columns[1],
|
|
2540
|
+
grid.datasource.data[0],
|
|
2541
|
+
);
|
|
2542
|
+
const btn = new Button(comp);
|
|
2543
|
+
btn.click();
|
|
2544
|
+
|
|
2545
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
2546
|
+
});
|
|
2547
|
+
});
|
|
2368
2548
|
});
|
|
@@ -90,6 +90,7 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
90
90
|
onBeforeDestroy(): void;
|
|
91
91
|
protected focusSearchInput(): void;
|
|
92
92
|
get layoutOptions(): TekGridLayoutOptions | undefined;
|
|
93
|
+
protected instantiateCancelColumn(): TekGridColumn;
|
|
93
94
|
/**
|
|
94
95
|
* Get Grid columns objects
|
|
95
96
|
* @param columns Grid columns parameter
|