@zeedhi/teknisa-components-common 3.0.0 → 3.0.1
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/.package.json +4 -1
- package/dist/teknisa-components-common.js +3722 -32
- package/dist/teknisa-components-common.min.js +3722 -32
- package/dist/types/components/index.d.ts +5 -0
- package/dist/types/components/tek-datasource/index.d.ts +3 -0
- package/dist/types/components/tek-datasource/interfaces.d.ts +16 -0
- package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +93 -0
- package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +95 -0
- package/dist/types/components/tek-grid/columns-searcher.d.ts +5 -0
- package/dist/types/components/tek-grid/dynamic-filter-datasource-factory.d.ts +6 -0
- package/dist/types/components/tek-grid/filter-helper.d.ts +7 -0
- package/dist/types/components/tek-grid/grid-filter-button.d.ts +29 -0
- package/dist/types/components/tek-grid/grouped-data-manager.d.ts +82 -0
- package/dist/types/components/tek-grid/grouped-data-selector.d.ts +7 -0
- package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +14 -0
- package/dist/types/components/tek-grid/index.d.ts +18 -0
- package/dist/types/components/tek-grid/interfaces.d.ts +259 -0
- package/dist/types/components/tek-grid/keymap-grouped.d.ts +6 -0
- package/dist/types/components/tek-grid/layout-options.d.ts +39 -0
- package/dist/types/components/tek-grid/tek-grid-column.d.ts +42 -0
- package/dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.d.ts +8 -0
- package/dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.d.ts +13 -0
- package/dist/types/components/tek-grid/tek-grid-controller.d.ts +31 -0
- package/dist/types/components/tek-grid/tek-grid-events.d.ts +31 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.d.ts +17 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/index.d.ts +3 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.d.ts +5 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +12 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/index.d.ts +2 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +22 -0
- package/dist/types/components/tek-grid/tek-grid.d.ts +216 -0
- package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +22 -0
- package/dist/types/components/tek-user-info/interfaces.d.ts +27 -0
- package/dist/types/components/tek-user-info/tek-user-info-list.d.ts +32 -0
- package/dist/types/components/tek-user-info/tek-user-info.d.ts +37 -0
- package/dist/types/error/tek-grid-delete-rows-error.d.ts +7 -0
- package/dist/types/error/teknisa-common-error.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/config/config.d.ts +7 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/is-filled-object/is-filled-object.d.ts +2 -0
- package/dist/types/utils/is-nil.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/index.ts +5 -12
- package/src/components/tek-datasource/index.ts +3 -0
- package/src/components/tek-datasource/interfaces.ts +36 -0
- package/src/components/tek-datasource/tek-memory-datasource.ts +314 -0
- package/src/components/tek-datasource/tek-rest-datasource.ts +224 -0
- package/src/components/tek-grid/columns-searcher.ts +22 -0
- package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +20 -0
- package/src/components/tek-grid/filter-helper.ts +20 -0
- package/src/components/tek-grid/grid-filter-button.ts +419 -0
- package/src/components/tek-grid/grouped-data-manager.ts +448 -0
- package/src/components/tek-grid/grouped-data-selector.ts +40 -0
- package/src/components/tek-grid/grouped-view-navigator.ts +84 -0
- package/src/components/tek-grid/index.ts +18 -0
- package/src/components/tek-grid/interfaces.ts +329 -0
- package/src/components/tek-grid/keymap-grouped.ts +20 -0
- package/src/components/tek-grid/layout-options.ts +248 -0
- package/src/components/tek-grid/tek-grid-column.ts +193 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +28 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +38 -0
- package/src/components/tek-grid/tek-grid-controller.ts +140 -0
- package/src/components/tek-grid/tek-grid-events.ts +105 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +26 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +3 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +6 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +85 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +2 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +365 -0
- package/src/components/tek-grid/tek-grid.ts +1118 -0
- package/src/components/tek-user-info/TekUserInfoController.ts +87 -0
- package/src/components/tek-user-info/interfaces.ts +21 -0
- package/src/components/tek-user-info/tek-user-info-list.ts +64 -0
- package/src/components/tek-user-info/tek-user-info.ts +337 -0
- package/src/error/tek-grid-delete-rows-error.ts +15 -0
- package/src/error/teknisa-common-error.ts +8 -0
- package/src/index.ts +1 -0
- package/src/utils/config/config.ts +8 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/is-filled-object/is-filled-object.ts +5 -0
- package/src/utils/is-nil.ts +3 -0
- package/tests/unit/components/tek-grid/button-option.spec.ts +49 -0
- package/tests/unit/components/tek-grid/columns-searcher.spec.ts +112 -0
- package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +90 -0
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +34 -130
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +110 -241
- package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +593 -0
- package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +136 -0
- package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +244 -0
- package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +20 -0
- package/tests/unit/components/tek-grid/{layout_options.spec.ts → layout-options.spec.ts} +77 -35
- package/tests/unit/components/tek-grid/multi-option.spec.ts +139 -0
- package/tests/unit/components/tek-grid/{grid-column.spec.ts → tek-grid-column.spec.ts} +48 -6
- package/tests/unit/components/tek-grid/{grid-columns-button.spec.ts → tek-grid-columns-button.spec.ts} +42 -9
- package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +253 -0
- package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +186 -0
- package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +34 -0
- package/tests/unit/components/tek-grid/tek-grid.spec.ts +895 -0
- package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +482 -0
- package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +422 -0
- package/src/error/delete-rows-error.ts +0 -11
- package/tests/unit/components/tek-grid/grid.spec.ts +0 -2701
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TekUserInfo } from './tek-user-info';
|
|
2
|
+
|
|
3
|
+
class TekUserInfoController {
|
|
4
|
+
component: TekUserInfo;
|
|
5
|
+
|
|
6
|
+
get versionInfo() {
|
|
7
|
+
return this.component.versionInfo;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(component: TekUserInfo) {
|
|
11
|
+
this.component = component;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get name() {
|
|
15
|
+
return this.versionInfo?.name || '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set name(value: string) {
|
|
19
|
+
if (!this.versionInfo) return;
|
|
20
|
+
this.versionInfo.name = value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get version() {
|
|
24
|
+
return this.versionInfo?.version || '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
set version(value: string) {
|
|
28
|
+
if (!this.versionInfo) return;
|
|
29
|
+
this.versionInfo.version = value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get hasDefaultEmail() {
|
|
33
|
+
return !!this.component.defaultEmail;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get hasAboutImage() {
|
|
37
|
+
return !!this.component.aboutImage;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
mergeText(name: string, version: string) {
|
|
41
|
+
return `<li>${name} - <b>${version}</b></li>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get mainVersion() {
|
|
45
|
+
if (!this.versionInfo?.name || !this.versionInfo.version) return '';
|
|
46
|
+
|
|
47
|
+
return `${this.versionInfo.name} - <b>${this.versionInfo.version}</b>`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected getItems(tab: 'frontend' | 'backend' | 'modules') {
|
|
51
|
+
if (!this.versionInfo) return [];
|
|
52
|
+
|
|
53
|
+
const tabInfo = this.versionInfo[tab];
|
|
54
|
+
|
|
55
|
+
return `<ul>${tabInfo.map((item) => this.mergeText(item.name, item.version)).join('')}</ul>`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get frontendItems() {
|
|
59
|
+
return this.getItems('frontend');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get backendItems() {
|
|
63
|
+
return this.getItems('backend');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get modulesItems() {
|
|
67
|
+
return this.getItems('modules');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get showReportError() {
|
|
71
|
+
const { reportError } = this.component.visibleItems;
|
|
72
|
+
return reportError || reportError === undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get showVersionInfo() {
|
|
76
|
+
const { versionInfo } = this.component.visibleItems;
|
|
77
|
+
return versionInfo || versionInfo === undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get showAbout() {
|
|
81
|
+
const { about } = this.component.visibleItems;
|
|
82
|
+
return about || about === undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { TekUserInfoController };
|
|
87
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IList } from '@zeedhi/common';
|
|
2
|
+
import { IUserInfo } from '@zeedhi/zd-user-info-common';
|
|
3
|
+
|
|
4
|
+
export interface IVersionInfo {
|
|
5
|
+
name: string,
|
|
6
|
+
version: string,
|
|
7
|
+
frontend: { name: string, version: string }[],
|
|
8
|
+
backend: { name: string, version: string }[],
|
|
9
|
+
modules: { name: string, version: string }[],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ITekUserInfo extends IUserInfo {
|
|
13
|
+
aboutImage?: string;
|
|
14
|
+
defaultEmail?: string;
|
|
15
|
+
versionInfo?: IVersionInfo | null;
|
|
16
|
+
versionUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ITekUserInfoList extends IList {
|
|
20
|
+
parentName?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { List } from '@zeedhi/common';
|
|
2
|
+
import { Metadata } from '@zeedhi/core';
|
|
3
|
+
import { ITekUserInfoList } from './interfaces';
|
|
4
|
+
import { TekUserInfo } from './tek-user-info';
|
|
5
|
+
|
|
6
|
+
export class TekUserInfoList extends List implements ITekUserInfoList {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the user info component
|
|
9
|
+
*/
|
|
10
|
+
public parentName = '';
|
|
11
|
+
|
|
12
|
+
public dense = true;
|
|
13
|
+
|
|
14
|
+
constructor(props: ITekUserInfoList) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.parentName = props.parentName || '';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
onCreated(): void {
|
|
20
|
+
super.onCreated();
|
|
21
|
+
this.items = this.getItems();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected getItems() {
|
|
25
|
+
const parent = this.parentName ? Metadata.getInstance<TekUserInfo>(this.parentName) : this.parent;
|
|
26
|
+
|
|
27
|
+
if (!(parent instanceof TekUserInfo)) {
|
|
28
|
+
throw Error(`Could not find the TekUserInfo component associated with ${this.name} TekUserInfoList`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
name: `${parent.name}_version`,
|
|
34
|
+
component: 'ZdListItem',
|
|
35
|
+
title: `{{TekUserInfoController_${parent.componentId}.name}}`,
|
|
36
|
+
subtitle: `{{TekUserInfoController_${parent.componentId}.version}}`,
|
|
37
|
+
isVisible: `{{TekUserInfoController_${parent.componentId}.showVersionInfo}}`,
|
|
38
|
+
cssClass: 'zd-px-2',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: `${parent.name}_about`,
|
|
42
|
+
component: 'ZdListItem',
|
|
43
|
+
title: 'TEKUSERINFO_ABOUT',
|
|
44
|
+
prependIcon: 'infoOutline',
|
|
45
|
+
cssClass: 'zd-px-2',
|
|
46
|
+
isVisible: `{{TekUserInfoController_${parent.componentId}.showAbout}}`,
|
|
47
|
+
events: {
|
|
48
|
+
click: () => parent.onAboutClick(),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: `${parent.name}_report`,
|
|
53
|
+
component: 'ZdListItem',
|
|
54
|
+
title: 'TEKUSERINFO_REPORT_ERROR',
|
|
55
|
+
prependIcon: 'mdi-ladybug',
|
|
56
|
+
cssClass: 'zd-px-2',
|
|
57
|
+
isVisible: `{{TekUserInfoController_${parent.componentId}.showReportError}}`,
|
|
58
|
+
events: {
|
|
59
|
+
click: () => parent.onReportClick(),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { Button, Form, IComponentRender, Modal, ModalService } from '@zeedhi/common';
|
|
2
|
+
import {
|
|
3
|
+
Http, IEventParam, Loader, Messages, Metadata,
|
|
4
|
+
} from '@zeedhi/core';
|
|
5
|
+
import { ITekUserInfo, IVersionInfo } from './interfaces';
|
|
6
|
+
import { TekUserInfoController } from './TekUserInfoController';
|
|
7
|
+
import { UserInfo } from '@zeedhi/zd-user-info-common';
|
|
8
|
+
|
|
9
|
+
export class TekUserInfo extends UserInfo implements ITekUserInfo {
|
|
10
|
+
public aboutModal?: Modal;
|
|
11
|
+
|
|
12
|
+
public reportModal?: Modal;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Data about the application version
|
|
16
|
+
*/
|
|
17
|
+
public versionInfo: IVersionInfo | null = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Default email address to be defined in the Report Bug form
|
|
21
|
+
*/
|
|
22
|
+
public defaultEmail = '';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Url from which the version info will be retrieved
|
|
26
|
+
*/
|
|
27
|
+
public versionUrl = '';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Path to the image to be shown on about modal
|
|
31
|
+
*/
|
|
32
|
+
public aboutImage = '';
|
|
33
|
+
|
|
34
|
+
protected propBottomSlot?: IComponentRender[];
|
|
35
|
+
|
|
36
|
+
constructor(props: ITekUserInfo) {
|
|
37
|
+
super(props);
|
|
38
|
+
this.versionInfo = this.getInitValue('versionInfo', props.versionInfo, this.versionInfo);
|
|
39
|
+
this.defaultEmail = this.getInitValue('defaultEmail', props.defaultEmail, this.defaultEmail);
|
|
40
|
+
this.versionUrl = this.getInitValue('versionUrl', props.versionUrl, this.versionUrl);
|
|
41
|
+
this.aboutImage = this.getInitValue('aboutImage', props.aboutImage, this.aboutImage);
|
|
42
|
+
|
|
43
|
+
this.createAccessors();
|
|
44
|
+
this.propBottomSlot = props.bottomSlot;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected getBottomSlot(): IComponentRender[] {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
name: `${this.name}_bottom_list`,
|
|
51
|
+
component: 'TekUserInfoList',
|
|
52
|
+
parentName: this.name,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public onAboutClick() {
|
|
58
|
+
if (!this.aboutModal) {
|
|
59
|
+
this.aboutModal = ModalService.create({
|
|
60
|
+
name: `${this.name}_about_modal`,
|
|
61
|
+
cssClass: 'about-modal',
|
|
62
|
+
grid: { cols: 8, sm: 4, lg: 5 },
|
|
63
|
+
children: [
|
|
64
|
+
{
|
|
65
|
+
name: `${this.name}_about_header`,
|
|
66
|
+
component: 'ZdHeader',
|
|
67
|
+
color: 'transparent',
|
|
68
|
+
padless: true,
|
|
69
|
+
elevation: 0,
|
|
70
|
+
rightSlot: [
|
|
71
|
+
{
|
|
72
|
+
name: `${this.name}_about_close_button`,
|
|
73
|
+
component: 'ZdModalCloseButton',
|
|
74
|
+
small: true,
|
|
75
|
+
modalName: `${this.name}_about_modal`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: `${this.name}_about_row`,
|
|
81
|
+
component: 'ZdTag',
|
|
82
|
+
tag: 'div',
|
|
83
|
+
cssClass: 'zd-justify-center zd-px-6',
|
|
84
|
+
isVisible: `{{TekUserInfoController_${this.componentId}.hasAboutImage}}`,
|
|
85
|
+
children: [
|
|
86
|
+
{
|
|
87
|
+
name: `${this.name}_about_image`,
|
|
88
|
+
component: 'ZdImage',
|
|
89
|
+
width: '100%',
|
|
90
|
+
src: this.aboutImage,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: `${this.name}_version_tabs`,
|
|
96
|
+
cssClass: 'zd-pt-3 zd-tekUserInfo-tab',
|
|
97
|
+
component: 'ZdTabs',
|
|
98
|
+
tabs: [
|
|
99
|
+
{
|
|
100
|
+
name: `${this.name}_version_frontend_tab`,
|
|
101
|
+
tabTitle: 'Frontend',
|
|
102
|
+
children: this.getVersionTree('frontend'),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: `${this.name}_version_backend_tab`,
|
|
106
|
+
tabTitle: 'Backend',
|
|
107
|
+
children: this.getVersionTree('backend'),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: `${this.name}_version_modules_tab`,
|
|
111
|
+
tabTitle: 'Modules',
|
|
112
|
+
children: this.getVersionTree('modules'),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.aboutModal.show();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
protected getVersionTree(tab: 'frontend' | 'backend' | 'modules') {
|
|
124
|
+
if (!this.versionInfo) return [];
|
|
125
|
+
|
|
126
|
+
const main = {
|
|
127
|
+
name: `${this.name}_version_${tab}_main`,
|
|
128
|
+
component: 'ZdText',
|
|
129
|
+
text: `{{TekUserInfoController_${this.componentId}.mainVersion}}`,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const itemsComponent = {
|
|
133
|
+
name: `${this.name}_version_${tab}`,
|
|
134
|
+
component: 'ZdText',
|
|
135
|
+
cssClass: 'zd-pl-4',
|
|
136
|
+
text: `{{TekUserInfoController_${this.componentId}.${tab}Items}}`,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return [main, itemsComponent];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public onReportClick() {
|
|
143
|
+
if (!this.reportModal) {
|
|
144
|
+
this.reportModal = ModalService.create({
|
|
145
|
+
name: `${this.name}_report_modal`,
|
|
146
|
+
children: [
|
|
147
|
+
{
|
|
148
|
+
name: `${this.name}_report_header`,
|
|
149
|
+
component: 'ZdHeader',
|
|
150
|
+
color: 'transparent',
|
|
151
|
+
padless: true,
|
|
152
|
+
elevation: 0,
|
|
153
|
+
leftSlot: [
|
|
154
|
+
{
|
|
155
|
+
name: `${this.name}_report_title`,
|
|
156
|
+
component: 'ZdText',
|
|
157
|
+
text: 'TEKUSERINFO_REPORT_ERROR',
|
|
158
|
+
cssClass: 'zd-theme-font-title',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
rightSlot: [
|
|
162
|
+
{
|
|
163
|
+
name: `${this.name}_report_close_button`,
|
|
164
|
+
component: 'ZdModalCloseButton',
|
|
165
|
+
small: true,
|
|
166
|
+
modalName: `${this.name}_report_modal`,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: `${this.name}_report_form`,
|
|
172
|
+
component: 'ZdForm',
|
|
173
|
+
cssClass: 'zd-pt-4',
|
|
174
|
+
children: [
|
|
175
|
+
{
|
|
176
|
+
name: 'report_email',
|
|
177
|
+
component: 'ZdTextInput',
|
|
178
|
+
label: 'E-mail',
|
|
179
|
+
grid: {
|
|
180
|
+
cols: '12',
|
|
181
|
+
},
|
|
182
|
+
value: this.defaultEmail,
|
|
183
|
+
readonly: `{{TekUserInfoController_${this.componentId}.hasDefaultEmail}}`,
|
|
184
|
+
validations: {
|
|
185
|
+
required: {},
|
|
186
|
+
email: {},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'report_cc',
|
|
191
|
+
component: 'ZdTextInput',
|
|
192
|
+
label: 'CC',
|
|
193
|
+
placeholder: 'TEKUSERINFO_EMAIL_PLACEHOLDER',
|
|
194
|
+
grid: {
|
|
195
|
+
cols: '12',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'report_type',
|
|
200
|
+
component: 'ZdSelect',
|
|
201
|
+
label: 'TEKUSERINFO_TYPE',
|
|
202
|
+
dataValue: 'value',
|
|
203
|
+
dataText: 'text',
|
|
204
|
+
datasource: {
|
|
205
|
+
uniqueKey: 'value',
|
|
206
|
+
translate: true,
|
|
207
|
+
data: [
|
|
208
|
+
{ value: '0', text: 'TEKUSERINFO_ERROR' },
|
|
209
|
+
{ value: '1', text: 'TEKUSERINFO_IMPROVEMENT' },
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
grid: {
|
|
213
|
+
cols: '12',
|
|
214
|
+
},
|
|
215
|
+
validations: {
|
|
216
|
+
required: {},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: 'report_description',
|
|
221
|
+
component: 'ZdTextarea',
|
|
222
|
+
label: 'TEKUSERINFO_DESCRIPTION',
|
|
223
|
+
grid: {
|
|
224
|
+
cols: '12',
|
|
225
|
+
},
|
|
226
|
+
validations: {
|
|
227
|
+
required: {},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: `${this.name}_report_footer`,
|
|
234
|
+
component: 'ZdFooter',
|
|
235
|
+
color: 'transparent',
|
|
236
|
+
padless: true,
|
|
237
|
+
rightSlot: [
|
|
238
|
+
{
|
|
239
|
+
name: `${this.name}_report_cancel`,
|
|
240
|
+
component: 'ZdButton',
|
|
241
|
+
label: 'TEKUSERINFO_CANCEL',
|
|
242
|
+
outline: true,
|
|
243
|
+
events: {
|
|
244
|
+
click: () => { this.reportModal?.hide(); },
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: `${this.name}_report_send`,
|
|
249
|
+
component: 'ZdButton',
|
|
250
|
+
label: 'TEKUSERINFO_SEND',
|
|
251
|
+
events: {
|
|
252
|
+
click: (args: IEventParam<Button>) => this.onSendReport(args),
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.reportModal.show();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public async onSendReport({ event, element }: IEventParam<Button>) {
|
|
265
|
+
if (!this.reportModal) return;
|
|
266
|
+
|
|
267
|
+
const form = Metadata.getInstance<Form>(`${this.name}_report_form`);
|
|
268
|
+
|
|
269
|
+
const validation = await form.validate();
|
|
270
|
+
|
|
271
|
+
if (!validation.valid) return;
|
|
272
|
+
|
|
273
|
+
this.callEvent('onSendReport', {
|
|
274
|
+
event, element, component: this, form,
|
|
275
|
+
});
|
|
276
|
+
this.reportModal.hide();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public onCreated() {
|
|
280
|
+
super.onCreated();
|
|
281
|
+
Loader.addController(`TekUserInfoController_${this.componentId}`, TekUserInfoController, [this]);
|
|
282
|
+
|
|
283
|
+
this.bottomSlot = this.propBottomSlot ? this.propBottomSlot : this.getBottomSlot();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public async onMounted(element: any) {
|
|
287
|
+
super.onMounted(element);
|
|
288
|
+
|
|
289
|
+
if (this.versionUrl) {
|
|
290
|
+
const res = await Http.get(this.versionUrl);
|
|
291
|
+
|
|
292
|
+
this.versionInfo = res.data.versionInfo;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
Messages.add({
|
|
298
|
+
'pt-BR': {
|
|
299
|
+
translation: {
|
|
300
|
+
TEKUSERINFO_ABOUT: 'Sobre',
|
|
301
|
+
TEKUSERINFO_REPORT_ERROR: 'Reportar Erro',
|
|
302
|
+
TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separe e-mails usando ";"',
|
|
303
|
+
TEKUSERINFO_TYPE: 'Tipo',
|
|
304
|
+
TEKUSERINFO_ERROR: 'Erro',
|
|
305
|
+
TEKUSERINFO_IMPROVEMENT: 'Melhoria',
|
|
306
|
+
TEKUSERINFO_DESCRIPTION: 'Descrição',
|
|
307
|
+
TEKUSERINFO_CANCEL: 'Cancelar',
|
|
308
|
+
TEKUSERINFO_SEND: 'Enviar',
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
'en-US': {
|
|
312
|
+
translation: {
|
|
313
|
+
TEKUSERINFO_ABOUT: 'About',
|
|
314
|
+
TEKUSERINFO_REPORT_ERROR: 'Report Bug',
|
|
315
|
+
TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separate e-mails using ";"',
|
|
316
|
+
TEKUSERINFO_TYPE: 'Type',
|
|
317
|
+
TEKUSERINFO_ERROR: 'Bug',
|
|
318
|
+
TEKUSERINFO_IMPROVEMENT: 'Improvement',
|
|
319
|
+
TEKUSERINFO_DESCRIPTION: 'Description',
|
|
320
|
+
TEKUSERINFO_CANCEL: 'Cancel',
|
|
321
|
+
TEKUSERINFO_SEND: 'Send',
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
'es-CL': {
|
|
325
|
+
translation: {
|
|
326
|
+
TEKUSERINFO_ABOUT: 'Sobre',
|
|
327
|
+
TEKUSERINFO_REPORT_ERROR: 'Reportar Error',
|
|
328
|
+
TEKUSERINFO_EMAIL_PLACEHOLDER: 'Separar e-mails usando ";"',
|
|
329
|
+
TEKUSERINFO_TYPE: 'Tipo',
|
|
330
|
+
TEKUSERINFO_ERROR: 'Error',
|
|
331
|
+
TEKUSERINFO_IMPROVEMENT: 'Mejora',
|
|
332
|
+
TEKUSERINFO_DESCRIPTION: 'Descripción',
|
|
333
|
+
TEKUSERINFO_CANCEL: 'Cancelar',
|
|
334
|
+
TEKUSERINFO_SEND: 'Enviar',
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TeknisaCommonError } from './teknisa-common-error';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TekGridDelete rows error
|
|
5
|
+
*/
|
|
6
|
+
export class TekGridDeleteRowsError extends TeknisaCommonError {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(
|
|
9
|
+
"TekGrid can't automatically delete rows when selectAllPages property is true." +
|
|
10
|
+
' You should delete them manually using the beforeDelete event and preventing' +
|
|
11
|
+
' the default execution',
|
|
12
|
+
);
|
|
13
|
+
this.name = 'TekGridDeleteRowsError';
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Button } from '@zeedhi/common';
|
|
2
|
+
import { TekGrid, ButtonOption } from '../../../../src';
|
|
3
|
+
import { Loader, SimpleControllerBuilder } from '@zeedhi/core';
|
|
4
|
+
|
|
5
|
+
describe('ButtonOption', () => {
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
Loader.setBuilder(new SimpleControllerBuilder());
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('buildComponent()', () => {
|
|
11
|
+
it('when called, should build a simple button component', () => {
|
|
12
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
13
|
+
const config = {
|
|
14
|
+
type: 'pdf',
|
|
15
|
+
label: 'Exportar PDF',
|
|
16
|
+
};
|
|
17
|
+
const option = new ButtonOption(config);
|
|
18
|
+
|
|
19
|
+
const component = option.buildComponent(grid);
|
|
20
|
+
|
|
21
|
+
expect(component).toEqual(expect.objectContaining({
|
|
22
|
+
label: config.label,
|
|
23
|
+
name: 'Grid_export_pdf_portrait',
|
|
24
|
+
component: 'ZdButton',
|
|
25
|
+
iconName: undefined,
|
|
26
|
+
flat: true,
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('the generated button component should call grid.getReport on click', () => {
|
|
31
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
32
|
+
const spy = jest.fn();
|
|
33
|
+
grid.getReport = spy;
|
|
34
|
+
const config = {
|
|
35
|
+
type: 'pdf',
|
|
36
|
+
label: 'Exportar PDF',
|
|
37
|
+
portrait: false,
|
|
38
|
+
};
|
|
39
|
+
const option = new ButtonOption(config);
|
|
40
|
+
|
|
41
|
+
const component = option.buildComponent(grid);
|
|
42
|
+
|
|
43
|
+
const instance = new Button(component);
|
|
44
|
+
instance.click();
|
|
45
|
+
|
|
46
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|