@questwork/vue-q-widget-vue3 3.1.0
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/.babelrc.json +16 -0
- package/LICENSE +9 -0
- package/dist/q-widget.min.js +14 -0
- package/dist/q-widget.min.js.LICENSE.txt +1 -0
- package/lib/helpers/controller/index.js +11 -0
- package/lib/helpers/controller/saveState.js +26 -0
- package/lib/helpers/controller/showError.js +27 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utilities/configHandler/configHandler.js +26 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/buttonsHandler.js +41 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/elementQFormConfigHandler.js +38 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/index.js +1 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/layoutHandler.js +54 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/actionsHandler.js +41 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/bulkActionHandler.js +53 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/elementQListConfigHandler.js +43 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/headersHandler.js +48 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/index.js +1 -0
- package/lib/helpers/utilities/configHandler/handlers/index.js +15 -0
- package/lib/helpers/utilities/configHandler/index.js +1 -0
- package/lib/helpers/utilities/index.js +2 -0
- package/lib/helpers/utilities/setId/index.js +1 -0
- package/lib/helpers/utilities/setId/setId.js +10 -0
- package/lib/index.js +2 -0
- package/lib/models/configs/config.js +23 -0
- package/lib/models/configs/elementQForm/buttonHandler.js +68 -0
- package/lib/models/configs/elementQForm/elementQForm.js +34 -0
- package/lib/models/configs/elementQForm/index.js +1 -0
- package/lib/models/configs/elementQForm/makeFormHandler.js +27 -0
- package/lib/models/configs/elementQForm/nodeHandler.js +60 -0
- package/lib/models/configs/elementQGrid/elementQGrid.js +50 -0
- package/lib/models/configs/elementQGrid/index.js +1 -0
- package/lib/models/configs/elementQGrid/makeClasses.js +86 -0
- package/lib/models/configs/elementQList/elementQList.js +75 -0
- package/lib/models/configs/elementQList/index.js +1 -0
- package/lib/models/configs/elementQList/makeQWidgetQListBulkButton.js +78 -0
- package/lib/models/configs/elementQList/makeQWidgetQListButton.js +83 -0
- package/lib/models/configs/elementQList/makeQWidgetQListHeader.js +75 -0
- package/lib/models/configs/index.js +3 -0
- package/lib/models/controller/controller.js +67 -0
- package/lib/models/controller/index.js +1 -0
- package/lib/models/controllerHelpers/controllerHelpers.js +46 -0
- package/lib/models/controllerHelpers/index.js +1 -0
- package/lib/models/factories/index.js +1 -0
- package/lib/models/factories/nodeFactory.js +55 -0
- package/lib/models/index.js +5 -0
- package/lib/models/nodes/container.js +37 -0
- package/lib/models/nodes/containers/box.js +16 -0
- package/lib/models/nodes/containers/column.js +16 -0
- package/lib/models/nodes/containers/headerSticky.js +16 -0
- package/lib/models/nodes/containers/index.js +18 -0
- package/lib/models/nodes/containers/row.js +16 -0
- package/lib/models/nodes/element.js +124 -0
- package/lib/models/nodes/elements/index.js +33 -0
- package/lib/models/nodes/elements/qButton.js +15 -0
- package/lib/models/nodes/elements/qForm.js +67 -0
- package/lib/models/nodes/elements/qGrid.js +35 -0
- package/lib/models/nodes/elements/qHtml.js +15 -0
- package/lib/models/nodes/elements/qImport.js +15 -0
- package/lib/models/nodes/elements/qLabel.js +15 -0
- package/lib/models/nodes/elements/qList.js +46 -0
- package/lib/models/nodes/elements/qPaginator.js +20 -0
- package/lib/models/nodes/elements/qTab.js +19 -0
- package/lib/models/nodes/index.js +21 -0
- package/lib/models/nodes/node.js +69 -0
- package/package.json +73 -0
- package/vite.config.js +52 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NodeFactory } from '../factories'
|
|
2
|
+
import { setId } from '../../helpers'
|
|
3
|
+
|
|
4
|
+
class Controller {
|
|
5
|
+
constructor(opt = {}) {
|
|
6
|
+
this.css = opt.css || {}
|
|
7
|
+
this.controllerHelpers = opt.controllerHelpers
|
|
8
|
+
this.eventHandlers = opt.eventHandlers || {}
|
|
9
|
+
this.id = opt.id || setId('controller')
|
|
10
|
+
this.initialState = opt.initialState
|
|
11
|
+
this.name = opt.name
|
|
12
|
+
this.saveStateKeys = opt.saveStateKeys || []
|
|
13
|
+
this.setLayout(opt.layout, opt.controllerHelpers)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get isValid() {
|
|
17
|
+
return !!this.id && !!this.layout
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static init(layout) {
|
|
21
|
+
const instance = new this(layout)
|
|
22
|
+
return instance.isValid ? instance : null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getElements() {
|
|
26
|
+
return this.elements || []
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getElementByElementName(elementName) {
|
|
30
|
+
return this.elements.find((element) => (element.getElementName() === elementName))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getState() {
|
|
34
|
+
return {
|
|
35
|
+
...this.getControllerState(),
|
|
36
|
+
...this.layout.getElementState()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getControllerState() {
|
|
41
|
+
return this.state
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setLayout(layout, controllerHelpers) {
|
|
45
|
+
this.layout = NodeFactory.init({ layout, controllerHelpers })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setElements(elements) {
|
|
49
|
+
this.elements = elements
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
updateState(state) {
|
|
53
|
+
this.state = {
|
|
54
|
+
...this.state,
|
|
55
|
+
...state
|
|
56
|
+
}
|
|
57
|
+
this.layout.updateElementState(this.state)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default {
|
|
62
|
+
Controller
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
Controller
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Controller } from './controller'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class ControllerHelpers {
|
|
2
|
+
constructor(opt) {
|
|
3
|
+
this.permissionHandler = permissionHandler
|
|
4
|
+
Object.keys(opt).forEach((key) => {
|
|
5
|
+
this[key] = opt[key]
|
|
6
|
+
})
|
|
7
|
+
}
|
|
8
|
+
static init(controllerHelpers) {
|
|
9
|
+
const instance = new ControllerHelpers(controllerHelpers)
|
|
10
|
+
return instance.isValid ? instance : null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get isValid() {
|
|
14
|
+
return isFunction(this.getControllerState)
|
|
15
|
+
&& isFunction(this.getControllerUniqueKey)
|
|
16
|
+
&& isFunction(this.saveControllerState)
|
|
17
|
+
&& isFunction(this.startLoading)
|
|
18
|
+
&& isFunction(this.stopLoading)
|
|
19
|
+
&& isFunction(this.runChains)
|
|
20
|
+
&& this.qForm && isFunction(this.qForm.NodeHelper)
|
|
21
|
+
&& this.qGrid && isFunction(this.qGrid.QItem) && isFunction(this.qGrid.Cell)
|
|
22
|
+
&& this.qList && isFunction(this.qList.QRow) && isFunction(this.qList.QListBulkButton) && isFunction(this.qList.QListButton)
|
|
23
|
+
&& this.qUtilities && isFunction(this.qUtilities.convertString) && isFunction(this.qUtilities.getValidation) && isFunction(this.qUtilities.lodash)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isFunction(fun) {
|
|
28
|
+
return typeof fun === 'function'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function permissionHandler() {
|
|
32
|
+
return {
|
|
33
|
+
isAllowCreate: true,
|
|
34
|
+
isAllowRead: true,
|
|
35
|
+
isAllowUpdate: true,
|
|
36
|
+
isAllowDelete: true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default {
|
|
41
|
+
ControllerHelpers
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
ControllerHelpers
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ControllerHelpers } from './controllerHelpers'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NodeFactory } from './nodeFactory'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NODE_TYPE } from '../nodes'
|
|
2
|
+
|
|
3
|
+
class NodeFactory {
|
|
4
|
+
static init({ layout = {}, controllerHelpers = {} } = {}) {
|
|
5
|
+
const nodes = []
|
|
6
|
+
return recursive({ layout, nodes, controllerHelpers })
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function recursive({ layout, nodes, controllerHelpers }) {
|
|
11
|
+
if (layout instanceof NODE_TYPE.Node) {
|
|
12
|
+
return layout
|
|
13
|
+
}
|
|
14
|
+
const item = {
|
|
15
|
+
...layout,
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(item.children)) {
|
|
18
|
+
item.children = item.children.map((child) => (recursive({ layout: child, nodes, controllerHelpers })))
|
|
19
|
+
}
|
|
20
|
+
return initNode(item, nodes, controllerHelpers)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function initNode(layout, nodes, controllerHelpers) {
|
|
24
|
+
const { nodeType, permissions } = layout || {}
|
|
25
|
+
if (typeof NODE_TYPE[nodeType] === 'function') {
|
|
26
|
+
const { permissionHandler } = controllerHelpers
|
|
27
|
+
const permissionResult = permissions ? permissionHandler(permissions) : {
|
|
28
|
+
isAllowCreate: true,
|
|
29
|
+
isAllowRead: true,
|
|
30
|
+
isAllowUpdate: true,
|
|
31
|
+
isAllowDelete: true,
|
|
32
|
+
}
|
|
33
|
+
const i = (NODE_TYPE[nodeType]).init({
|
|
34
|
+
...layout,
|
|
35
|
+
permissionResult
|
|
36
|
+
})
|
|
37
|
+
if (i) {
|
|
38
|
+
if (i.isExist(nodes)) {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
nodes.push(i)
|
|
42
|
+
return i
|
|
43
|
+
}
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
NodeFactory
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
NodeFactory
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Node } from './node'
|
|
2
|
+
|
|
3
|
+
class Container extends Node {
|
|
4
|
+
constructor(opt = {}) {
|
|
5
|
+
super(opt)
|
|
6
|
+
this.children = opt.children || []
|
|
7
|
+
this.nodeType = 'Container'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getChildren() {
|
|
11
|
+
return this.children
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getValidChildren() {
|
|
15
|
+
return this.getChildren().filter((i) => i)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getElementState() {
|
|
19
|
+
return this.getValidChildren().reduce((acc, child) => ({
|
|
20
|
+
...acc,
|
|
21
|
+
...child.getElementState()
|
|
22
|
+
}), {})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
updateElementState(state) {
|
|
26
|
+
this.getValidChildren().forEach((child) => child.updateElementState(state))
|
|
27
|
+
return this
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
Container
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
Container
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Container } from '../container'
|
|
2
|
+
|
|
3
|
+
class ContainerColumn extends Container {
|
|
4
|
+
constructor(opt = {}) {
|
|
5
|
+
super(opt)
|
|
6
|
+
this.nodeType = 'ContainerColumn'
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
ContainerColumn
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
ContainerColumn
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Container } from '../container'
|
|
2
|
+
|
|
3
|
+
class ContainerHeaderSticky extends Container {
|
|
4
|
+
constructor(opt = {}) {
|
|
5
|
+
super(opt)
|
|
6
|
+
this.nodeType = 'ContainerHeaderSticky'
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
ContainerHeaderSticky
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
ContainerHeaderSticky
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContainerBox } from './box'
|
|
2
|
+
import { ContainerColumn } from './column'
|
|
3
|
+
import { ContainerHeaderSticky } from './headerSticky'
|
|
4
|
+
import { ContainerRow } from './row'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
ContainerBox,
|
|
8
|
+
ContainerColumn,
|
|
9
|
+
ContainerHeaderSticky,
|
|
10
|
+
ContainerRow
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
ContainerBox,
|
|
15
|
+
ContainerColumn,
|
|
16
|
+
ContainerHeaderSticky,
|
|
17
|
+
ContainerRow
|
|
18
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Node } from './node'
|
|
2
|
+
import { configHandler } from '../../helpers'
|
|
3
|
+
|
|
4
|
+
class Element extends Node {
|
|
5
|
+
constructor(opt = {}) {
|
|
6
|
+
super(opt)
|
|
7
|
+
this.configPermissions = opt.configPermissions
|
|
8
|
+
this.name = opt.name
|
|
9
|
+
this.nodeType = opt.nodeType || 'Element'
|
|
10
|
+
this.state = {}
|
|
11
|
+
this.configHandler(opt.config)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get isCreated() {
|
|
15
|
+
return super.isCreated && !!this.component
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get isValid() {
|
|
19
|
+
return super.isValid && !!this.name
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get hasConfigPermissions() {
|
|
23
|
+
return !!this.configPermissions
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get stateName() {
|
|
27
|
+
return {
|
|
28
|
+
...this.defaultStateName,
|
|
29
|
+
...this.config.stateName
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addComponent(component) {
|
|
34
|
+
this.component = component
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
configHandler(config = {}) {
|
|
38
|
+
if (this.hasConfigPermissions) {
|
|
39
|
+
this.config = configHandler({ config, configPermissions: this.configPermissions, type: this.nodeType })
|
|
40
|
+
} else {
|
|
41
|
+
this.config = config
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getConfig() {
|
|
46
|
+
return this.config || {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getComponent() {
|
|
50
|
+
return this.component
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getElementName() {
|
|
54
|
+
return this.name
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getHandlers() {
|
|
58
|
+
const elementName = this.getElementName()
|
|
59
|
+
const { elementHandlers = {} } = this.state
|
|
60
|
+
return elementHandlers[elementName] || {}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getState() {
|
|
64
|
+
return this.state
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getElementState() {
|
|
68
|
+
return _mergeState(this.state, this.stateName)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onCreated({ component, payload = {} }) {
|
|
72
|
+
this.addComponent(component)
|
|
73
|
+
this.updateState(payload)
|
|
74
|
+
return this
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
update(obj) {
|
|
78
|
+
this.updateElementState(obj)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
updateState(obj) {
|
|
82
|
+
this.state = {
|
|
83
|
+
...this.state,
|
|
84
|
+
...obj
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
updateElementState(state) {
|
|
89
|
+
const updatedState = _updateState(state, this.stateName)
|
|
90
|
+
this.updateState(updatedState)
|
|
91
|
+
return this
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _mergeState(state, stateName) {
|
|
96
|
+
return Object.keys(stateName).reduce((acc, elementStateKey) => {
|
|
97
|
+
const controllerStateKey = stateName[elementStateKey]
|
|
98
|
+
const value = state[elementStateKey]
|
|
99
|
+
return {
|
|
100
|
+
...acc,
|
|
101
|
+
[controllerStateKey]: value
|
|
102
|
+
}
|
|
103
|
+
}, {})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function _updateState(state, stateName) {
|
|
107
|
+
return Object.keys(stateName).reduce((acc, elementStateKey) => {
|
|
108
|
+
const controllerStateKey = stateName[elementStateKey]
|
|
109
|
+
const value = state[controllerStateKey]
|
|
110
|
+
delete acc[controllerStateKey]
|
|
111
|
+
return {
|
|
112
|
+
...acc,
|
|
113
|
+
[elementStateKey]: value
|
|
114
|
+
}
|
|
115
|
+
}, state)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default {
|
|
119
|
+
Element
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
Element
|
|
124
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ElementQButton } from './qButton'
|
|
2
|
+
import { ElementQForm } from './qForm'
|
|
3
|
+
import { ElementQGrid } from './qGrid'
|
|
4
|
+
import { ElementQHtml } from './qHtml'
|
|
5
|
+
import { ElementQImport } from './qImport'
|
|
6
|
+
import { ElementQLabel } from './qLabel'
|
|
7
|
+
import { ElementQList } from './qList'
|
|
8
|
+
import { ElementQPaginator } from './qPaginator'
|
|
9
|
+
import { ElementQTab } from './qTab'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
ElementQButton,
|
|
13
|
+
ElementQForm,
|
|
14
|
+
ElementQGrid,
|
|
15
|
+
ElementQHtml,
|
|
16
|
+
ElementQImport,
|
|
17
|
+
ElementQLabel,
|
|
18
|
+
ElementQList,
|
|
19
|
+
ElementQPaginator,
|
|
20
|
+
ElementQTab,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
ElementQButton,
|
|
25
|
+
ElementQForm,
|
|
26
|
+
ElementQGrid,
|
|
27
|
+
ElementQHtml,
|
|
28
|
+
ElementQImport,
|
|
29
|
+
ElementQLabel,
|
|
30
|
+
ElementQList,
|
|
31
|
+
ElementQPaginator,
|
|
32
|
+
ElementQTab,
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Element } from '../element'
|
|
2
|
+
import { ElementQFormConfig } from '../../configs'
|
|
3
|
+
|
|
4
|
+
class ElementQForm extends Element {
|
|
5
|
+
constructor(opt = {}) {
|
|
6
|
+
super(opt)
|
|
7
|
+
this.defaultStateName = {
|
|
8
|
+
axios: 'axios',
|
|
9
|
+
formData: 'formData',
|
|
10
|
+
formErrors: 'formErrors',
|
|
11
|
+
formNode: 'formNode',
|
|
12
|
+
pageKey: 'pageKey',
|
|
13
|
+
qForm: 'qForm'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getConfig(helpers) {
|
|
18
|
+
let config = this.config || {}
|
|
19
|
+
if (this.state.qForm) {
|
|
20
|
+
const { lodash } = helpers.qUtilities
|
|
21
|
+
const stateConfig = _getStateConfig(this.state.qForm)
|
|
22
|
+
config = lodash.mergeWith(stateConfig, config || {}, _customizer)
|
|
23
|
+
}
|
|
24
|
+
return typeof ElementQFormConfig === 'function' ? ElementQFormConfig.init({
|
|
25
|
+
...config,
|
|
26
|
+
helpers: {
|
|
27
|
+
...helpers,
|
|
28
|
+
element: this
|
|
29
|
+
},
|
|
30
|
+
}) : {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getFormCustomizer() {
|
|
34
|
+
const { formCustomizer } = this.getHandlers()
|
|
35
|
+
return typeof formCustomizer === 'function' ? formCustomizer : _customizer
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _customizer(objValue, srcValue) {
|
|
40
|
+
if (Array.isArray(objValue)) {
|
|
41
|
+
return srcValue || null
|
|
42
|
+
}
|
|
43
|
+
if (typeof srcValue === 'number' || typeof srcValue === 'boolean') {
|
|
44
|
+
return srcValue
|
|
45
|
+
}
|
|
46
|
+
if (!srcValue) {
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
return undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _getStateConfig(qForm) {
|
|
53
|
+
const { buttons = [], layout = {}, trees = [] } = qForm || {}
|
|
54
|
+
return {
|
|
55
|
+
buttons,
|
|
56
|
+
layout,
|
|
57
|
+
trees
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default {
|
|
62
|
+
ElementQForm
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
ElementQForm
|
|
67
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Element } from '../element'
|
|
2
|
+
import { ElementQGridConfig } from '../../configs'
|
|
3
|
+
|
|
4
|
+
class ElementQGrid extends Element {
|
|
5
|
+
constructor(opt = {}) {
|
|
6
|
+
super(opt)
|
|
7
|
+
this.defaultStateName = {
|
|
8
|
+
gridItems: 'gridItems',
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getConfig(helpers) {
|
|
13
|
+
let config = this.config || {}
|
|
14
|
+
if (this.state.qGrid) {
|
|
15
|
+
const stateConfig = this.state.qGrid
|
|
16
|
+
config = {
|
|
17
|
+
...stateConfig,
|
|
18
|
+
...config,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return typeof ElementQGridConfig === 'function' ? ElementQGridConfig.init({
|
|
22
|
+
...config,
|
|
23
|
+
helpers: {
|
|
24
|
+
...helpers,
|
|
25
|
+
element: this,
|
|
26
|
+
},
|
|
27
|
+
}) : {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
ElementQGrid,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ElementQGrid }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Element } from '../element'
|
|
2
|
+
import { ElementQListConfig } from '../../configs'
|
|
3
|
+
|
|
4
|
+
class ElementQList extends Element {
|
|
5
|
+
constructor(opt = {}) {
|
|
6
|
+
super(opt)
|
|
7
|
+
this.defaultStateName = {
|
|
8
|
+
qList: 'qList',
|
|
9
|
+
qSorterKeys: 'qSorterKeys',
|
|
10
|
+
rows: 'rows'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getConfig(helpers) {
|
|
15
|
+
let config = this.config || {}
|
|
16
|
+
if (this.state.qList) {
|
|
17
|
+
const stateConfig = _getStateConfig(this.state.qList)
|
|
18
|
+
config = {
|
|
19
|
+
...stateConfig,
|
|
20
|
+
...config
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return typeof ElementQListConfig === 'function' ? ElementQListConfig.init({
|
|
24
|
+
...config,
|
|
25
|
+
helpers: {
|
|
26
|
+
...helpers,
|
|
27
|
+
element: this
|
|
28
|
+
},
|
|
29
|
+
}) : {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _getStateConfig(qList) {
|
|
34
|
+
// const { actions = [], bulkAction = {}, headers = [] } = qList || {}
|
|
35
|
+
return {
|
|
36
|
+
...qList
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default {
|
|
41
|
+
ElementQList
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
ElementQList
|
|
46
|
+
}
|