@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,28 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
declare const FavoriteTool_base: (new (...args: any[]) => {
|
|
4
|
+
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
5
|
+
connectedCallback(): void;
|
|
6
|
+
disconnectedCallback(): void;
|
|
7
|
+
stateChanged(_state: unknown): void;
|
|
8
|
+
readonly isConnected: boolean;
|
|
9
|
+
}) & typeof LitElement;
|
|
10
|
+
export declare class FavoriteTool extends FavoriteTool_base {
|
|
11
|
+
static styles: import("lit").CSSResult;
|
|
12
|
+
favorites: any;
|
|
13
|
+
user: any;
|
|
14
|
+
page?: string;
|
|
15
|
+
resourceId?: string;
|
|
16
|
+
favored: boolean;
|
|
17
|
+
routingTypes: any[];
|
|
18
|
+
blackList: string[];
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
updated(changes: any): void;
|
|
21
|
+
stateChanged(state: any): void;
|
|
22
|
+
onClick(event: any): void;
|
|
23
|
+
refreshFavorites(): Promise<void>;
|
|
24
|
+
removeFavorite(routing: any): Promise<void>;
|
|
25
|
+
addFavorite(routing: any): Promise<void>;
|
|
26
|
+
getFullRouting(): string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { connect } from 'pwa-helpers/connect-mixin.js';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
import { store, client } from '@things-factory/shell/client';
|
|
8
|
+
import { UPDATE_FAVORITES } from '@things-factory/fav-base/client';
|
|
9
|
+
let FavoriteTool = class FavoriteTool extends connect(store)(LitElement) {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.favored = false;
|
|
13
|
+
this.routingTypes = [];
|
|
14
|
+
this.blackList = [];
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
var renderable = (this.blackList || []).indexOf(this.page) == -1;
|
|
18
|
+
return renderable
|
|
19
|
+
? html `
|
|
20
|
+
<md-icon @click=${this.onClick.bind(this)} ?favorable=${!this.favored}
|
|
21
|
+
>${this.favored ? 'star' : 'star_border'}</md-icon
|
|
22
|
+
>
|
|
23
|
+
`
|
|
24
|
+
: html ``;
|
|
25
|
+
}
|
|
26
|
+
updated(changes) {
|
|
27
|
+
if (changes.has('user')) {
|
|
28
|
+
this.refreshFavorites();
|
|
29
|
+
}
|
|
30
|
+
this.favored = (this.favorites || []).includes(this.getFullRouting());
|
|
31
|
+
}
|
|
32
|
+
stateChanged(state) {
|
|
33
|
+
this.favorites = state.favorite.favorites;
|
|
34
|
+
this.user = state.auth.user;
|
|
35
|
+
this.page = state.route.page;
|
|
36
|
+
this.resourceId = state.route.resourceId;
|
|
37
|
+
this.routingTypes = state.menu.routingTypes;
|
|
38
|
+
}
|
|
39
|
+
onClick(event) {
|
|
40
|
+
if (this.favored) {
|
|
41
|
+
this.removeFavorite(this.getFullRouting());
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.addFavorite(this.getFullRouting());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async refreshFavorites() {
|
|
48
|
+
if (!this.user || !this.user.email) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const response = await client.query({
|
|
52
|
+
query: gql `
|
|
53
|
+
query {
|
|
54
|
+
myFavorites {
|
|
55
|
+
id
|
|
56
|
+
routing
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
});
|
|
61
|
+
store.dispatch({
|
|
62
|
+
type: UPDATE_FAVORITES,
|
|
63
|
+
favorites: response.data.myFavorites.map(favorite => favorite.routing)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async removeFavorite(routing) {
|
|
67
|
+
await client.query({
|
|
68
|
+
query: gql `
|
|
69
|
+
mutation {
|
|
70
|
+
deleteFavorite(routing: "${routing}")
|
|
71
|
+
}
|
|
72
|
+
`
|
|
73
|
+
});
|
|
74
|
+
this.refreshFavorites();
|
|
75
|
+
}
|
|
76
|
+
async addFavorite(routing) {
|
|
77
|
+
await client.query({
|
|
78
|
+
query: gql `
|
|
79
|
+
mutation {
|
|
80
|
+
createFavorite(favorite: {
|
|
81
|
+
routing: "${routing}"
|
|
82
|
+
}) {
|
|
83
|
+
id
|
|
84
|
+
routing
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`
|
|
88
|
+
});
|
|
89
|
+
this.refreshFavorites();
|
|
90
|
+
}
|
|
91
|
+
getFullRouting() {
|
|
92
|
+
var routingType = Object.values(this.routingTypes).find(type => type.page == this.page);
|
|
93
|
+
return routingType ? `${this.page}/${this.resourceId}` : this.page;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
FavoriteTool.styles = css `
|
|
97
|
+
:host {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
vertical-align: middle;
|
|
100
|
+
line-height: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[favorable] {
|
|
104
|
+
opacity: 0.5;
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: Array }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], FavoriteTool.prototype, "favorites", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: Object }),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], FavoriteTool.prototype, "user", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String }),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], FavoriteTool.prototype, "page", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: String }),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], FavoriteTool.prototype, "resourceId", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
property({ type: Boolean }),
|
|
125
|
+
__metadata("design:type", Boolean)
|
|
126
|
+
], FavoriteTool.prototype, "favored", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: Array }),
|
|
129
|
+
__metadata("design:type", Array)
|
|
130
|
+
], FavoriteTool.prototype, "routingTypes", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: Array }),
|
|
133
|
+
__metadata("design:type", Array)
|
|
134
|
+
], FavoriteTool.prototype, "blackList", void 0);
|
|
135
|
+
FavoriteTool = __decorate([
|
|
136
|
+
customElement('favorite-tool')
|
|
137
|
+
], FavoriteTool);
|
|
138
|
+
export { FavoriteTool };
|
|
139
|
+
//# sourceMappingURL=favorite-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorite-tool.js","sourceRoot":"","sources":["../../client/apptools/favorite-tool.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GA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C,WAAW,CAAC,OAAO;QACvB,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,GAAG,CAAA;;;wBAGQ,OAAO;;;;;;OAMxB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACzB,CAAC;IAED,cAAc;QACZ,IAAI,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;QACvF,OAAO,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IACpE,CAAC;;AA9GM,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;GAUlB,AAVY,CAUZ;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;+CAAe;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CAAU;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAoB;AAClB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;6CAAyB;AAC1B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;kDAAyB;AACxB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;+CAAyB;AAnBxC,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAgHxB","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { LitElement, html, css } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\nimport gql from 'graphql-tag'\n\nimport { store, client } from '@things-factory/shell/client'\nimport { UPDATE_FAVORITES } from '@things-factory/fav-base/client'\n\n@customElement('favorite-tool')\nexport class FavoriteTool extends connect(store)(LitElement) {\n static styles = css`\n :host {\n display: inline-block;\n vertical-align: middle;\n line-height: 0;\n }\n\n [favorable] {\n opacity: 0.5;\n }\n `\n\n @property({ type: Array }) favorites: any\n @property({ type: Object }) user: any\n @property({ type: String }) page?: string\n @property({ type: String }) resourceId?: string\n @property({ type: Boolean }) favored: boolean = false\n @property({ type: Array }) routingTypes: any[] = []\n @property({ type: Array }) blackList: string[] = []\n\n render() {\n var renderable = (this.blackList || []).indexOf(this.page!) == -1\n\n return renderable\n ? html`\n <md-icon @click=${this.onClick.bind(this)} ?favorable=${!this.favored}\n >${this.favored ? 'star' : 'star_border'}</md-icon\n >\n `\n : html``\n }\n\n updated(changes) {\n if (changes.has('user')) {\n this.refreshFavorites()\n }\n\n this.favored = (this.favorites || []).includes(this.getFullRouting())\n }\n\n stateChanged(state) {\n this.favorites = state.favorite.favorites\n this.user = state.auth.user\n this.page = state.route.page\n this.resourceId = state.route.resourceId\n this.routingTypes = state.menu.routingTypes\n }\n\n onClick(event) {\n if (this.favored) {\n this.removeFavorite(this.getFullRouting())\n } else {\n this.addFavorite(this.getFullRouting())\n }\n }\n\n async refreshFavorites() {\n if (!this.user || !this.user.email) {\n return\n }\n\n const response = await client.query({\n query: gql`\n query {\n myFavorites {\n id\n routing\n }\n }\n `\n })\n\n store.dispatch({\n type: UPDATE_FAVORITES,\n favorites: response.data.myFavorites.map(favorite => favorite.routing)\n })\n }\n\n async removeFavorite(routing) {\n await client.query({\n query: gql`\n mutation {\n deleteFavorite(routing: \"${routing}\")\n }\n `\n })\n\n this.refreshFavorites()\n }\n\n async addFavorite(routing) {\n await client.query({\n query: gql`\n mutation {\n createFavorite(favorite: {\n routing: \"${routing}\"\n }) {\n id\n routing\n }\n }\n `\n })\n\n this.refreshFavorites()\n }\n\n getFullRouting() {\n var routingType = Object.values(this.routingTypes).find(type => type.page == this.page)\n return routingType ? `${this.page}/${this.resourceId}` : this.page\n }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import '@operato/i18n';
|
|
2
|
+
import './apptools/favorite-tool';
|
|
3
|
+
import './viewparts/menu-tree-bar';
|
|
4
|
+
import { html } from 'lit-html';
|
|
5
|
+
import { appendViewpart, TOOL_POSITION, VIEWPART_POSITION } from '@operato/layout';
|
|
6
|
+
import { APPEND_APP_TOOL } from '@things-factory/apptool-base/client';
|
|
7
|
+
import { auth } from '@things-factory/auth-base/dist-client';
|
|
8
|
+
import { ADD_MORENDA } from '@things-factory/more-base/client';
|
|
9
|
+
import { navigate, store } from '@operato/shell';
|
|
10
|
+
import { isMobileDevice } from '@operato/utils';
|
|
11
|
+
export default function bootstrap() {
|
|
12
|
+
if (!isMobileDevice()) {
|
|
13
|
+
appendViewpart({
|
|
14
|
+
name: 'menu-tree-bar',
|
|
15
|
+
viewpart: {
|
|
16
|
+
show: true,
|
|
17
|
+
template: html ` <menu-tree-bar></menu-tree-bar> `
|
|
18
|
+
},
|
|
19
|
+
position: VIEWPART_POSITION.NAVBAR
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
store.dispatch({
|
|
23
|
+
type: APPEND_APP_TOOL,
|
|
24
|
+
tool: {
|
|
25
|
+
name: 'favorite-tool',
|
|
26
|
+
template: html ` <favorite-tool .blackList=${['menu-list']}></favorite-tool> `,
|
|
27
|
+
position: TOOL_POSITION.REAR
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
auth.on('profile', ({ credential }) => {
|
|
31
|
+
if (credential.owner) {
|
|
32
|
+
appendRoleMenusManagementMorenda();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function appendRoleMenusManagementMorenda() {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const useRoleByMenusManagementMenu = ((_b = (_a = store.getState()) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.useRoleByMenusManagementMenu) || false;
|
|
39
|
+
if (useRoleByMenusManagementMenu) {
|
|
40
|
+
store.dispatch({
|
|
41
|
+
type: ADD_MORENDA,
|
|
42
|
+
morenda: {
|
|
43
|
+
icon: html ` <md-icon>menu</md-icon> `,
|
|
44
|
+
name: html ` <ox-i18n msgid="title.role_menus_management"></ox-i18n> `,
|
|
45
|
+
action: () => {
|
|
46
|
+
navigate('role-menus');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AACtB,OAAO,0BAA0B,CAAA;AACjC,OAAO,2BAA2B,CAAA;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QACtB,cAAc,CAAC;YACb,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,IAAI,CAAA,mCAAmC;aAClD;YACD,QAAQ,EAAE,iBAAiB,CAAC,MAAM;SACnC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC;QACb,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE;YACJ,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,IAAI,CAAA,8BAA8B,CAAC,WAAW,CAAC,oBAAoB;YAC7E,QAAQ,EAAE,aAAa,CAAC,IAAI;SAC7B;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QACpC,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;YACrB,gCAAgC,EAAE,CAAA;QACpC,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gCAAgC;;IACvC,MAAM,4BAA4B,GAAG,CAAA,MAAA,MAAC,KAAK,CAAC,QAAQ,EAAU,0CAAE,IAAI,0CAAE,4BAA4B,KAAI,KAAK,CAAA;IAE3G,IAAI,4BAA4B,EAAE,CAAC;QACjC,KAAK,CAAC,QAAQ,CAAC;YACb,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;gBACP,IAAI,EAAE,IAAI,CAAA,2BAA2B;gBACrC,IAAI,EAAE,IAAI,CAAA,2DAA2D;gBACrE,MAAM,EAAE,GAAG,EAAE;oBACX,QAAQ,CAAC,YAAY,CAAC,CAAA;gBACxB,CAAC;aACF;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import '@operato/i18n'\nimport './apptools/favorite-tool'\nimport './viewparts/menu-tree-bar'\n\nimport { html } from 'lit-html'\n\nimport { appendViewpart, TOOL_POSITION, VIEWPART_POSITION } from '@operato/layout'\nimport { APPEND_APP_TOOL } from '@things-factory/apptool-base/client'\nimport { auth } from '@things-factory/auth-base/dist-client'\nimport { ADD_MORENDA } from '@things-factory/more-base/client'\nimport { navigate, store } from '@operato/shell'\nimport { isMobileDevice } from '@operato/utils'\n\nexport default function bootstrap() {\n if (!isMobileDevice()) {\n appendViewpart({\n name: 'menu-tree-bar',\n viewpart: {\n show: true,\n template: html` <menu-tree-bar></menu-tree-bar> `\n },\n position: VIEWPART_POSITION.NAVBAR\n })\n }\n\n store.dispatch({\n type: APPEND_APP_TOOL,\n tool: {\n name: 'favorite-tool',\n template: html` <favorite-tool .blackList=${['menu-list']}></favorite-tool> `,\n position: TOOL_POSITION.REAR\n }\n })\n\n auth.on('profile', ({ credential }) => {\n if (credential.owner) {\n appendRoleMenusManagementMorenda()\n }\n })\n}\n\nfunction appendRoleMenusManagementMorenda() {\n const useRoleByMenusManagementMenu = (store.getState() as any)?.menu?.useRoleByMenusManagementMenu || false\n\n if (useRoleByMenusManagementMenu) {\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>menu</md-icon> `,\n name: html` <ox-i18n msgid=\"title.role_menus_management\"></ox-i18n> `,\n action: () => {\n navigate('role-menus')\n }\n }\n })\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { i18next, localize } from '@operato/i18n';
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
4
|
+
import gql from 'graphql-tag';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
7
|
+
let ChildMenusSelector = class ChildMenusSelector extends localize(i18next)(LitElement) {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.roleMenus = [];
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
const parentMenu = this.parentMenu || {};
|
|
14
|
+
const menus = parentMenu.children || [];
|
|
15
|
+
const roleMenus = this.roleMenus || [];
|
|
16
|
+
return html `
|
|
17
|
+
<div>
|
|
18
|
+
<input id="checkAll" type="checkbox" @change=${e => this.onCheckAll(e)} />
|
|
19
|
+
<label for="checkAll">Check all</label>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<ul menus>
|
|
23
|
+
${menus === null || menus === void 0 ? void 0 : menus.map(menu => html `
|
|
24
|
+
<li>
|
|
25
|
+
<label for="${menu.id}"
|
|
26
|
+
>${menu.name}
|
|
27
|
+
<input
|
|
28
|
+
type="checkbox"
|
|
29
|
+
id="${menu.id}"
|
|
30
|
+
.checked=${roleMenus.map(p => p.id).indexOf(menu.id) > -1}
|
|
31
|
+
.data-menu=${menu.id}
|
|
32
|
+
@change=${e => this.onSave(e)}
|
|
33
|
+
/>
|
|
34
|
+
</label>
|
|
35
|
+
</li>
|
|
36
|
+
`)}
|
|
37
|
+
</ul>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
get menuList() {
|
|
41
|
+
return this.renderRoot.querySelectorAll('ul[menus] input[type=checkbox]');
|
|
42
|
+
}
|
|
43
|
+
async onCheckAll(e) {
|
|
44
|
+
const checked = e.currentTarget.checked;
|
|
45
|
+
Array.from(this.menuList).forEach(checkbox => (checkbox.checked = checked));
|
|
46
|
+
const response = await client.mutate({
|
|
47
|
+
mutation: gql `
|
|
48
|
+
mutation ($roleId: String!, $parentMenuId: String!, $isCheckedAll: Boolean!) {
|
|
49
|
+
updateRoleMenus(roleId: $roleId, parentMenuId: $parentMenuId, isCheckedAll: $isCheckedAll) {
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
54
|
+
variables: { roleId: this.targetRole.id, parentMenuId: this.parentMenu.id, isCheckedAll: checked }
|
|
55
|
+
});
|
|
56
|
+
if (!response.errors) {
|
|
57
|
+
this.dispatchEvent(new CustomEvent('updateRoleMenus'));
|
|
58
|
+
this.showToast(i18next.t('text.data_updated_successfully'));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async onSave(e) {
|
|
62
|
+
const menuId = e.currentTarget.id;
|
|
63
|
+
const isCheckedMenu = e.currentTarget.checked;
|
|
64
|
+
const response = await client.mutate({
|
|
65
|
+
mutation: gql `
|
|
66
|
+
mutation ($roleId: String!, $targetMenuId: String!, $isCheckedMenu: Boolean!) {
|
|
67
|
+
updateRoleMenu(roleId: $roleId, targetMenuId: $targetMenuId, isCheckedMenu: $isCheckedMenu) {
|
|
68
|
+
id
|
|
69
|
+
name
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`,
|
|
73
|
+
variables: { roleId: this.targetRole.id, targetMenuId: menuId, isCheckedMenu }
|
|
74
|
+
});
|
|
75
|
+
if (!response.errors) {
|
|
76
|
+
this.dispatchEvent(new CustomEvent('updateRoleMenus'));
|
|
77
|
+
this.showToast(i18next.t('text.data_updated_successfully'));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
showToast(message) {
|
|
81
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
ChildMenusSelector.styles = [
|
|
85
|
+
css `
|
|
86
|
+
:host {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
border: 1px solid var(--md-sys-color-primary);
|
|
90
|
+
font: normal 15px var(--theme-font);
|
|
91
|
+
color: var(--md-sys-color-secondary);
|
|
92
|
+
}
|
|
93
|
+
div {
|
|
94
|
+
margin: var(--spacing-medium);
|
|
95
|
+
}
|
|
96
|
+
ul {
|
|
97
|
+
flex: 1;
|
|
98
|
+
background-color: var(--md-sys-color-surface);
|
|
99
|
+
overflow: auto;
|
|
100
|
+
display: grid;
|
|
101
|
+
grid-template-columns: 1fr 1fr;
|
|
102
|
+
margin: 0;
|
|
103
|
+
padding: var(--spacing-medium);
|
|
104
|
+
list-style: none;
|
|
105
|
+
border: 1px dashed rgba(0, 0, 0, 0.1);
|
|
106
|
+
border-width: 1px 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
input[type='checkbox'] {
|
|
110
|
+
display: inline;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
li {
|
|
114
|
+
padding: var(--spacing-small);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#checkAll,
|
|
118
|
+
[for='checkAll'] {
|
|
119
|
+
margin-bottom: var(--spacing-medium);
|
|
120
|
+
padding-bottom: var(--spacing-small);
|
|
121
|
+
font-weight: bold;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@media screen and (max-width: 480px) {
|
|
125
|
+
ul {
|
|
126
|
+
grid-template-columns: 1fr;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`
|
|
130
|
+
];
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: Object }),
|
|
133
|
+
__metadata("design:type", Object)
|
|
134
|
+
], ChildMenusSelector.prototype, "parentMenu", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: Array }),
|
|
137
|
+
__metadata("design:type", Array)
|
|
138
|
+
], ChildMenusSelector.prototype, "roleMenus", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: Object }),
|
|
141
|
+
__metadata("design:type", Object)
|
|
142
|
+
], ChildMenusSelector.prototype, "targetRole", void 0);
|
|
143
|
+
ChildMenusSelector = __decorate([
|
|
144
|
+
customElement('child-menus-selector')
|
|
145
|
+
], ChildMenusSelector);
|
|
146
|
+
//# sourceMappingURL=child-menus-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-menus-selector.js","sourceRoot":"","sources":["../../client/components/child-menus-selector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAm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,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AAtIM,yBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4CF;CACF,AA9CY,CA8CZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDAAgB;AAChB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;qDAAsB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDAAgB;AAnDvC,kBAAkB;IADvB,aAAa,CAAC,sBAAsB,CAAC;GAChC,kBAAkB,CAwIvB","sourcesContent":["import { i18next, localize } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\n@customElement('child-menus-selector')\nclass ChildMenusSelector extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--md-sys-color-primary);\n font: normal 15px var(--theme-font);\n color: var(--md-sys-color-secondary);\n }\n div {\n margin: var(--spacing-medium);\n }\n ul {\n flex: 1;\n background-color: var(--md-sys-color-surface);\n overflow: auto;\n display: grid;\n grid-template-columns: 1fr 1fr;\n margin: 0;\n padding: var(--spacing-medium);\n list-style: none;\n border: 1px dashed rgba(0, 0, 0, 0.1);\n border-width: 1px 0;\n }\n\n input[type='checkbox'] {\n display: inline;\n }\n\n li {\n padding: var(--spacing-small);\n }\n\n #checkAll,\n [for='checkAll'] {\n margin-bottom: var(--spacing-medium);\n padding-bottom: var(--spacing-small);\n font-weight: bold;\n }\n\n @media screen and (max-width: 480px) {\n ul {\n grid-template-columns: 1fr;\n }\n }\n `\n ]\n\n @property({ type: Object }) parentMenu: any\n @property({ type: Array }) roleMenus: any[] = []\n @property({ type: Object }) targetRole: any\n\n render() {\n const parentMenu = this.parentMenu || {}\n const menus = parentMenu.children || []\n const roleMenus = this.roleMenus || []\n\n return html`\n <div>\n <input id=\"checkAll\" type=\"checkbox\" @change=${e => this.onCheckAll(e)} />\n <label for=\"checkAll\">Check all</label>\n </div>\n\n <ul menus>\n ${menus?.map(\n menu => html`\n <li>\n <label for=\"${menu.id}\"\n >${menu.name}\n <input\n type=\"checkbox\"\n id=\"${menu.id}\"\n .checked=${roleMenus.map(p => p.id).indexOf(menu.id) > -1}\n .data-menu=${menu.id}\n @change=${e => this.onSave(e)}\n />\n </label>\n </li>\n `\n )}\n </ul>\n `\n }\n\n get menuList() {\n return this.renderRoot.querySelectorAll('ul[menus] input[type=checkbox]')\n }\n\n async onCheckAll(e) {\n const checked = e.currentTarget.checked\n\n Array.from(this.menuList).forEach(checkbox => ((checkbox as HTMLInputElement).checked = checked))\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($roleId: String!, $parentMenuId: String!, $isCheckedAll: Boolean!) {\n updateRoleMenus(roleId: $roleId, parentMenuId: $parentMenuId, isCheckedAll: $isCheckedAll) {\n name\n }\n }\n `,\n variables: { roleId: this.targetRole.id, parentMenuId: this.parentMenu.id, isCheckedAll: checked }\n })\n\n if (!response.errors) {\n this.dispatchEvent(new CustomEvent('updateRoleMenus'))\n this.showToast(i18next.t('text.data_updated_successfully'))\n }\n }\n\n async onSave(e) {\n const menuId = e.currentTarget.id\n const isCheckedMenu = e.currentTarget.checked\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($roleId: String!, $targetMenuId: String!, $isCheckedMenu: Boolean!) {\n updateRoleMenu(roleId: $roleId, targetMenuId: $targetMenuId, isCheckedMenu: $isCheckedMenu) {\n id\n name\n }\n }\n `,\n variables: { roleId: this.targetRole.id, targetMenuId: menuId, isCheckedMenu }\n })\n\n if (!response.errors) {\n this.dispatchEvent(new CustomEvent('updateRoleMenus'))\n this.showToast(i18next.t('text.data_updated_successfully'))\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@operato/data-grist';
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { i18next, localize } from '@operato/i18n';
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
4
|
+
import gql from 'graphql-tag';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
7
|
+
import { isMobileDevice } from '@operato/utils';
|
|
8
|
+
import '@operato/data-grist';
|
|
9
|
+
import { CommonHeaderStyles } from '@operato/styles';
|
|
10
|
+
import { DataGrist } from '@operato/data-grist';
|
|
11
|
+
let RoleSelectPopup = class RoleSelectPopup extends localize(i18next)(LitElement) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this._searchFields = [];
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return html `
|
|
18
|
+
<search-form .fields=${this._searchFields} @submit=${async () => this.dataGrist.fetch()}></search-form>
|
|
19
|
+
|
|
20
|
+
<div class="container">
|
|
21
|
+
<div class="grist">
|
|
22
|
+
<ox-grist
|
|
23
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
24
|
+
.config=${this.config}
|
|
25
|
+
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
26
|
+
></ox-grist>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div class="footer">
|
|
31
|
+
<div filler></div>
|
|
32
|
+
<button @click=${this._selectRole.bind(this)} label=${i18next.t('button.select')} done></button>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
firstUpdated() {
|
|
37
|
+
this._searchFields = [
|
|
38
|
+
{
|
|
39
|
+
name: 'name',
|
|
40
|
+
type: 'text',
|
|
41
|
+
props: {
|
|
42
|
+
placeholder: i18next.t('field.name'),
|
|
43
|
+
searchOper: 'i_like'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'description',
|
|
48
|
+
type: 'text',
|
|
49
|
+
props: {
|
|
50
|
+
placeholder: i18next.t('field.description'),
|
|
51
|
+
searchOper: 'i_like'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
this.config = {
|
|
56
|
+
rows: {
|
|
57
|
+
appendable: false
|
|
58
|
+
},
|
|
59
|
+
columns: [
|
|
60
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
61
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: false },
|
|
62
|
+
{
|
|
63
|
+
type: 'string',
|
|
64
|
+
name: 'name',
|
|
65
|
+
header: i18next.t('field.name'),
|
|
66
|
+
record: {
|
|
67
|
+
editable: false
|
|
68
|
+
},
|
|
69
|
+
width: 200
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'string',
|
|
73
|
+
name: 'description',
|
|
74
|
+
header: i18next.t('field.description'),
|
|
75
|
+
record: {
|
|
76
|
+
editable: true
|
|
77
|
+
},
|
|
78
|
+
width: 250
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'datetime',
|
|
82
|
+
name: 'updatedAt',
|
|
83
|
+
header: i18next.t('field.updated_at'),
|
|
84
|
+
width: 180
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async fetchHandler({ page, limit, sorters = [] }) {
|
|
90
|
+
var _a;
|
|
91
|
+
const filters = ((_a = this.searchForm) === null || _a === void 0 ? void 0 : _a.queryFilters) || [];
|
|
92
|
+
const response = await client.query({
|
|
93
|
+
query: gql `
|
|
94
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
95
|
+
roles(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
96
|
+
items {
|
|
97
|
+
id
|
|
98
|
+
name
|
|
99
|
+
description
|
|
100
|
+
updatedAt
|
|
101
|
+
}
|
|
102
|
+
total
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
variables: {
|
|
107
|
+
filters,
|
|
108
|
+
pagination: { page, limit },
|
|
109
|
+
sortings: sorters
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
total: response.data.roles.total || 0,
|
|
114
|
+
records: response.data.roles.items || []
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
_selectRole() {
|
|
118
|
+
const selectedRole = this.dataGrist.selected[0];
|
|
119
|
+
if (selectedRole) {
|
|
120
|
+
this.dispatchEvent(new CustomEvent('selected', { detail: this.dataGrist.selected[0] }));
|
|
121
|
+
history.back();
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.showToast(i18next.t('text.target_is_not_selected'));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
showToast(message) {
|
|
128
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
RoleSelectPopup.styles = [
|
|
132
|
+
CommonHeaderStyles,
|
|
133
|
+
css `
|
|
134
|
+
:host {
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
background-color: var(--md-sys-color-surface);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.container {
|
|
142
|
+
flex: 1;
|
|
143
|
+
display: flex;
|
|
144
|
+
overflow-y: auto;
|
|
145
|
+
min-height: 20vh;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.grist {
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
flex: 1;
|
|
152
|
+
overflow-y: auto;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
ox-grist {
|
|
156
|
+
overflow-y: hidden;
|
|
157
|
+
flex: 1;
|
|
158
|
+
}
|
|
159
|
+
`
|
|
160
|
+
];
|
|
161
|
+
__decorate([
|
|
162
|
+
property({ type: Array }),
|
|
163
|
+
__metadata("design:type", Array)
|
|
164
|
+
], RoleSelectPopup.prototype, "_searchFields", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property({ type: Object }),
|
|
167
|
+
__metadata("design:type", Object)
|
|
168
|
+
], RoleSelectPopup.prototype, "config", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
query('ox-grist'),
|
|
171
|
+
__metadata("design:type", DataGrist)
|
|
172
|
+
], RoleSelectPopup.prototype, "dataGrist", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
query('search-form'),
|
|
175
|
+
__metadata("design:type", HTMLFormElement)
|
|
176
|
+
], RoleSelectPopup.prototype, "searchForm", void 0);
|
|
177
|
+
RoleSelectPopup = __decorate([
|
|
178
|
+
customElement('role-select-popup')
|
|
179
|
+
], RoleSelectPopup);
|
|
180
|
+
//# sourceMappingURL=role-select-popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-select-popup.js","sourceRoot":"","sources":["../../client/components/role-select-popup.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAA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AC,CAAC,CAAC,CAAA;QAC/C,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACvF,OAAO,CAAC,IAAI,EAAE,CAAA;QAChB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAA;QAC1D,CAAC;IACH,CAAC;IAED,SAAS,CAAC,OAAO;QACf,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AA3JM,sBAAM,GAAG;IACd,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BF;CACF,AA7BY,CA6BZ;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;sDAA0B;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAY;AAEpB;IAAlB,KAAK,CAAC,UAAU,CAAC;8BAAa,SAAS;kDAAA;AAClB;IAArB,KAAK,CAAC,aAAa,CAAC;8BAAc,eAAe;mDAAA;AApC9C,eAAe;IADpB,aAAa,CAAC,mBAAmB,CAAC;GAC7B,eAAe,CA6JpB","sourcesContent":["import { i18next, localize } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state, query } from 'lit/decorators.js'\nimport { isMobileDevice } from '@operato/utils'\nimport '@operato/data-grist'\nimport { CommonHeaderStyles } from '@operato/styles'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\n\n@customElement('role-select-popup')\nclass RoleSelectPopup extends localize(i18next)(LitElement) {\n static styles = [\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background-color: var(--md-sys-color-surface);\n }\n\n .container {\n flex: 1;\n display: flex;\n overflow-y: auto;\n min-height: 20vh;\n }\n\n .grist {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow-y: auto;\n }\n\n ox-grist {\n overflow-y: hidden;\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) _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=${async () => this.dataGrist.fetch()}></search-form>\n\n <div class=\"container\">\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 </div>\n\n <div class=\"footer\">\n <div filler></div>\n <button @click=${this._selectRole.bind(this)} label=${i18next.t('button.select')} done></button>\n </div>\n `\n }\n\n firstUpdated() {\n this._searchFields = [\n {\n name: 'name',\n type: 'text',\n props: {\n placeholder: i18next.t('field.name'),\n searchOper: 'i_like'\n }\n },\n {\n name: 'description',\n type: 'text',\n props: {\n placeholder: i18next.t('field.description'),\n searchOper: 'i_like'\n }\n }\n ]\n\n this.config = {\n rows: {\n appendable: false\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: false },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: false\n },\n width: 200\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n width: 250\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n width: 180\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sorters = [] }: FetchOption) {\n const filters = (this.searchForm as any)?.queryFilters || []\n\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n roles(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings: sorters\n }\n })\n\n return {\n total: response.data.roles.total || 0,\n records: response.data.roles.items || []\n }\n }\n\n _selectRole() {\n const selectedRole = this.dataGrist.selected[0]\n if (selectedRole) {\n this.dispatchEvent(new CustomEvent('selected', { detail: this.dataGrist.selected[0] }))\n history.back()\n } else {\n this.showToast(i18next.t('text.target_is_not_selected'))\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|