@things-factory/menu-ui 8.0.0 → 9.0.0-beta.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/dist-client/apptools/favorite-tool.d.ts +28 -0
- package/dist-client/apptools/favorite-tool.js +139 -0
- package/dist-client/apptools/favorite-tool.js.map +1 -0
- package/dist-client/bootstrap.d.ts +4 -0
- package/dist-client/bootstrap.js +52 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/components/child-menus-selector.d.ts +1 -0
- package/dist-client/components/child-menus-selector.js +146 -0
- package/dist-client/components/child-menus-selector.js.map +1 -0
- package/dist-client/components/role-select-popup.d.ts +1 -0
- package/dist-client/components/role-select-popup.js +180 -0
- package/dist-client/components/role-select-popup.js.map +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/menu-list-page.d.ts +2 -0
- package/dist-client/pages/menu-list-page.js +204 -0
- package/dist-client/pages/menu-list-page.js.map +1 -0
- package/dist-client/pages/menu-management-detail.d.ts +2 -0
- package/dist-client/pages/menu-management-detail.js +376 -0
- package/dist-client/pages/menu-management-detail.js.map +1 -0
- package/dist-client/pages/menu-management.d.ts +3 -0
- package/dist-client/pages/menu-management.js +280 -0
- package/dist-client/pages/menu-management.js.map +1 -0
- package/dist-client/pages/role-menus-management.d.ts +4 -0
- package/dist-client/pages/role-menus-management.js +215 -0
- package/dist-client/pages/role-menus-management.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +14 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/viewparts/menu-bar.d.ts +12 -0
- package/dist-client/viewparts/menu-bar.js +108 -0
- package/dist-client/viewparts/menu-bar.js.map +1 -0
- package/dist-client/viewparts/menu-tile-list.d.ts +13 -0
- package/dist-client/viewparts/menu-tile-list.js +234 -0
- package/dist-client/viewparts/menu-tile-list.js.map +1 -0
- package/dist-client/viewparts/menu-tree-bar.d.ts +28 -0
- package/dist-client/viewparts/menu-tree-bar.js +307 -0
- package/dist-client/viewparts/menu-tree-bar.js.map +1 -0
- package/package.json +21 -18
- package/things-factory.config.js +5 -14
- package/client/apptools/favorite-tool.js +0 -130
- package/client/bootstrap.js +0 -57
- package/client/components/child-menus-selector.js +0 -150
- package/client/components/role-select-popup.js +0 -179
- package/client/pages/menu-list-page.js +0 -200
- package/client/pages/menu-management-detail.js +0 -384
- package/client/pages/menu-management.js +0 -294
- package/client/pages/role-menus-management.js +0 -215
- package/client/route.js +0 -15
- package/client/viewparts/menu-bar.js +0 -114
- package/client/viewparts/menu-tile-list.js +0 -222
- package/client/viewparts/menu-tree-bar.js +0 -295
- package/server/index.ts +0 -0
- /package/{client/index.js → dist-client/index.d.ts} +0 -0
- /package/{client → dist-client}/themes/menu-theme.css +0 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '../viewparts/menu-bar';
|
|
3
|
+
import '../viewparts/menu-tile-list';
|
|
4
|
+
import gql from 'graphql-tag';
|
|
5
|
+
import { css, html } from 'lit';
|
|
6
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
7
|
+
import { connect } from 'pwa-helpers/connect-mixin.js';
|
|
8
|
+
import { navigate, PageView, store } from '@operato/shell';
|
|
9
|
+
import { client } from '@operato/graphql';
|
|
10
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
11
|
+
import { pulltorefresh } from '@operato/pull-to-refresh';
|
|
12
|
+
import { swipe } from '@things-factory/utils/src/index.js';
|
|
13
|
+
let MenuListPage = class MenuListPage extends connect(store)(PageView) {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.menus = [];
|
|
17
|
+
this.favorites = [];
|
|
18
|
+
this.showSpinner = false;
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `
|
|
22
|
+
<menu-bar .menus=${this.menus} .menuId=${this.menuId}></menu-bar>
|
|
23
|
+
|
|
24
|
+
<menu-tile-list
|
|
25
|
+
.menus=${this.menus}
|
|
26
|
+
.routingTypes=${this.routingTypes}
|
|
27
|
+
.menuId=${this.menuId}
|
|
28
|
+
.favorites=${this.favorites}
|
|
29
|
+
.showSpinner=${this.showSpinner}
|
|
30
|
+
></menu-tile-list>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
get context() {
|
|
34
|
+
return {
|
|
35
|
+
title: 'Menu'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async fetchMenus() {
|
|
39
|
+
const response = await client.query({
|
|
40
|
+
query: gql `
|
|
41
|
+
query {
|
|
42
|
+
userMenus {
|
|
43
|
+
id
|
|
44
|
+
name
|
|
45
|
+
role {
|
|
46
|
+
id
|
|
47
|
+
name
|
|
48
|
+
description
|
|
49
|
+
}
|
|
50
|
+
children {
|
|
51
|
+
id
|
|
52
|
+
name
|
|
53
|
+
routingType
|
|
54
|
+
idField
|
|
55
|
+
titleField
|
|
56
|
+
resourceName
|
|
57
|
+
resourceUrl
|
|
58
|
+
template
|
|
59
|
+
role {
|
|
60
|
+
id
|
|
61
|
+
name
|
|
62
|
+
description
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
});
|
|
69
|
+
return response.data.userMenus;
|
|
70
|
+
}
|
|
71
|
+
async updated(changes) {
|
|
72
|
+
if (changes.has('user')) {
|
|
73
|
+
if (this.user && this.user.email) {
|
|
74
|
+
this.refresh();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
stateChanged(state) {
|
|
79
|
+
this.page = state.route.page;
|
|
80
|
+
this.routingTypes = state.menu.routingTypes;
|
|
81
|
+
this.menuId = state.route.resourceId;
|
|
82
|
+
this.favorites = state.favorite.favorites;
|
|
83
|
+
this.user = state.auth.user;
|
|
84
|
+
var provider = state.menu.provider;
|
|
85
|
+
this.getMenus = typeof provider === 'function' ? provider.bind(this) : this.fetchMenus;
|
|
86
|
+
}
|
|
87
|
+
async refresh() {
|
|
88
|
+
this.showSpinner = true;
|
|
89
|
+
this.menus = await this.getMenus();
|
|
90
|
+
this.showSpinner = false;
|
|
91
|
+
}
|
|
92
|
+
async firstUpdated() {
|
|
93
|
+
var list = this.renderRoot.querySelector('menu-tile-list');
|
|
94
|
+
pulltorefresh({
|
|
95
|
+
container: this.renderRoot,
|
|
96
|
+
scrollable: list,
|
|
97
|
+
refresh: () => {
|
|
98
|
+
return this.refresh();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
swipe({
|
|
102
|
+
container: this.renderRoot.querySelector('menu-tile-list'),
|
|
103
|
+
animates: {
|
|
104
|
+
dragging: async (d, opts) => {
|
|
105
|
+
var currentIndex = Number(this.menuId);
|
|
106
|
+
var isHome = this.menuId === '' || this.menuId === undefined;
|
|
107
|
+
if ((d > 0 && isHome) || (d < 0 && currentIndex >= this.menus.length - 1)) {
|
|
108
|
+
/* TODO blocked gesture */
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
list.style.transform = `translate3d(${d}px, 0, 0)`;
|
|
112
|
+
},
|
|
113
|
+
aborting: async (opts) => {
|
|
114
|
+
list.style.transition = 'transform 0.3s';
|
|
115
|
+
list.style.transform = `translate3d(0, 0, 0)`;
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
list.style.transition = '';
|
|
118
|
+
}, 300);
|
|
119
|
+
},
|
|
120
|
+
swiping: async (d, opts) => {
|
|
121
|
+
var currentIndex = Number(this.menuId);
|
|
122
|
+
var isHome = this.menuId === '' || this.menuId === undefined;
|
|
123
|
+
if ((d > 0 && isHome) || (d < 0 && currentIndex >= this.menus.length - 1)) {
|
|
124
|
+
list.style.transform = `translate3d(0, 0, 0)`;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
list.style.transition = 'transform 0.3s';
|
|
128
|
+
list.style.transform = `translate3d(${d < 0 ? '-100%' : '100%'}, 0, 0)`;
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
if (isHome) {
|
|
131
|
+
navigate(`${this.page}/0`);
|
|
132
|
+
}
|
|
133
|
+
else if (d > 0 && currentIndex == 0) {
|
|
134
|
+
navigate(`${this.page}`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
navigate(`${this.page}/${currentIndex + (d < 0 ? 1 : -1)}`);
|
|
138
|
+
}
|
|
139
|
+
list.style.transition = '';
|
|
140
|
+
list.style.transform = `translate3d(${d < 0 ? '100%' : '-100%'}, 0, 0)`;
|
|
141
|
+
requestAnimationFrame(() => {
|
|
142
|
+
list.style.transition = 'transform 0.3s';
|
|
143
|
+
list.style.transform = `translate3d(0, 0, 0)`;
|
|
144
|
+
});
|
|
145
|
+
}, 300);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
await this.updateComplete;
|
|
150
|
+
this.refresh();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
MenuListPage.styles = [
|
|
154
|
+
ScrollbarStyles,
|
|
155
|
+
css `
|
|
156
|
+
:host {
|
|
157
|
+
display: flex;
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
menu-bar {
|
|
164
|
+
z-index: 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
menu-tile-list {
|
|
168
|
+
flex: 1;
|
|
169
|
+
overflow-y: auto;
|
|
170
|
+
}
|
|
171
|
+
`
|
|
172
|
+
];
|
|
173
|
+
__decorate([
|
|
174
|
+
property({ type: String }),
|
|
175
|
+
__metadata("design:type", String)
|
|
176
|
+
], MenuListPage.prototype, "menuId", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
property({ type: Array }),
|
|
179
|
+
__metadata("design:type", Array)
|
|
180
|
+
], MenuListPage.prototype, "menus", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
property({ type: Object }),
|
|
183
|
+
__metadata("design:type", Object)
|
|
184
|
+
], MenuListPage.prototype, "routingTypes", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({ type: Array }),
|
|
187
|
+
__metadata("design:type", Array)
|
|
188
|
+
], MenuListPage.prototype, "favorites", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property({ type: Object }),
|
|
191
|
+
__metadata("design:type", Object)
|
|
192
|
+
], MenuListPage.prototype, "user", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
property({ type: Boolean }),
|
|
195
|
+
__metadata("design:type", Boolean)
|
|
196
|
+
], MenuListPage.prototype, "showSpinner", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
state(),
|
|
199
|
+
__metadata("design:type", String)
|
|
200
|
+
], MenuListPage.prototype, "page", void 0);
|
|
201
|
+
MenuListPage = __decorate([
|
|
202
|
+
customElement('menu-list-page')
|
|
203
|
+
], MenuListPage);
|
|
204
|
+
//# sourceMappingURL=menu-list-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-list-page.js","sourceRoot":"","sources":["../../client/pages/menu-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,6BAA6B,CAAA;AAEpC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,M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AAC;;2CAAkB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;+CAAsB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CAAU;AACR;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;iDAA6B;AAExC;IAAhB,KAAK,EAAE;;0CAAsB;AA7B1B,YAAY;IADjB,aAAa,CAAC,gBAAgB,CAAC;GAC1B,YAAY,CAwLjB","sourcesContent":["import '../viewparts/menu-bar'\nimport '../viewparts/menu-tile-list'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { navigate, PageView, store } from '@operato/shell'\nimport { client } from '@operato/graphql'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { pulltorefresh } from '@operato/pull-to-refresh'\nimport { swipe } from '@things-factory/utils/src/index.js'\n\n@customElement('menu-list-page')\nclass MenuListPage extends connect(store)(PageView) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n overflow: hidden;\n }\n\n menu-bar {\n z-index: 1;\n }\n\n menu-tile-list {\n flex: 1;\n overflow-y: auto;\n }\n `\n ]\n\n @property({ type: String }) menuId?: string\n @property({ type: Array }) menus: any[] = []\n @property({ type: Object }) routingTypes: any\n @property({ type: Array }) favorites: any[] = []\n @property({ type: Object }) user: any\n @property({ type: Boolean }) showSpinner: boolean = false\n\n @state() private page?: string\n\n private getMenus: any\n\n render() {\n return html`\n <menu-bar .menus=${this.menus} .menuId=${this.menuId}></menu-bar>\n\n <menu-tile-list\n .menus=${this.menus}\n .routingTypes=${this.routingTypes}\n .menuId=${this.menuId}\n .favorites=${this.favorites}\n .showSpinner=${this.showSpinner}\n ></menu-tile-list>\n `\n }\n\n get context() {\n return {\n title: 'Menu'\n }\n }\n\n async fetchMenus() {\n const response = await client.query({\n query: gql`\n query {\n userMenus {\n id\n name\n role {\n id\n name\n description\n }\n children {\n id\n name\n routingType\n idField\n titleField\n resourceName\n resourceUrl\n template\n role {\n id\n name\n description\n }\n }\n }\n }\n `\n })\n\n return response.data.userMenus\n }\n\n async updated(changes) {\n if (changes.has('user')) {\n if (this.user && this.user.email) {\n this.refresh()\n }\n }\n }\n\n stateChanged(state) {\n this.page = state.route.page\n this.routingTypes = state.menu.routingTypes\n this.menuId = state.route.resourceId\n this.favorites = state.favorite.favorites\n this.user = state.auth.user\n\n var provider = state.menu.provider\n this.getMenus = typeof provider === 'function' ? provider.bind(this) : this.fetchMenus\n }\n\n async refresh() {\n this.showSpinner = true\n this.menus = await this.getMenus()\n this.showSpinner = false\n }\n\n async firstUpdated() {\n var list = this.renderRoot.querySelector('menu-tile-list') as HTMLElement\n\n pulltorefresh({\n container: this.renderRoot,\n scrollable: list,\n refresh: () => {\n return this.refresh()\n }\n })\n\n swipe({\n container: this.renderRoot.querySelector('menu-tile-list'),\n animates: {\n dragging: async (d, opts) => {\n var currentIndex = Number(this.menuId)\n var isHome = this.menuId === '' || this.menuId === undefined\n\n if ((d > 0 && isHome) || (d < 0 && currentIndex >= this.menus.length - 1)) {\n /* TODO blocked gesture */\n return false\n }\n\n list.style.transform = `translate3d(${d}px, 0, 0)`\n },\n aborting: async opts => {\n list.style.transition = 'transform 0.3s'\n list.style.transform = `translate3d(0, 0, 0)`\n\n setTimeout(() => {\n list.style.transition = ''\n }, 300)\n },\n swiping: async (d, opts) => {\n var currentIndex = Number(this.menuId)\n var isHome = this.menuId === '' || this.menuId === undefined\n\n if ((d > 0 && isHome) || (d < 0 && currentIndex >= this.menus.length - 1)) {\n list.style.transform = `translate3d(0, 0, 0)`\n\n return\n }\n\n list.style.transition = 'transform 0.3s'\n list.style.transform = `translate3d(${d < 0 ? '-100%' : '100%'}, 0, 0)`\n\n setTimeout(() => {\n if (isHome) {\n navigate(`${this.page}/0`)\n } else if (d > 0 && currentIndex == 0) {\n navigate(`${this.page}`)\n } else {\n navigate(`${this.page}/${currentIndex + (d < 0 ? 1 : -1)}`)\n }\n\n list.style.transition = ''\n list.style.transform = `translate3d(${d < 0 ? '100%' : '-100%'}, 0, 0)`\n\n requestAnimationFrame(() => {\n list.style.transition = 'transform 0.3s'\n list.style.transform = `translate3d(0, 0, 0)`\n })\n }, 300)\n }\n }\n })\n\n await this.updateComplete\n\n this.refresh()\n }\n}\n"]}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@things-factory/form-ui';
|
|
3
|
+
import '@operato/data-grist';
|
|
4
|
+
import gql from 'graphql-tag';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
7
|
+
import { DataGrist, getEditor, getRenderer } from '@operato/data-grist';
|
|
8
|
+
import { i18next, localize } from '@operato/i18n';
|
|
9
|
+
import { client } from '@operato/graphql';
|
|
10
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
11
|
+
import { isMobileDevice } from '@operato/utils';
|
|
12
|
+
import { gqlBuilder } from '@things-factory/utils';
|
|
13
|
+
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
14
|
+
let MenuManagementDetail = class MenuManagementDetail extends localize(i18next)(LitElement) {
|
|
15
|
+
render() {
|
|
16
|
+
return html `
|
|
17
|
+
<search-form .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
|
|
18
|
+
|
|
19
|
+
<div class="grist">
|
|
20
|
+
<ox-grist
|
|
21
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
22
|
+
.config=${this.config}
|
|
23
|
+
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
24
|
+
></ox-grist>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div class="button-container">
|
|
28
|
+
<button @click=${this.save}>${i18next.t('button.save')}</button>
|
|
29
|
+
<button @click=${this.delete}>${i18next.t('button.delete')}</button>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
firstUpdated() {
|
|
34
|
+
this.searchFields = [
|
|
35
|
+
{
|
|
36
|
+
name: 'name',
|
|
37
|
+
label: i18next.t('field.name'),
|
|
38
|
+
type: 'text',
|
|
39
|
+
props: { searchOper: 'i_like' }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'description',
|
|
43
|
+
label: i18next.t('field.description'),
|
|
44
|
+
type: 'text',
|
|
45
|
+
props: { searchOper: 'i_like' }
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'template',
|
|
49
|
+
label: i18next.t('field.template'),
|
|
50
|
+
type: 'text',
|
|
51
|
+
props: { searchOper: 'i_like' }
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'category',
|
|
55
|
+
label: i18next.t('field.category'),
|
|
56
|
+
type: 'text',
|
|
57
|
+
props: { searchOper: 'i_like' }
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'resourceUrl',
|
|
61
|
+
label: i18next.t('field.resource_url'),
|
|
62
|
+
type: 'text',
|
|
63
|
+
props: { searchOper: 'i_like' }
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'hiddenFlag',
|
|
67
|
+
label: i18next.t('field.hidden_flag'),
|
|
68
|
+
type: 'checkbox',
|
|
69
|
+
props: { searchOper: 'eq' },
|
|
70
|
+
attrs: ['indeterminate']
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
this.config = {
|
|
74
|
+
rows: { selectable: { multiple: true } },
|
|
75
|
+
pagination: { infinite: true },
|
|
76
|
+
columns: [
|
|
77
|
+
{ type: 'gutter', gutterName: 'dirty' },
|
|
78
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
79
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
80
|
+
{
|
|
81
|
+
type: 'string',
|
|
82
|
+
name: 'name',
|
|
83
|
+
header: i18next.t('field.name'),
|
|
84
|
+
record: { editable: true, align: 'left' },
|
|
85
|
+
sortable: true,
|
|
86
|
+
width: 150
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'integer',
|
|
90
|
+
name: 'rank',
|
|
91
|
+
header: i18next.t('field.rank'),
|
|
92
|
+
record: { editable: true },
|
|
93
|
+
sortable: true,
|
|
94
|
+
width: 80
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'select',
|
|
98
|
+
name: 'resourceType',
|
|
99
|
+
header: i18next.t('field.type'),
|
|
100
|
+
record: {
|
|
101
|
+
editable: true,
|
|
102
|
+
options: ['', 'board']
|
|
103
|
+
},
|
|
104
|
+
width: 80
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'string',
|
|
108
|
+
name: 'resourceId',
|
|
109
|
+
header: i18next.t('field.value'),
|
|
110
|
+
record: {
|
|
111
|
+
editable: true,
|
|
112
|
+
editor: function (value, column, record, rowIndex, field) {
|
|
113
|
+
const type = record.resourceType || 'string';
|
|
114
|
+
if (value && type !== 'board') {
|
|
115
|
+
delete record.resourceId;
|
|
116
|
+
value = '';
|
|
117
|
+
}
|
|
118
|
+
return getEditor(type)(value, column, record, rowIndex, field);
|
|
119
|
+
},
|
|
120
|
+
renderer: function (value, column, record, rowIndex, field) {
|
|
121
|
+
const type = record.resourceType || 'string';
|
|
122
|
+
if (value && type !== 'board') {
|
|
123
|
+
delete record.resourceId;
|
|
124
|
+
value = '';
|
|
125
|
+
}
|
|
126
|
+
return getRenderer(type)(value, column, record, rowIndex, field);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
width: 140
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: 'string',
|
|
133
|
+
name: 'description',
|
|
134
|
+
header: i18next.t('field.description'),
|
|
135
|
+
record: { editable: true, align: 'left' },
|
|
136
|
+
sortable: true,
|
|
137
|
+
width: 200
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: 'string',
|
|
141
|
+
name: 'template',
|
|
142
|
+
header: i18next.t('field.template'),
|
|
143
|
+
record: { editable: true, align: 'left' },
|
|
144
|
+
sortable: true,
|
|
145
|
+
width: 160
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: 'string',
|
|
149
|
+
name: 'resourceUrl',
|
|
150
|
+
header: i18next.t('field.resource_url'),
|
|
151
|
+
record: { editable: true, align: 'left' },
|
|
152
|
+
sortable: true,
|
|
153
|
+
width: 160
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'boolean',
|
|
157
|
+
name: 'hiddenFlag',
|
|
158
|
+
header: i18next.t('field.hidden_flag'),
|
|
159
|
+
record: { editable: true },
|
|
160
|
+
sortable: true,
|
|
161
|
+
width: 80
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'resource-object',
|
|
165
|
+
name: 'role',
|
|
166
|
+
label: true,
|
|
167
|
+
header: i18next.t('field.required role'),
|
|
168
|
+
record: {
|
|
169
|
+
editable: true,
|
|
170
|
+
options: {
|
|
171
|
+
title: i18next.t('title.lookup role'),
|
|
172
|
+
queryName: 'roles'
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
width: 200
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: 'datetime',
|
|
179
|
+
name: 'updatedAt',
|
|
180
|
+
header: i18next.t('field.updated_at'),
|
|
181
|
+
record: { editable: false },
|
|
182
|
+
sortable: true,
|
|
183
|
+
width: 150
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'object',
|
|
187
|
+
name: 'updater',
|
|
188
|
+
header: i18next.t('field.updater'),
|
|
189
|
+
record: { editable: false },
|
|
190
|
+
sortable: true,
|
|
191
|
+
width: 150
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async fetchHandler({ page, limit, sorters = [{ name: 'rank' }, { name: 'name' }] }) {
|
|
197
|
+
const response = await client.query({
|
|
198
|
+
query: gql `
|
|
199
|
+
query {
|
|
200
|
+
menus(${gqlBuilder.buildArgs({
|
|
201
|
+
filters: [...this.searchForm.queryFilters, { name: 'parentId', operator: 'eq', value: this.menuId }],
|
|
202
|
+
pagination: { page, limit },
|
|
203
|
+
sortings: sorters
|
|
204
|
+
})}) {
|
|
205
|
+
items {
|
|
206
|
+
id
|
|
207
|
+
name
|
|
208
|
+
rank
|
|
209
|
+
description
|
|
210
|
+
category
|
|
211
|
+
template
|
|
212
|
+
resourceUrl
|
|
213
|
+
resourceType
|
|
214
|
+
resourceId
|
|
215
|
+
hiddenFlag
|
|
216
|
+
role {
|
|
217
|
+
id
|
|
218
|
+
name
|
|
219
|
+
description
|
|
220
|
+
}
|
|
221
|
+
updatedAt
|
|
222
|
+
updater{
|
|
223
|
+
id
|
|
224
|
+
name
|
|
225
|
+
description
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
total
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
total: response.data.menus.total || 0,
|
|
235
|
+
records: response.data.menus.items || []
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
async save() {
|
|
239
|
+
const patches = this.getPatches();
|
|
240
|
+
if (patches && patches.length) {
|
|
241
|
+
const response = await client.query({
|
|
242
|
+
query: gql `
|
|
243
|
+
mutation {
|
|
244
|
+
updateMultipleMenu(${gqlBuilder.buildArgs({
|
|
245
|
+
patches
|
|
246
|
+
})}) {
|
|
247
|
+
name
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
`
|
|
251
|
+
});
|
|
252
|
+
if (!response.errors)
|
|
253
|
+
this.dataGrist.fetch();
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
OxPrompt.open({
|
|
257
|
+
title: i18next.t('text.nothing_changed'),
|
|
258
|
+
text: i18next.t('text.there_is_nothing_to_save')
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async delete() {
|
|
263
|
+
const ids = this.dataGrist.selected.map(record => record.id);
|
|
264
|
+
if (ids && ids.length > 0) {
|
|
265
|
+
if (await OxPrompt.open({
|
|
266
|
+
type: 'warning',
|
|
267
|
+
title: i18next.t('button.delete'),
|
|
268
|
+
text: i18next.t('text.are_you_sure'),
|
|
269
|
+
confirmButton: { text: i18next.t('button.delete') },
|
|
270
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
271
|
+
})) {
|
|
272
|
+
const response = await client.query({
|
|
273
|
+
query: gql `
|
|
274
|
+
mutation {
|
|
275
|
+
deleteMenus(${gqlBuilder.buildArgs({ ids })})
|
|
276
|
+
}
|
|
277
|
+
`
|
|
278
|
+
});
|
|
279
|
+
if (!response.errors) {
|
|
280
|
+
this.dataGrist.fetch();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
OxPrompt.open({
|
|
286
|
+
title: i18next.t('text.nothing_selected'),
|
|
287
|
+
text: i18next.t('text.there_is_nothing_to_delete')
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
getPatches() {
|
|
292
|
+
let patches = this.dataGrist.dirtyRecords;
|
|
293
|
+
if (patches && patches.length) {
|
|
294
|
+
patches = patches.map(menu => {
|
|
295
|
+
let patchField = menu.id ? { id: menu.id } : {};
|
|
296
|
+
patchField = Object.assign(Object.assign({}, patchField), { routingType: menu.routingType, menuType: menu.menuType });
|
|
297
|
+
const dirtyFields = menu.__dirtyfields__;
|
|
298
|
+
for (let key in dirtyFields) {
|
|
299
|
+
patchField[key] = dirtyFields[key].after;
|
|
300
|
+
}
|
|
301
|
+
patchField.parent = { id: this.menuId };
|
|
302
|
+
patchField.routingType = patchField.routingType || 'STATIC';
|
|
303
|
+
patchField.menuType = patchField.menuType || 'SCREEN';
|
|
304
|
+
patchField.cuFlag = menu.__dirty__;
|
|
305
|
+
return patchField;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return patches;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
MenuManagementDetail.styles = [
|
|
312
|
+
ScrollbarStyles,
|
|
313
|
+
css `
|
|
314
|
+
:host {
|
|
315
|
+
display: flex;
|
|
316
|
+
flex-direction: column;
|
|
317
|
+
overflow: hidden;
|
|
318
|
+
background-color: var(--md-sys-color-surface);
|
|
319
|
+
}
|
|
320
|
+
search-form {
|
|
321
|
+
overflow: visible;
|
|
322
|
+
}
|
|
323
|
+
.grist {
|
|
324
|
+
display: flex;
|
|
325
|
+
flex-direction: column;
|
|
326
|
+
flex: 1;
|
|
327
|
+
overflow-y: auto;
|
|
328
|
+
}
|
|
329
|
+
ox-grist {
|
|
330
|
+
overflow-y: hidden;
|
|
331
|
+
flex: 1;
|
|
332
|
+
}
|
|
333
|
+
.button-container {
|
|
334
|
+
padding: 10px 0 12px 0;
|
|
335
|
+
text-align: center;
|
|
336
|
+
}
|
|
337
|
+
.button-container > button {
|
|
338
|
+
background-color: var(--button-background-color);
|
|
339
|
+
border: var(--button-border);
|
|
340
|
+
border-radius: var(--button-border-radius);
|
|
341
|
+
margin: var(--button-margin);
|
|
342
|
+
padding: var(--button-padding);
|
|
343
|
+
color: var(--button-color);
|
|
344
|
+
font: var(--button-font);
|
|
345
|
+
text-transform: var(--button-text-transform);
|
|
346
|
+
}
|
|
347
|
+
.button-container > button:hover,
|
|
348
|
+
.button-container > button:active {
|
|
349
|
+
background-color: var(--button-background-focus-color);
|
|
350
|
+
}
|
|
351
|
+
`
|
|
352
|
+
];
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: String }),
|
|
355
|
+
__metadata("design:type", String)
|
|
356
|
+
], MenuManagementDetail.prototype, "menuId", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
property({ type: Object }),
|
|
359
|
+
__metadata("design:type", Object)
|
|
360
|
+
], MenuManagementDetail.prototype, "searchFields", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
property({ type: Object }),
|
|
363
|
+
__metadata("design:type", Object)
|
|
364
|
+
], MenuManagementDetail.prototype, "config", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
query('ox-grist'),
|
|
367
|
+
__metadata("design:type", DataGrist)
|
|
368
|
+
], MenuManagementDetail.prototype, "dataGrist", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
query('search-form'),
|
|
371
|
+
__metadata("design:type", HTMLFormElement)
|
|
372
|
+
], MenuManagementDetail.prototype, "searchForm", void 0);
|
|
373
|
+
MenuManagementDetail = __decorate([
|
|
374
|
+
customElement('menu-management-detail')
|
|
375
|
+
], MenuManagementDetail);
|
|
376
|
+
//# sourceMappingURL=menu-management-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-management-detail.js","sourceRoot":"","sources":["../../client/pages/menu-management-detail.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAChC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,SAAS,EAAe,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE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;gBACD,UAAU,CAAC,MAAM,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;gBACvC,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,QAAQ,CAAA;gBAC3D,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,QAAQ,CAAA;gBACrD,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;gBAElC,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;;AAlWM,2BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCF;CACF,AAzCY,CAyCZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0DAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAY;AAEpB;IAAlB,KAAK,CAAC,UAAU,CAAC;8BAAa,SAAS;uDAAA;AAClB;IAArB,KAAK,CAAC,aAAa,CAAC;8BAAc,eAAe;wDAAA;AAjD9C,oBAAoB;IADzB,aAAa,CAAC,wBAAwB,CAAC;GAClC,oBAAoB,CAoWzB","sourcesContent":["import '@things-factory/form-ui'\nimport '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { DataGrist, FetchOption, getEditor, getRenderer } from '@operato/data-grist'\nimport { i18next, localize } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { gqlBuilder } from '@things-factory/utils'\n\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('menu-management-detail')\nclass MenuManagementDetail extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background-color: var(--md-sys-color-surface);\n }\n search-form {\n overflow: visible;\n }\n .grist {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow-y: auto;\n }\n ox-grist {\n overflow-y: hidden;\n flex: 1;\n }\n .button-container {\n padding: 10px 0 12px 0;\n text-align: center;\n }\n .button-container > button {\n background-color: var(--button-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n margin: var(--button-margin);\n padding: var(--button-padding);\n color: var(--button-color);\n font: var(--button-font);\n text-transform: var(--button-text-transform);\n }\n .button-container > button:hover,\n .button-container > button:active {\n background-color: var(--button-background-focus-color);\n }\n `\n ]\n\n @property({ type: String }) menuId?: string\n @property({ type: Object }) searchFields: any\n @property({ type: Object }) config: any\n\n @query('ox-grist') dataGrist!: DataGrist\n @query('search-form') searchForm!: HTMLFormElement\n\n render() {\n return html`\n <search-form .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>\n\n <div class=\"grist\">\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.config}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ></ox-grist>\n </div>\n\n <div class=\"button-container\">\n <button @click=${this.save}>${i18next.t('button.save')}</button>\n <button @click=${this.delete}>${i18next.t('button.delete')}</button>\n </div>\n `\n }\n\n firstUpdated() {\n this.searchFields = [\n {\n name: 'name',\n label: i18next.t('field.name'),\n type: 'text',\n props: { searchOper: 'i_like' }\n },\n {\n name: 'description',\n label: i18next.t('field.description'),\n type: 'text',\n props: { searchOper: 'i_like' }\n },\n {\n name: 'template',\n label: i18next.t('field.template'),\n type: 'text',\n props: { searchOper: 'i_like' }\n },\n {\n name: 'category',\n label: i18next.t('field.category'),\n type: 'text',\n props: { searchOper: 'i_like' }\n },\n {\n name: 'resourceUrl',\n label: i18next.t('field.resource_url'),\n type: 'text',\n props: { searchOper: 'i_like' }\n },\n {\n name: 'hiddenFlag',\n label: i18next.t('field.hidden_flag'),\n type: 'checkbox',\n props: { searchOper: 'eq' },\n attrs: ['indeterminate']\n }\n ]\n\n this.config = {\n rows: { selectable: { multiple: true } },\n pagination: { infinite: true },\n columns: [\n { type: 'gutter', gutterName: 'dirty' },\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: true, align: 'left' },\n sortable: true,\n width: 150\n },\n {\n type: 'integer',\n name: 'rank',\n header: i18next.t('field.rank'),\n record: { editable: true },\n sortable: true,\n width: 80\n },\n {\n type: 'select',\n name: 'resourceType',\n header: i18next.t('field.type'),\n record: {\n editable: true,\n options: ['', 'board']\n },\n width: 80\n },\n {\n type: 'string',\n name: 'resourceId',\n header: i18next.t('field.value'),\n record: {\n editable: true,\n editor: function (value, column, record, rowIndex, field) {\n const type = record.resourceType || 'string'\n if (value && type !== 'board') {\n delete record.resourceId\n value = ''\n }\n return getEditor(type)(value, column, record, rowIndex, field)\n },\n renderer: function (value, column, record, rowIndex, field) {\n const type = record.resourceType || 'string'\n if (value && type !== 'board') {\n delete record.resourceId\n value = ''\n }\n return getRenderer(type)(value, column, record, rowIndex, field)\n }\n },\n width: 140\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: { editable: true, align: 'left' },\n sortable: true,\n width: 200\n },\n {\n type: 'string',\n name: 'template',\n header: i18next.t('field.template'),\n record: { editable: true, align: 'left' },\n sortable: true,\n width: 160\n },\n {\n type: 'string',\n name: 'resourceUrl',\n header: i18next.t('field.resource_url'),\n record: { editable: true, align: 'left' },\n sortable: true,\n width: 160\n },\n {\n type: 'boolean',\n name: 'hiddenFlag',\n header: i18next.t('field.hidden_flag'),\n record: { editable: true },\n sortable: true,\n width: 80\n },\n {\n type: 'resource-object',\n name: 'role',\n label: true,\n header: i18next.t('field.required role'),\n record: {\n editable: true,\n options: {\n title: i18next.t('title.lookup role'),\n queryName: 'roles'\n }\n },\n width: 200\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false },\n sortable: true,\n width: 150\n },\n {\n type: 'object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false },\n sortable: true,\n width: 150\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sorters = [{ name: 'rank' }, { name: 'name' }] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query {\n menus(${gqlBuilder.buildArgs({\n filters: [...this.searchForm.queryFilters, { name: 'parentId', operator: 'eq', value: this.menuId }],\n pagination: { page, limit },\n sortings: sorters\n })}) {\n items {\n id\n name\n rank\n description\n category\n template\n resourceUrl\n resourceType\n resourceId\n hiddenFlag\n role {\n id\n name\n description\n }\n updatedAt\n updater{\n id\n name\n description\n }\n }\n total\n }\n }\n `\n })\n\n return {\n total: response.data.menus.total || 0,\n records: response.data.menus.items || []\n }\n }\n\n async save() {\n const patches = this.getPatches()\n if (patches && patches.length) {\n const response = await client.query({\n query: gql`\n mutation {\n updateMultipleMenu(${gqlBuilder.buildArgs({\n patches\n })}) {\n name\n }\n }\n `\n })\n\n if (!response.errors) this.dataGrist.fetch()\n } else {\n OxPrompt.open({\n title: i18next.t('text.nothing_changed'),\n text: i18next.t('text.there_is_nothing_to_save')\n })\n }\n }\n\n async delete() {\n const ids = this.dataGrist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n if (\n await OxPrompt.open({\n type: 'warning',\n title: i18next.t('button.delete'),\n text: i18next.t('text.are_you_sure'),\n confirmButton: { text: i18next.t('button.delete') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.query({\n query: gql`\n mutation {\n deleteMenus(${gqlBuilder.buildArgs({ ids })})\n }\n `\n })\n\n if (!response.errors) {\n this.dataGrist.fetch()\n }\n }\n } else {\n OxPrompt.open({\n title: i18next.t('text.nothing_selected'),\n text: i18next.t('text.there_is_nothing_to_delete')\n })\n }\n }\n\n getPatches() {\n let patches = this.dataGrist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(menu => {\n let patchField: any = menu.id ? { id: menu.id } : {}\n patchField = { ...patchField, routingType: menu.routingType, menuType: menu.menuType }\n const dirtyFields = menu.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.parent = { id: this.menuId }\n patchField.routingType = patchField.routingType || 'STATIC'\n patchField.menuType = patchField.menuType || 'SCREEN'\n patchField.cuFlag = menu.__dirty__\n\n return patchField\n })\n }\n\n return patches\n }\n}\n"]}
|