@things-factory/meta-ui 7.0.1-alpha.51 → 7.0.1-alpha.52
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/bootstrap.ts +2 -6
- package/client/index.ts +0 -20
- package/client/load-components.ts +17 -0
- package/client/pages/entity/main-menu-selector.js +0 -4
- package/client/pages/personalize/personal-column-selector.js +0 -4
- package/dist-client/actions/main.d.ts +0 -1
- package/dist-client/actions/main.js +0 -1
- package/dist-client/actions/main.js.map +1 -1
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -5
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/index.d.ts +0 -16
- package/dist-client/index.js +0 -17
- package/dist-client/index.js.map +1 -1
- package/dist-client/load-components.d.ts +15 -0
- package/dist-client/load-components.js +17 -0
- package/dist-client/load-components.js.map +1 -0
- package/dist-client/pages/entity/main-menu-selector.js +0 -4
- package/dist-client/pages/entity/main-menu-selector.js.map +1 -1
- package/dist-client/pages/personalize/personal-column-selector.js +0 -4
- package/dist-client/pages/personalize/personal-column-selector.js.map +1 -1
- package/dist-client/reducers/main.js +0 -3
- package/dist-client/reducers/main.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/dynamic-menu/dynamic-menu-query.js +50 -16
- package/dist-server/service/dynamic-menu/dynamic-menu-query.js.map +1 -1
- package/dist-server/service/dynamic-menu/dynamic-menu-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/dynamic-menu/dynamic-menu-query.ts +145 -115
- package/server/service/dynamic-menu/dynamic-menu-type.ts +11 -16
- package/client/actions/main.js +0 -127
- package/client/pages/menu/dynamic-menu-setting-let.ts +0 -82
- package/client/reducers/main.js +0 -79
- package/client/viewparts/dynamic-menu-part.ts +0 -119
- package/server/controllers/index.ts +0 -0
package/client/reducers/main.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { UPDATE_META_UI } from '../actions/main'
|
|
2
|
-
import cloneDeep from 'lodash-es/cloneDeep'
|
|
3
|
-
|
|
4
|
-
const INITIAL_STATE = {
|
|
5
|
-
template: [],
|
|
6
|
-
addon: [],
|
|
7
|
-
menus: []
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const UPDATE_META_MENU_TEMPLATE = 'UPDATE_META_MENU_TEMPLATE'
|
|
11
|
-
|
|
12
|
-
function buildMenus(template, addon) {
|
|
13
|
-
var menus = cloneDeep(template || [])
|
|
14
|
-
addon = addon || []
|
|
15
|
-
|
|
16
|
-
/* make group by parent */
|
|
17
|
-
const groups =
|
|
18
|
-
addon
|
|
19
|
-
.filter(menu => menu.active)
|
|
20
|
-
.sort((menu1, menu2) => (menu1.parent || '').localeCompare(menu2.parent || '') || menu1.rank - menu2.rank)
|
|
21
|
-
.reduce((arr, menu) => {
|
|
22
|
-
let lastparent = arr.length > 0 && arr[arr.length - 1][0].parent
|
|
23
|
-
|
|
24
|
-
if (!lastparent || lastparent !== menu.parent) {
|
|
25
|
-
arr.push([menu])
|
|
26
|
-
} else {
|
|
27
|
-
arr[arr.length - 1].push(menu)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return arr
|
|
31
|
-
}, []) || []
|
|
32
|
-
|
|
33
|
-
/* iterate group to put menu into parent menu */
|
|
34
|
-
groups.forEach(group => {
|
|
35
|
-
group.forEach(menu => {
|
|
36
|
-
const { parent, name, rank, type, value, icon } = menu
|
|
37
|
-
|
|
38
|
-
const parentMenu = parent && menus.find(m => m.name === parent)
|
|
39
|
-
if (parentMenu && !parentMenu.menus) {
|
|
40
|
-
parentMenu.menus = []
|
|
41
|
-
}
|
|
42
|
-
const children = parentMenu ? parentMenu.menus : menus
|
|
43
|
-
children.push({
|
|
44
|
-
name,
|
|
45
|
-
type,
|
|
46
|
-
path:
|
|
47
|
-
type === 'page'
|
|
48
|
-
? value
|
|
49
|
-
: type === 'board'
|
|
50
|
-
? `board-viewer/${value}?title=${name}`
|
|
51
|
-
: type === 'interactive-board'
|
|
52
|
-
? `board-viewer/${value}?interactive=true&title=${name}`
|
|
53
|
-
: '',
|
|
54
|
-
icon: icon || (type === 'page' ? 'menu' : type === 'board' || type === 'interactive-board' ? 'dashboard' : '')
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
return menus
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const metaUI = (state = INITIAL_STATE, action) => {
|
|
63
|
-
switch (action.type) {
|
|
64
|
-
case UPDATE_META_UI:
|
|
65
|
-
return { ...state }
|
|
66
|
-
|
|
67
|
-
case UPDATE_META_MENU_TEMPLATE:
|
|
68
|
-
return {
|
|
69
|
-
...state,
|
|
70
|
-
template: action.template,
|
|
71
|
-
addon: action.addon,
|
|
72
|
-
menus: buildMenus(action.template, action.addon)
|
|
73
|
-
}
|
|
74
|
-
default:
|
|
75
|
-
return state
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default metaUI
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
import '@operato/menu/ox-menu-portrait.js'
|
|
3
|
-
import '@operato/menu/ox-menu-landscape.js'
|
|
4
|
-
|
|
5
|
-
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
6
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
7
|
-
import { connect } from 'pwa-helpers'
|
|
8
|
-
|
|
9
|
-
import { store } from '@operato/shell'
|
|
10
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
11
|
-
|
|
12
|
-
import { Menu } from '@operato/menu/dist/src/types'
|
|
13
|
-
|
|
14
|
-
function isActiveMenu(menu: Menu, path: string) {
|
|
15
|
-
return menu.path?.split('?')[0] === path || (menu.active && typeof menu.active === 'function' && menu.active.call(menu, { path }))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// TODO @operato/menu/ox-menu-part를 사용하도록 통합되어야 한다.
|
|
19
|
-
@customElement('dynamic-menu-part')
|
|
20
|
-
export class DynamicMenuPart extends connect(store)(LitElement) {
|
|
21
|
-
static styles = [
|
|
22
|
-
ScrollbarStyles,
|
|
23
|
-
css`
|
|
24
|
-
:host {
|
|
25
|
-
display: flex;
|
|
26
|
-
overflow-y: auto;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
height: 100%;
|
|
29
|
-
min-width: 200px;
|
|
30
|
-
background-color: var(--theme-white-color);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:host([landscape]) {
|
|
34
|
-
overflow-x: auto;
|
|
35
|
-
flex-direction: row;
|
|
36
|
-
width: 100%;
|
|
37
|
-
min-height: 20px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
ox-menu-portrait,
|
|
41
|
-
ox-menu-landscape {
|
|
42
|
-
flex: 1;
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
@property({ type: String }) page!: string
|
|
48
|
-
@property({ type: String }) resourceId?: string
|
|
49
|
-
@property({ type: Array }) menus?: Menu[]
|
|
50
|
-
@property({ type: String }) orientation?: 'landscape' | 'portrait'
|
|
51
|
-
|
|
52
|
-
@state() slotTemplate: any
|
|
53
|
-
@state() _activeTopLevel?: Menu
|
|
54
|
-
@state() _activeMenu?: Menu
|
|
55
|
-
@state() _path?: string
|
|
56
|
-
|
|
57
|
-
render() {
|
|
58
|
-
return html`
|
|
59
|
-
<slot name="head"></slot>
|
|
60
|
-
${this.orientation !== 'landscape'
|
|
61
|
-
? html`<ox-menu-portrait .menus=${this.menus} .activeTopLevel=${this._activeTopLevel} .activeMenu=${this._activeMenu} .path=${this._path}></ox-menu-portrait>`
|
|
62
|
-
: html`<ox-menu-landscape .menus=${this.menus} .activeTopLevel=${this._activeTopLevel} .activeMenu=${this._activeMenu} .path=${this._path}></ox-menu-landscape>`}
|
|
63
|
-
<slot name="tail"></slot>
|
|
64
|
-
`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
firstUpdated() {
|
|
68
|
-
this.renderRoot.addEventListener('active-toplevel', (e: Event) => {
|
|
69
|
-
e.stopPropagation()
|
|
70
|
-
e.preventDefault()
|
|
71
|
-
|
|
72
|
-
this._activeTopLevel = (e as CustomEvent).detail
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
updated(changes: PropertyValues<this>) {
|
|
77
|
-
if (changes.has('menus') || changes.has('page') || changes.has('resourceId')) {
|
|
78
|
-
this.findActivePage()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (changes.has('orientation')) {
|
|
82
|
-
if (this.orientation == 'portrait') {
|
|
83
|
-
this.removeAttribute('landscape')
|
|
84
|
-
} else {
|
|
85
|
-
this.setAttribute('landscape', '')
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (changes.has('slotTemplate')) {
|
|
90
|
-
this.replaceChild(this.slotTemplate, this.renderRoot)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
stateChanged(state: any): void {
|
|
95
|
-
this.page = state.route.page
|
|
96
|
-
this.resourceId = state.route.resourceId
|
|
97
|
-
this.menus = state.metaUI.menus || []
|
|
98
|
-
this.slotTemplate = state.metaUI.slotTemplate
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private findActivePage() {
|
|
102
|
-
var path = this.resourceId ? `${this.page}/${this.resourceId}` : this.page
|
|
103
|
-
var menus = this.menus || []
|
|
104
|
-
var activeMenu
|
|
105
|
-
|
|
106
|
-
this._activeTopLevel = menus.find(menu => {
|
|
107
|
-
if (isActiveMenu(menu, path)) {
|
|
108
|
-
activeMenu = menu
|
|
109
|
-
return true
|
|
110
|
-
} else if (menu.menus) {
|
|
111
|
-
activeMenu = menu.menus.find(menu => isActiveMenu(menu, path))
|
|
112
|
-
return !!activeMenu
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
this._path = path
|
|
117
|
-
this._activeMenu = activeMenu || this._activeTopLevel
|
|
118
|
-
}
|
|
119
|
-
}
|
|
File without changes
|