@worksafevictoria/wcl7.5 1.17.0-beta.10 → 1.17.0-beta.11
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/package.json +1 -1
- package/src/components/SubComponents/FormInstance/models/base-form-element.js +4 -3
- package/src/components/SubComponents/FormInstance/services/form-render-parser.js +51 -16
- package/src/components/SubComponents/FormInstance/services/logic-parser.js +81 -9
- package/src/components/SubComponents/FormInstance/services/registry-factory.js +52 -50
- package/src/components/SubComponents/FormInstance/stories/mocks/checkboxesother.json +1 -10
- package/src/components/SubComponents/FormInstance/stories/mocks/emailconfirm.json +1 -10
- package/src/components/SubComponents/FormInstance/stories/mocks/jahd.json +1 -5
- package/src/components/SubComponents/FormInstance/stories/mocks/quad.json +1 -5
- package/src/components/SubComponents/FormInstance/stories/mocks/radiosother.json +1 -9
- package/src/components/SubComponents/FormInstance/stories/mocks/sameas.json +1 -5
- package/src/components/SubComponents/FormInstance/stories/mocks/selectother.json +1 -10
- package/src/components/SubComponents/FormInstance/stories/mocks/styles.json +1 -5
- package/src/components/SubComponents/FormInstance/stories/mocks/table-select.json +1 -15
- package/src/components/SubComponents/FormInstance/stories/mocks/token.json +1 -5
- package/src/components/SubComponents/FormInstance/stories/mocks/twig.json +1 -13
- package/src/components/SubComponents/FormInstance/stories/mocks/wizard.json +1 -13
- package/src/components/SubComponents/FormInstance/tests/form-test-utils.js +3 -0
- package/src/components/SubComponents/FormInstance/tests/form.test.js +2 -1
- package/src/components/SubComponents/FormInstance/tests/radiosother.test.js +12 -11
- package/src/components/SubComponents/FormInstance/tests/rule-disabled.test.js +13 -45
- package/src/components/SubComponents/FormInstance/tests/rule-enabled-value.test.js +8 -24
- package/src/components/SubComponents/FormInstance/tests/rule-hidden.test.js +13 -45
- package/src/components/SubComponents/FormInstance/tests/rule-required-value.test.js +15 -55
- package/src/components/SubComponents/FormInstance/tests/rule-visible.test.js +0 -413
- package/src/components/SubComponents/FormInstance/tests/sameas.test.js +9 -25
- package/src/components/SubComponents/FormInstance/tests/twig.test.js +7 -5
package/package.json
CHANGED
|
@@ -54,7 +54,7 @@ export class BaseFormElement {
|
|
|
54
54
|
getLabelPosition() {
|
|
55
55
|
return this.getPosition(
|
|
56
56
|
this.webformElement['#_title_display'] ??
|
|
57
|
-
this.webformElement['#title_display']
|
|
57
|
+
this.webformElement['#title_display'],
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -160,7 +160,7 @@ export class BaseFormElement {
|
|
|
160
160
|
label: getStyle(this.webformElement['#label_attributes']),
|
|
161
161
|
wrapper: getStyle(this.webformElement['#wrapper_attributes']),
|
|
162
162
|
element: getStyle(this.webformElement['#attributes']),
|
|
163
|
-
additional: this.getAdditionalStyles(this.getCustomClass())
|
|
163
|
+
additional: this.getAdditionalStyles(this.getCustomClass()),
|
|
164
164
|
}
|
|
165
165
|
const hasOverride = Object.values(style).some((attr) => !this.isEmpty(attr))
|
|
166
166
|
return hasOverride ? style : undefined
|
|
@@ -251,7 +251,8 @@ export class BaseFormElement {
|
|
|
251
251
|
if (this.isEmpty(this.webformElement['#states'])) {
|
|
252
252
|
return undefined
|
|
253
253
|
} else {
|
|
254
|
-
|
|
254
|
+
// NEW: Pass the current instance (`this`) to the parser.
|
|
255
|
+
return parseElementStates(this.webformElement, this)
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
|
|
@@ -3,6 +3,39 @@ import { converFormIOElementToJSON } from './convert-form-element'
|
|
|
3
3
|
import { updateConditionWithFormReferences } from './logic-linker'
|
|
4
4
|
import { RegisterFactory } from './registry-factory'
|
|
5
5
|
|
|
6
|
+
function extractWebformKeys(webformObject) {
|
|
7
|
+
const result = []
|
|
8
|
+
|
|
9
|
+
const isElement = (obj) => obj && typeof obj === 'object' && obj['#type']
|
|
10
|
+
|
|
11
|
+
const extract = (obj) => {
|
|
12
|
+
if (!obj || typeof obj !== 'object') return null
|
|
13
|
+
|
|
14
|
+
const type = obj['#type']
|
|
15
|
+
|
|
16
|
+
const key = obj['#webform_key'] || null
|
|
17
|
+
const node = key ? { key, children: [], type } : null
|
|
18
|
+
|
|
19
|
+
for (const [childKey, val] of Object.entries(obj)) {
|
|
20
|
+
if (childKey.startsWith('#')) continue
|
|
21
|
+
if (isElement(val)) {
|
|
22
|
+
const childNode = extract(val)
|
|
23
|
+
if (childNode && node) node.children.push(childNode)
|
|
24
|
+
else if (childNode) return childNode
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return node
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for (const [topKey, val] of Object.entries(webformObject)) {
|
|
32
|
+
if (typeof val === 'object' && val['#type']) {
|
|
33
|
+
const topNode = extract(val)
|
|
34
|
+
if (topNode) result.push(topNode)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result
|
|
38
|
+
}
|
|
6
39
|
export class FormRenderParser {
|
|
7
40
|
initialise(contentApiUrl, isPreview) {
|
|
8
41
|
this.formSettingsMeta = { contentApiUrl }
|
|
@@ -17,14 +50,16 @@ export class FormRenderParser {
|
|
|
17
50
|
const formlogicList = []
|
|
18
51
|
try {
|
|
19
52
|
webform = this.preProcessWebForm(webform)
|
|
53
|
+
const pathTree = extractWebformKeys(webform)
|
|
20
54
|
const formiodefinition = {
|
|
21
55
|
id: webform['#id'],
|
|
22
56
|
components: this.parseFormContainerComponents(
|
|
23
57
|
webform,
|
|
24
58
|
webFormElementTree,
|
|
25
59
|
null,
|
|
26
|
-
formlogicList
|
|
27
|
-
|
|
60
|
+
formlogicList,
|
|
61
|
+
pathTree,
|
|
62
|
+
),
|
|
28
63
|
}
|
|
29
64
|
|
|
30
65
|
options.breadcrumbSettings = { clickable: false }
|
|
@@ -35,14 +70,12 @@ export class FormRenderParser {
|
|
|
35
70
|
|
|
36
71
|
formiodefinition.display = this.getDisplay(webFormElementTree)
|
|
37
72
|
if (this.isPreview) {
|
|
38
|
-
console.log('drupal webform', webform)
|
|
39
|
-
console.log('formio definition', formiodefinition)
|
|
40
73
|
}
|
|
41
74
|
return {
|
|
42
75
|
definition: formiodefinition,
|
|
43
76
|
tree: webFormElementTree,
|
|
44
77
|
options,
|
|
45
|
-
css
|
|
78
|
+
css,
|
|
46
79
|
}
|
|
47
80
|
} catch (e) {
|
|
48
81
|
console.error(e)
|
|
@@ -54,7 +87,8 @@ export class FormRenderParser {
|
|
|
54
87
|
container,
|
|
55
88
|
webFormElementTree,
|
|
56
89
|
parent,
|
|
57
|
-
formlogicList
|
|
90
|
+
formlogicList,
|
|
91
|
+
tree,
|
|
58
92
|
) => {
|
|
59
93
|
return Object.keys(container)
|
|
60
94
|
.filter((i) => !i.startsWith('#'))
|
|
@@ -63,11 +97,12 @@ export class FormRenderParser {
|
|
|
63
97
|
return RegisterFactory.getFormIOElement(
|
|
64
98
|
webFormElement,
|
|
65
99
|
this.formSettingsMeta,
|
|
66
|
-
parent
|
|
100
|
+
parent,
|
|
101
|
+
tree,
|
|
67
102
|
)
|
|
68
103
|
})
|
|
69
104
|
.filter(
|
|
70
|
-
(formIOElement) => !!formIOElement && formIOElement.isRenderable()
|
|
105
|
+
(formIOElement) => !!formIOElement && formIOElement.isRenderable(),
|
|
71
106
|
)
|
|
72
107
|
.map((formIOElement) => {
|
|
73
108
|
// nested form logic
|
|
@@ -78,11 +113,11 @@ export class FormRenderParser {
|
|
|
78
113
|
subContainer,
|
|
79
114
|
webFormElementTree,
|
|
80
115
|
formIOElement,
|
|
81
|
-
formlogicList
|
|
82
|
-
|
|
116
|
+
formlogicList,
|
|
117
|
+
tree,
|
|
118
|
+
),
|
|
83
119
|
)
|
|
84
120
|
}
|
|
85
|
-
|
|
86
121
|
return formIOElement
|
|
87
122
|
})
|
|
88
123
|
.map((formIOElement) => {
|
|
@@ -90,7 +125,7 @@ export class FormRenderParser {
|
|
|
90
125
|
webFormElementTree[formIOElement.getKey()] = formIOElement
|
|
91
126
|
const formioElementJSON = converFormIOElementToJSON(
|
|
92
127
|
formIOElement,
|
|
93
|
-
formlogicList
|
|
128
|
+
formlogicList,
|
|
94
129
|
).json
|
|
95
130
|
formIOElement.setFormIOdefinitionForElement(formioElementJSON)
|
|
96
131
|
return formioElementJSON
|
|
@@ -103,7 +138,7 @@ export class FormRenderParser {
|
|
|
103
138
|
webform.actions = {
|
|
104
139
|
'#type': 'webform_actions',
|
|
105
140
|
'#webform_id': 'form--actions',
|
|
106
|
-
'#webform_key': 'actions'
|
|
141
|
+
'#webform_key': 'actions',
|
|
107
142
|
}
|
|
108
143
|
}
|
|
109
144
|
return webform
|
|
@@ -115,8 +150,8 @@ export class FormRenderParser {
|
|
|
115
150
|
updateConditionWithFormReferences(
|
|
116
151
|
logic,
|
|
117
152
|
sourceElement,
|
|
118
|
-
webFormElementTree
|
|
119
|
-
)
|
|
153
|
+
webFormElementTree,
|
|
154
|
+
),
|
|
120
155
|
)
|
|
121
156
|
})
|
|
122
157
|
}
|
|
@@ -146,7 +181,7 @@ export class FormRenderParser {
|
|
|
146
181
|
|
|
147
182
|
getDisplay(webFormElementTree) {
|
|
148
183
|
const pageKeys = Object.keys(webFormElementTree).filter((elementKey) =>
|
|
149
|
-
webFormElementTree[elementKey].isPageComponent()
|
|
184
|
+
webFormElementTree[elementKey].isPageComponent(),
|
|
150
185
|
)
|
|
151
186
|
if (pageKeys.length > 0) {
|
|
152
187
|
return 'wizard'
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isEmpty,
|
|
5
5
|
} from '../models/form-utils'
|
|
6
6
|
|
|
7
|
-
export function parseElementStates(webformElement) {
|
|
7
|
+
export function parseElementStates(webformElement, elementInstance) {
|
|
8
8
|
const states = webformElement['#states'] || {}
|
|
9
9
|
let logicList = []
|
|
10
10
|
Object.keys(states)
|
|
@@ -21,9 +21,13 @@ export function parseElementStates(webformElement) {
|
|
|
21
21
|
const state = states[sourceKey]
|
|
22
22
|
let conditonal = `result = (`
|
|
23
23
|
if (Array.isArray(state)) {
|
|
24
|
-
|
|
24
|
+
// Pass instance to ruleToString
|
|
25
|
+
state.forEach((rule) => {
|
|
26
|
+
return (conditonal += ruleToString(rule, elementInstance, conditonal))
|
|
27
|
+
})
|
|
25
28
|
} else {
|
|
26
|
-
|
|
29
|
+
// Pass instance to ruleToString
|
|
30
|
+
conditonal += ruleToString(state, elementInstance, conditonal)
|
|
27
31
|
}
|
|
28
32
|
conditonal += ')'
|
|
29
33
|
logic.trigger.javascript = conditonal
|
|
@@ -54,10 +58,14 @@ function getLogicBasedOnCondition(elementCondition) {
|
|
|
54
58
|
return null
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
function ruleToString(rule) {
|
|
61
|
+
function ruleToString(rule, elementInstance) {
|
|
58
62
|
if (typeof rule === 'object') {
|
|
59
63
|
const conditions = Object.keys(rule).reduce((items, ruleKey) => {
|
|
60
|
-
const condition = ruleItemToString(
|
|
64
|
+
const condition = ruleItemToString(
|
|
65
|
+
rule[ruleKey],
|
|
66
|
+
ruleKey,
|
|
67
|
+
elementInstance,
|
|
68
|
+
)
|
|
61
69
|
if (!isEmpty(condition)) {
|
|
62
70
|
items.push(condition)
|
|
63
71
|
}
|
|
@@ -74,7 +82,7 @@ function ruleToString(rule) {
|
|
|
74
82
|
return ''
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
function ruleItemToString(ruleItem, itemKey) {
|
|
85
|
+
function ruleItemToString(ruleItem, itemKey, elementInstance) {
|
|
78
86
|
// Regex 1: Matches standard selectors (name="foo"). Captures 'foo'.
|
|
79
87
|
const standardMatch = itemKey.match(/name="([^"]+)"/)
|
|
80
88
|
// Regex 2: Matches array selectors (name="foo[bar]"). Captures 'foo' and 'bar'.
|
|
@@ -98,7 +106,13 @@ function ruleItemToString(ruleItem, itemKey) {
|
|
|
98
106
|
const conditions = Object.keys(ruleItem)
|
|
99
107
|
.map((elementProp) =>
|
|
100
108
|
formComponentID
|
|
101
|
-
? getTrigger(
|
|
109
|
+
? getTrigger(
|
|
110
|
+
formComponentID,
|
|
111
|
+
ruleItem,
|
|
112
|
+
elementProp,
|
|
113
|
+
checkboxOptionKey,
|
|
114
|
+
elementInstance,
|
|
115
|
+
)
|
|
102
116
|
: null,
|
|
103
117
|
)
|
|
104
118
|
.filter((trigger) => !!trigger)
|
|
@@ -143,12 +157,29 @@ function createNewLogic(actionName, actionValue) {
|
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
159
|
|
|
146
|
-
function getTrigger(
|
|
160
|
+
function getTrigger(
|
|
161
|
+
formComponentID,
|
|
162
|
+
ruleItem,
|
|
163
|
+
prop,
|
|
164
|
+
checkboxOptionKey = null,
|
|
165
|
+
elementInstance,
|
|
166
|
+
) {
|
|
147
167
|
if (ruleItem.hasOwnProperty(prop)) {
|
|
148
168
|
const value = ruleItem[prop] ?? ''
|
|
149
169
|
|
|
150
170
|
let variable = `data.{${formComponentID}}`
|
|
151
|
-
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
if (elementInstance && Array.isArray(elementInstance.tree)) {
|
|
174
|
+
const path = findPathInTree(elementInstance.tree, formComponentID)
|
|
175
|
+
if (path && path.length > 0) {
|
|
176
|
+
variable = buildDataAccessor(path, 'data')
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
let variable = `data.{${formComponentID}}`
|
|
181
|
+
}
|
|
182
|
+
|
|
152
183
|
let valueDelimeter = typeof value === 'string' ? "'" : ''
|
|
153
184
|
let expression = `${valueDelimeter}${value}${valueDelimeter}`
|
|
154
185
|
|
|
@@ -203,3 +234,44 @@ function getTrigger(formComponentID, ruleItem, prop, checkboxOptionKey = null) {
|
|
|
203
234
|
}
|
|
204
235
|
return null
|
|
205
236
|
}
|
|
237
|
+
|
|
238
|
+
function findPathInTree(tree, targetKey) {
|
|
239
|
+
if (!Array.isArray(tree) || !targetKey) return null
|
|
240
|
+
|
|
241
|
+
function dfs(nodes, path) {
|
|
242
|
+
for (const node of nodes) {
|
|
243
|
+
if (!node) continue
|
|
244
|
+
const nodeKey = node.key
|
|
245
|
+
const newPath =
|
|
246
|
+
nodeKey && node.type !== 'webform_wizard_page'
|
|
247
|
+
? path.concat(nodeKey)
|
|
248
|
+
: path
|
|
249
|
+
if (nodeKey === targetKey) return newPath
|
|
250
|
+
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
251
|
+
const found = dfs(node.children, newPath)
|
|
252
|
+
if (found) return found
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return null
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return dfs(tree, [])
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function isIdentifier(key) {
|
|
262
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(String(key))
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function buildDataAccessor(pathArray, rootName = 'data') {
|
|
266
|
+
if (!Array.isArray(pathArray) || pathArray.length === 0) return rootName
|
|
267
|
+
const parts = []
|
|
268
|
+
for (const key of pathArray) {
|
|
269
|
+
if (isIdentifier(key)) {
|
|
270
|
+
parts.push('.' + key)
|
|
271
|
+
} else {
|
|
272
|
+
const escaped = String(key).replace(/'/g, "\\'")
|
|
273
|
+
parts.push(`['${escaped}']`)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return rootName + parts.join('')
|
|
277
|
+
}
|
|
@@ -44,197 +44,197 @@ import { UnknownFormElement } from '../models/overrides/unknown'
|
|
|
44
44
|
import { URLFormElement } from '../models/overrides/url'
|
|
45
45
|
|
|
46
46
|
export class RegisterFactory {
|
|
47
|
-
static getFormIOElement(webformElement, formSettingsMeta, parent) {
|
|
47
|
+
static getFormIOElement(webformElement, formSettingsMeta, parent, tree) {
|
|
48
48
|
const matchingElements = [
|
|
49
49
|
{
|
|
50
50
|
isApplicable: (webformElement, type) =>
|
|
51
51
|
type === 'textfield' &&
|
|
52
52
|
webformElement['#input_mask']?.includes(`'alias': 'currency`),
|
|
53
|
-
factory: CurrencyFormElement
|
|
53
|
+
factory: CurrencyFormElement,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
isApplicable: (webformElement, type) =>
|
|
57
57
|
type === 'email' ||
|
|
58
58
|
webformElement['#input_mask']?.includes(`'alias': 'email`),
|
|
59
|
-
factory: EmailFormElement
|
|
59
|
+
factory: EmailFormElement,
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
isApplicable: 'tel',
|
|
63
|
-
factory: PhoneNumberFormElement
|
|
63
|
+
factory: PhoneNumberFormElement,
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
isApplicable: 'select',
|
|
67
|
-
factory: SelectFormElement
|
|
67
|
+
factory: SelectFormElement,
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
isApplicable: [
|
|
71
71
|
'webform_select_other',
|
|
72
72
|
'webform_checkboxes_other',
|
|
73
|
-
'webform_radios_other'
|
|
73
|
+
'webform_radios_other',
|
|
74
74
|
],
|
|
75
|
-
factory: OptionsOtherFormElement
|
|
75
|
+
factory: OptionsOtherFormElement,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
isApplicable: 'radios',
|
|
79
|
-
factory: RadioFormElement
|
|
79
|
+
factory: RadioFormElement,
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
isApplicable: ['datelist'],
|
|
83
|
-
factory: DateListFormElement
|
|
83
|
+
factory: DateListFormElement,
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
isApplicable: ['date', 'datetime'],
|
|
87
|
-
factory: DateFormElement
|
|
87
|
+
factory: DateFormElement,
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
isApplicable: 'webform_time',
|
|
91
|
-
factory: TimeFormElement
|
|
91
|
+
factory: TimeFormElement,
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
isApplicable: 'number',
|
|
95
|
-
factory: NumberFormElement
|
|
95
|
+
factory: NumberFormElement,
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
isApplicable: 'range',
|
|
99
|
-
factory: RangeFormElement
|
|
99
|
+
factory: RangeFormElement,
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
isApplicable: 'webform_likert',
|
|
103
|
-
factory: LikertFormElement
|
|
103
|
+
factory: LikertFormElement,
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
isApplicable: 'tableselect',
|
|
107
|
-
factory: TableSelectFormElement
|
|
107
|
+
factory: TableSelectFormElement,
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
isApplicable: 'webform_multiple',
|
|
111
|
-
factory: MultipleFormElement
|
|
111
|
+
factory: MultipleFormElement,
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
isApplicable: 'webform_custom_composite',
|
|
115
|
-
factory: CustomCompositeFormElement
|
|
115
|
+
factory: CustomCompositeFormElement,
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
isApplicable: 'webform_signature',
|
|
119
|
-
factory: SignatureFormElement
|
|
119
|
+
factory: SignatureFormElement,
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
isApplicable: ['webform_message'],
|
|
123
|
-
factory: MessageFormElement
|
|
123
|
+
factory: MessageFormElement,
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
isApplicable: [
|
|
127
127
|
'webform_markup',
|
|
128
128
|
'processed_text',
|
|
129
129
|
'webform_horizontal_rule',
|
|
130
|
-
'label'
|
|
130
|
+
'label',
|
|
131
131
|
],
|
|
132
|
-
factory: MarkupFormElement
|
|
132
|
+
factory: MarkupFormElement,
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
isApplicable: ['managed_file'],
|
|
136
|
-
factory: FileFormElement
|
|
136
|
+
factory: FileFormElement,
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
139
|
isApplicable: ['textformat'],
|
|
140
|
-
factory: TextFormatFormElement
|
|
140
|
+
factory: TextFormatFormElement,
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
isApplicable: 'url',
|
|
144
|
-
factory: URLFormElement
|
|
144
|
+
factory: URLFormElement,
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
isApplicable: ['checkbox', 'webform_same'],
|
|
148
|
-
factory: CheckboxFormElement
|
|
148
|
+
factory: CheckboxFormElement,
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
isApplicable: ['checkboxes'],
|
|
152
|
-
factory: CheckboxesFormElement
|
|
152
|
+
factory: CheckboxesFormElement,
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
isApplicable: 'webform_autocomplete',
|
|
156
|
-
factory: AutoCompleteFormElement
|
|
156
|
+
factory: AutoCompleteFormElement,
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
159
|
isApplicable: 'webform_more',
|
|
160
|
-
factory: MoreTextFormElement
|
|
160
|
+
factory: MoreTextFormElement,
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
isApplicable: ['hidden'],
|
|
164
|
-
factory: HiddenFormElement
|
|
164
|
+
factory: HiddenFormElement,
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
isApplicable: 'webform_address',
|
|
168
|
-
factory: AddresseFormElement
|
|
168
|
+
factory: AddresseFormElement,
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
isApplicable: ['textfield'],
|
|
172
|
-
factory: TextFormElement
|
|
172
|
+
factory: TextFormElement,
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
isApplicable: ['value', 'textarea'],
|
|
176
|
-
factory: TextAreaFormElement
|
|
176
|
+
factory: TextAreaFormElement,
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
isApplicable: 'webform_rating',
|
|
180
|
-
factory: RatingFormElement
|
|
180
|
+
factory: RatingFormElement,
|
|
181
181
|
},
|
|
182
182
|
// Matt testing
|
|
183
183
|
{
|
|
184
184
|
isApplicable: 'webform_testing',
|
|
185
|
-
factory: TestingFormElement
|
|
185
|
+
factory: TestingFormElement,
|
|
186
186
|
},
|
|
187
187
|
|
|
188
188
|
// end Matt testing
|
|
189
189
|
{
|
|
190
190
|
isApplicable: 'webform_scale',
|
|
191
|
-
factory: ScaleFormElement
|
|
191
|
+
factory: ScaleFormElement,
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
isApplicable: 'webform_actions',
|
|
195
|
-
factory: SubmitFormElement
|
|
195
|
+
factory: SubmitFormElement,
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
198
|
isApplicable: (webformElement) =>
|
|
199
199
|
webformElement['#webform_plugin_id'] === 'webform_wizard_page',
|
|
200
|
-
factory: PageFormElement
|
|
200
|
+
factory: PageFormElement,
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
isApplicable: 'details',
|
|
204
|
-
factory: DetailFormElement
|
|
204
|
+
factory: DetailFormElement,
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
207
|
isApplicable: 'container',
|
|
208
|
-
factory: ContainerFormElement
|
|
208
|
+
factory: ContainerFormElement,
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
211
|
isApplicable: 'webform_table',
|
|
212
|
-
factory: TableFormElement
|
|
212
|
+
factory: TableFormElement,
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
215
|
isApplicable: 'webform_table_row',
|
|
216
|
-
factory: TableRowFormElement
|
|
216
|
+
factory: TableRowFormElement,
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
isApplicable: 'item',
|
|
220
|
-
factory: TwigFormElement
|
|
220
|
+
factory: TwigFormElement,
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
isApplicable: ['fieldset', 'webform_section'],
|
|
224
|
-
factory: SectionFormElement
|
|
224
|
+
factory: SectionFormElement,
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
isApplicable: 'webform_flexbox',
|
|
228
|
-
factory: FlexboxFormElement
|
|
228
|
+
factory: FlexboxFormElement,
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
isApplicable: 'webform_email_confirm',
|
|
232
|
-
factory: EmailConfirmFormElement
|
|
232
|
+
factory: EmailConfirmFormElement,
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
isApplicable: 'webform_codemirror',
|
|
236
|
-
factory: CodeFormElement
|
|
237
|
-
}
|
|
236
|
+
factory: CodeFormElement,
|
|
237
|
+
},
|
|
238
238
|
]
|
|
239
239
|
|
|
240
240
|
const matchingElement = matchingElements.find((item) => {
|
|
@@ -252,7 +252,7 @@ export class RegisterFactory {
|
|
|
252
252
|
const ElementFactory = matchingElement?.factory
|
|
253
253
|
const moreElement = RegisterFactory.getMoreTextInstance(
|
|
254
254
|
webformElement,
|
|
255
|
-
parent
|
|
255
|
+
parent,
|
|
256
256
|
)
|
|
257
257
|
const elementInstance = matchingElement
|
|
258
258
|
? new ElementFactory(webformElement, parent, moreElement)
|
|
@@ -263,6 +263,8 @@ export class RegisterFactory {
|
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
elementInstance.setFormSettingsMeta(formSettingsMeta)
|
|
266
|
+
// Set the tree for logic parsing
|
|
267
|
+
elementInstance.tree = tree
|
|
266
268
|
return elementInstance
|
|
267
269
|
}
|
|
268
270
|
|
|
@@ -274,9 +276,9 @@ export class RegisterFactory {
|
|
|
274
276
|
...webFormElement,
|
|
275
277
|
'#type': 'webform_more',
|
|
276
278
|
'#webform_id': 'webform_more' + webFormElement['#webform_id'],
|
|
277
|
-
'#webform_key': 'webform_more' + webFormElement['#webform_key']
|
|
279
|
+
'#webform_key': 'webform_more' + webFormElement['#webform_key'],
|
|
278
280
|
},
|
|
279
|
-
parent
|
|
281
|
+
parent,
|
|
280
282
|
)
|
|
281
283
|
}
|
|
282
284
|
return moreElement
|
|
@@ -184,14 +184,5 @@
|
|
|
184
184
|
"#ajax_processed": false,
|
|
185
185
|
"#sorted": true,
|
|
186
186
|
"#after_build_done": true
|
|
187
|
-
}
|
|
188
|
-
"#tree": false,
|
|
189
|
-
"#weight": 0.001,
|
|
190
|
-
"#processed": false,
|
|
191
|
-
"#required": false,
|
|
192
|
-
"#title_display": "before",
|
|
193
|
-
"#description_display": "after",
|
|
194
|
-
"#errors": null,
|
|
195
|
-
"#id": "edit-elements",
|
|
196
|
-
"#sorted": true
|
|
187
|
+
}
|
|
197
188
|
}
|
|
@@ -97,14 +97,5 @@
|
|
|
97
97
|
},
|
|
98
98
|
"#sorted": true,
|
|
99
99
|
"#after_build_done": true
|
|
100
|
-
}
|
|
101
|
-
"#tree": false,
|
|
102
|
-
"#weight": 0.001,
|
|
103
|
-
"#processed": false,
|
|
104
|
-
"#required": false,
|
|
105
|
-
"#title_display": "before",
|
|
106
|
-
"#description_display": "after",
|
|
107
|
-
"#errors": null,
|
|
108
|
-
"#id": "edit-elements",
|
|
109
|
-
"#sorted": true
|
|
100
|
+
}
|
|
110
101
|
}
|
|
@@ -1351,9 +1351,5 @@
|
|
|
1351
1351
|
"#title_display": "before",
|
|
1352
1352
|
"#description_display": "after",
|
|
1353
1353
|
"#id": "edit-enter-details"
|
|
1354
|
-
}
|
|
1355
|
-
"#required": false,
|
|
1356
|
-
"#title_display": "before",
|
|
1357
|
-
"#description_display": "after",
|
|
1358
|
-
"#id": "kitchen_sink_formio_v1"
|
|
1354
|
+
}
|
|
1359
1355
|
}
|
|
@@ -164,13 +164,5 @@
|
|
|
164
164
|
"#ajax_processed": false,
|
|
165
165
|
"#sorted": true,
|
|
166
166
|
"#after_build_done": true
|
|
167
|
-
}
|
|
168
|
-
"#tree": false,
|
|
169
|
-
"#processed": false,
|
|
170
|
-
"#required": false,
|
|
171
|
-
"#title_display": "before",
|
|
172
|
-
"#description_display": "after",
|
|
173
|
-
"#errors": null,
|
|
174
|
-
"#id": "edit-elements",
|
|
175
|
-
"#sorted": true
|
|
167
|
+
}
|
|
176
168
|
}
|