@things-factory/menu-ui 8.0.0-alpha.27 → 8.0.0-alpha.29
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/client/apptools/{favorite-tool.js → favorite-tool.ts} +24 -30
- package/client/{bootstrap.js → bootstrap.ts} +1 -1
- package/client/components/{child-menus-selector.js → child-menus-selector.ts} +51 -57
- package/client/components/{role-select-popup.js → role-select-popup.ts} +38 -48
- package/client/pages/{menu-list-page.js → menu-list-page.ts} +37 -37
- package/client/pages/{menu-management-detail.js → menu-management-detail.ts} +55 -65
- package/client/pages/{menu-management.js → menu-management.ts} +33 -41
- package/client/pages/{role-menus-management.js → role-menus-management.ts} +56 -62
- package/client/viewparts/menu-bar.ts +110 -0
- package/client/viewparts/menu-tile-list.ts +216 -0
- package/client/viewparts/{menu-tree-bar.js → menu-tree-bar.ts} +133 -139
- 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.d.ts +0 -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/themes/menu-theme.css +31 -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/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -12
- package/things-factory.config.js +5 -14
- package/client/viewparts/menu-bar.js +0 -114
- package/client/viewparts/menu-tile-list.js +0 -222
- /package/client/{index.js → index.ts} +0 -0
- /package/client/{route.js → route.ts} +0 -0
|
@@ -2,160 +2,156 @@ import '@material/web/icon/icon.js'
|
|
|
2
2
|
|
|
3
3
|
import gql from 'graphql-tag'
|
|
4
4
|
import { css, html, LitElement } from 'lit'
|
|
5
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
5
6
|
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
6
7
|
|
|
7
|
-
import { client, store } from '@things-factory/shell'
|
|
8
|
+
import { client, store } from '@things-factory/shell/client'
|
|
8
9
|
import { ScrollbarStyles } from '@operato/styles'
|
|
9
10
|
|
|
11
|
+
@customElement('menu-tree-bar')
|
|
10
12
|
export default class MenuTreeBar extends connect(store)(LitElement) {
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
ul {
|
|
53
|
-
list-style: none;
|
|
54
|
-
margin: 0;
|
|
55
|
-
padding: 0;
|
|
56
|
-
}
|
|
13
|
+
static styles = [
|
|
14
|
+
ScrollbarStyles,
|
|
15
|
+
css`
|
|
16
|
+
:host {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
min-width: 200px;
|
|
20
|
+
}
|
|
21
|
+
[domain] {
|
|
22
|
+
background: var(--menu-domain-background-color);
|
|
23
|
+
background: linear-gradient(180deg, var(--md-sys-color-secondary) 0%, var(--md-sys-color-primary) 120%);
|
|
24
|
+
padding: var(--menu-domain-padding);
|
|
25
|
+
border-bottom: 1px solid var(--md-sys-color-primary);
|
|
26
|
+
}
|
|
27
|
+
[domain] md-icon {
|
|
28
|
+
margin-right: -8px;
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
color: var(--menu-domain-icon-color);
|
|
31
|
+
}
|
|
32
|
+
[domain] * {
|
|
33
|
+
vertical-align: middle;
|
|
34
|
+
}
|
|
35
|
+
[domain] span {
|
|
36
|
+
padding-left: 7px;
|
|
37
|
+
font: var(--menu-domain-font);
|
|
38
|
+
color: var(--menu-domain-color);
|
|
39
|
+
}
|
|
40
|
+
[domain] select {
|
|
41
|
+
background-color: transparent;
|
|
42
|
+
width: -webkit-fill-available;
|
|
43
|
+
max-width: 175px;
|
|
44
|
+
border: none;
|
|
45
|
+
|
|
46
|
+
font: var(--menu-domain-font);
|
|
47
|
+
color: var(--menu-domain-color);
|
|
48
|
+
}
|
|
49
|
+
select:focus {
|
|
50
|
+
outline: 0;
|
|
51
|
+
}
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
ul {
|
|
54
|
+
list-style: none;
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
}
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
ul[toplevel] {
|
|
60
|
+
overflow: auto;
|
|
61
|
+
}
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
li {
|
|
64
|
+
border-bottom: var(--menu-tree-toplevel-border-bottom);
|
|
65
|
+
}
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
text-decoration: none;
|
|
74
|
-
position: relative;
|
|
75
|
-
}
|
|
67
|
+
[grouplevel] li {
|
|
68
|
+
border-bottom: var(--menu-tree-grouplevel-border-bottom);
|
|
69
|
+
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
71
|
+
li span,
|
|
72
|
+
li a {
|
|
73
|
+
display: block;
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
position: relative;
|
|
76
|
+
}
|
|
84
77
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
[menutype] {
|
|
79
|
+
position: absolute;
|
|
80
|
+
font-size: 1.2em;
|
|
81
|
+
right: 0;
|
|
82
|
+
bottom: 50%;
|
|
83
|
+
transform: translate(-5px, 50%);
|
|
84
|
+
}
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
color: var(--menu-tree-toplevel-color);
|
|
93
|
-
}
|
|
86
|
+
[favorite] {
|
|
87
|
+
color: var(--menu-tree-favorite-color, tomato);
|
|
88
|
+
}
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
90
|
+
[groupmenu] > span {
|
|
91
|
+
padding: 9px 9px 7px 10px;
|
|
92
|
+
font: var(--menu-tree-toplevel-font);
|
|
93
|
+
color: var(--menu-tree-toplevel-color);
|
|
94
|
+
}
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
border-radius: 50%;
|
|
109
|
-
margin-right: 5px;
|
|
110
|
-
}
|
|
96
|
+
a {
|
|
97
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
98
|
+
padding: 7px 7px 6px 15px;
|
|
99
|
+
font: var(--menu-tree-grouplevel-font);
|
|
100
|
+
color: var(--menu-tree-grouplevel-color);
|
|
101
|
+
}
|
|
111
102
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
[groupmenu] > span::before {
|
|
104
|
+
content: '';
|
|
105
|
+
display: inline-block;
|
|
106
|
+
width: var(--menu-tree-toplevel-icon-size);
|
|
107
|
+
height: var(--menu-tree-toplevel-icon-size);
|
|
108
|
+
border: var(--menu-tree-toplevel-icon-border);
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
margin-right: 5px;
|
|
111
|
+
}
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
a span::before {
|
|
114
|
+
content: '-';
|
|
115
|
+
margin-right: 4px;
|
|
116
|
+
}
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
[expanded] > span {
|
|
119
|
+
font-weight: bold;
|
|
120
|
+
color: var(--menu-tree-focus-color);
|
|
121
|
+
}
|
|
125
122
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
[grouplevel] {
|
|
124
|
+
overflow-y: hidden;
|
|
125
|
+
max-height: 0;
|
|
129
126
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
127
|
+
transition-property: all;
|
|
128
|
+
transition-duration: 0.7s;
|
|
129
|
+
}
|
|
134
130
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
background-color: rgba(0, 0, 0, 0.6);
|
|
140
|
-
padding-left: 12px;
|
|
141
|
-
}
|
|
142
|
-
`
|
|
143
|
-
]
|
|
144
|
-
}
|
|
131
|
+
[expanded] > [grouplevel] {
|
|
132
|
+
overflow-y: auto;
|
|
133
|
+
max-height: 500px;
|
|
134
|
+
}
|
|
145
135
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
136
|
+
li[active] a {
|
|
137
|
+
color: var(--menu-tree-focus-color);
|
|
138
|
+
font-weight: bold;
|
|
139
|
+
border-left: var(--menu-tree-grouplevel-active-border-left);
|
|
140
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
141
|
+
padding-left: 12px;
|
|
142
|
+
}
|
|
143
|
+
`
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
@property({ type: String }) menuId?: string
|
|
147
|
+
@property({ type: Array }) menus: any[] = []
|
|
148
|
+
@property({ type: Array }) favorites: string[] = []
|
|
149
|
+
@property({ type: Array }) routingTypes: string[] = []
|
|
150
|
+
@property({ type: String }) page?: string
|
|
151
|
+
@property({ type: Object }) user?: any
|
|
152
|
+
@property({ type: String }) contextPath?: string
|
|
153
|
+
@property({ type: Array }) domains: any[] = []
|
|
154
|
+
@property({ type: Object }) domain?: any
|
|
159
155
|
|
|
160
156
|
render() {
|
|
161
157
|
var domains = this.domains || []
|
|
@@ -201,7 +197,7 @@ export default class MenuTreeBar extends connect(store)(LitElement) {
|
|
|
201
197
|
${menu.children.map(subMenu => {
|
|
202
198
|
const routing = this._getFullRouting(subMenu)
|
|
203
199
|
const favorite = this.favorites.includes(routing)
|
|
204
|
-
const { icon } = this.routingTypes[subMenu.routingType] || {}
|
|
200
|
+
const { icon } = this.routingTypes[subMenu.routingType] || ({} as any)
|
|
205
201
|
const typeIcon = icon ? icon : favorite ? 'star' : null
|
|
206
202
|
|
|
207
203
|
return html`
|
|
@@ -228,9 +224,9 @@ export default class MenuTreeBar extends connect(store)(LitElement) {
|
|
|
228
224
|
|
|
229
225
|
await this.updateComplete
|
|
230
226
|
|
|
231
|
-
var active = this.
|
|
227
|
+
var active = this.renderRoot.querySelector('[active]')
|
|
232
228
|
if (active) {
|
|
233
|
-
active.parentElement
|
|
229
|
+
active.parentElement?.parentElement?.setAttribute('expanded', '')
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
|
|
@@ -256,7 +252,7 @@ export default class MenuTreeBar extends connect(store)(LitElement) {
|
|
|
256
252
|
return resourceUrl
|
|
257
253
|
}
|
|
258
254
|
|
|
259
|
-
var { page } = this.routingTypes[routingType]
|
|
255
|
+
var { page } = this.routingTypes[routingType] as any
|
|
260
256
|
return titleField ? `${page}/${menu[titleField]}` : `${page}/${name}`
|
|
261
257
|
}
|
|
262
258
|
|
|
@@ -291,5 +287,3 @@ export default class MenuTreeBar extends connect(store)(LitElement) {
|
|
|
291
287
|
return response.data.userMenus
|
|
292
288
|
}
|
|
293
289
|
}
|
|
294
|
-
|
|
295
|
-
window.customElements.define('menu-tree-bar', MenuTreeBar)
|
|
@@ -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,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAG3D,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;IAArD;;QAiBwB,YAAO,GAAY,KAAK,CAAA;QAC1B,iBAAY,GAAU,EAAE,CAAA;QACxB,cAAS,GAAa,EAAE,CAAA;IA6FrD,CAAC;IA3FC,MAAM;QACJ,IAAI,UAAU,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAEjE,OAAO,UAAU;YACf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AAE,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,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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 {};
|