@zeedhi/teknisa-components-common 1.97.0 → 1.97.3
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 +372 -364
- package/coverage/coverage-final.json +4 -4
- 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 +692 -678
- package/dist/tek-components-common.esm.js +17 -4
- package/dist/tek-components-common.umd.js +16 -3
- package/package.json +2 -2
- package/tests/unit/components/tek-grid/grid.spec.ts +25 -0
- package/types/components/tek-grid/grid.d.ts +4 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Config, Loader, DateHelper, Http, Singleton, VersionService } from '@zeedhi/core';
|
|
1
|
+
import { KeyMap, I18n, FormatterParserProvider, Messages, DatasourceFactory, Metadata, MemoryDatasource, URL, Utils, RestDatasource, Config, Accessor, Loader, DateHelper, Http, Singleton, VersionService } from '@zeedhi/core';
|
|
2
2
|
import { Form, Button, Tooltip, GridEditable, Grid, ComponentRender, Iterable, Carousel, IterableComponentRender as IterableComponentRender$1, Loading as Loading$1, GridColumnEditable, Report, ColumnNotFoundError, IterableColumnsButtonController, IterableColumnsButton, ModalService, SelectMultiple, TreeGridEditable, List } from '@zeedhi/common';
|
|
3
3
|
import debounce from 'lodash.debounce';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
@@ -2108,8 +2108,7 @@ class TekGrid extends GridEditable {
|
|
|
2108
2108
|
* @param props TekGrid properties
|
|
2109
2109
|
*/
|
|
2110
2110
|
constructor(props) {
|
|
2111
|
-
|
|
2112
|
-
super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true }) }));
|
|
2111
|
+
super(props);
|
|
2113
2112
|
/* Grid Title */
|
|
2114
2113
|
this.title = '';
|
|
2115
2114
|
/* Show Add button */
|
|
@@ -2292,10 +2291,24 @@ class TekGrid extends GridEditable {
|
|
|
2292
2291
|
},
|
|
2293
2292
|
};
|
|
2294
2293
|
this.createAccessors();
|
|
2294
|
+
this.defaultLazy = this.getDefaultLazy(props);
|
|
2295
2295
|
this.gridBase = new GridBase(this);
|
|
2296
2296
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2297
2297
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2298
|
-
|
|
2298
|
+
}
|
|
2299
|
+
getDatasourceDefaults() {
|
|
2300
|
+
return { lazyLoad: true };
|
|
2301
|
+
}
|
|
2302
|
+
getDefaultLazy(props) {
|
|
2303
|
+
if (typeof props.datasource === 'object') {
|
|
2304
|
+
return props.datasource.lazyLoad;
|
|
2305
|
+
}
|
|
2306
|
+
if (typeof props.datasource === 'string' && Accessor.isAccessorDefinition(props.datasource)) {
|
|
2307
|
+
const [controller, accessor] = Accessor.getAccessor(props.datasource);
|
|
2308
|
+
const instance = Loader.getInstance(controller);
|
|
2309
|
+
return instance[accessor].lazyLoad || false;
|
|
2310
|
+
}
|
|
2311
|
+
return false;
|
|
2299
2312
|
}
|
|
2300
2313
|
onCreated() {
|
|
2301
2314
|
super.onCreated();
|
|
@@ -2112,8 +2112,7 @@
|
|
|
2112
2112
|
* @param props TekGrid properties
|
|
2113
2113
|
*/
|
|
2114
2114
|
constructor(props) {
|
|
2115
|
-
|
|
2116
|
-
super(Object.assign(Object.assign({}, props), { datasource: Object.assign(Object.assign({}, props.datasource), { lazyLoad: true }) }));
|
|
2115
|
+
super(props);
|
|
2117
2116
|
/* Grid Title */
|
|
2118
2117
|
this.title = '';
|
|
2119
2118
|
/* Show Add button */
|
|
@@ -2296,10 +2295,24 @@
|
|
|
2296
2295
|
},
|
|
2297
2296
|
};
|
|
2298
2297
|
this.createAccessors();
|
|
2298
|
+
this.defaultLazy = this.getDefaultLazy(props);
|
|
2299
2299
|
this.gridBase = new GridBase(this);
|
|
2300
2300
|
this.filterOperationsDatasource = this.gridBase.getFilterOperationsDatasource();
|
|
2301
2301
|
this.filterRelationsDatasource = this.gridBase.getFilterRelationsDatasource();
|
|
2302
|
-
|
|
2302
|
+
}
|
|
2303
|
+
getDatasourceDefaults() {
|
|
2304
|
+
return { lazyLoad: true };
|
|
2305
|
+
}
|
|
2306
|
+
getDefaultLazy(props) {
|
|
2307
|
+
if (typeof props.datasource === 'object') {
|
|
2308
|
+
return props.datasource.lazyLoad;
|
|
2309
|
+
}
|
|
2310
|
+
if (typeof props.datasource === 'string' && core.Accessor.isAccessorDefinition(props.datasource)) {
|
|
2311
|
+
const [controller, accessor] = core.Accessor.getAccessor(props.datasource);
|
|
2312
|
+
const instance = core.Loader.getInstance(controller);
|
|
2313
|
+
return instance[accessor].lazyLoad || false;
|
|
2314
|
+
}
|
|
2315
|
+
return false;
|
|
2303
2316
|
}
|
|
2304
2317
|
onCreated() {
|
|
2305
2318
|
super.onCreated();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "1.97.
|
|
3
|
+
"version": "1.97.3",
|
|
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": "2aea0238fb3917e862b21fd096f2851f74e44337"
|
|
36
36
|
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
} from '@zeedhi/common';
|
|
6
6
|
import {
|
|
7
7
|
KeyMap, Http, Metadata, IDictionary, IEventParam,
|
|
8
|
+
Datasource,
|
|
9
|
+
init,
|
|
8
10
|
} from '@zeedhi/core';
|
|
9
11
|
import {
|
|
10
12
|
ITekGrid,
|
|
@@ -19,6 +21,13 @@ jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
|
19
21
|
|
|
20
22
|
jest.useFakeTimers();
|
|
21
23
|
|
|
24
|
+
class AppController {
|
|
25
|
+
public datasource = {
|
|
26
|
+
uniqueKey: 'id',
|
|
27
|
+
data: [{ id: '1' }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
const clickOnFilterButton = (grid: TekGrid, event?: any) => {
|
|
23
32
|
const buttonProps = getChild<ITekGridFilterButton>(grid.toolbarSlot, `${grid.name}_filterButton`);
|
|
24
33
|
const filterButton = new TekGridFilterButton(buttonProps);
|
|
@@ -177,6 +186,22 @@ describe('TekGrid', () => {
|
|
|
177
186
|
expect((instance as any).gridBase.exportConfigButtons[0].flat).toBeTruthy();
|
|
178
187
|
expect((instance as any).gridBase.exportConfigButtons[0].events).toBeDefined();
|
|
179
188
|
});
|
|
189
|
+
|
|
190
|
+
it('should create new TekGrid with accessor datasource', () => {
|
|
191
|
+
init({
|
|
192
|
+
controllers: {
|
|
193
|
+
AppController,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const instance = new TekGrid({
|
|
197
|
+
name: 'grid',
|
|
198
|
+
component: 'TekGrid',
|
|
199
|
+
datasource: '{{AppController.datasource}}' as any,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect(instance.datasource).toBeInstanceOf(Datasource);
|
|
203
|
+
expect(instance.datasource.data).toEqual([{ id: '1' }]);
|
|
204
|
+
});
|
|
180
205
|
});
|
|
181
206
|
|
|
182
207
|
describe('getReport()', () => {
|
|
@@ -79,7 +79,11 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
|
|
|
79
79
|
* @param props TekGrid properties
|
|
80
80
|
*/
|
|
81
81
|
constructor(props: ITekGrid);
|
|
82
|
+
protected getDatasourceDefaults(): {
|
|
83
|
+
lazyLoad: boolean;
|
|
84
|
+
};
|
|
82
85
|
private defaultLazy;
|
|
86
|
+
private getDefaultLazy;
|
|
83
87
|
onCreated(): void;
|
|
84
88
|
onMounted(element: HTMLElement): void;
|
|
85
89
|
onBeforeDestroy(): void;
|