@worksafevictoria/wcl7.5 1.5.0 → 1.7.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/.storybook/preview.js +20 -13
- package/bin/deploy.sh +1 -1
- package/lib/utility.js +10 -8
- package/package.json +6 -5
- package/src/assets/icons/AppFooter/x-ws-footer.svg +10 -0
- package/src/assets/icons/AppFooter/x-ww-footer.svg +28 -0
- package/src/assets/icons/SocialShare/x-icon-white.svg +28 -0
- package/src/assets/styles/modal.scss +51 -0
- package/src/components/Common/CardGrid/index.vue +56 -51
- package/src/components/Common/CardGridItem/card-grid-item-caret.vue +7 -4
- package/src/components/Common/CardGridItem/card-grid-item-icon.vue +15 -19
- package/src/components/Common/CardGridItem/index.vue +77 -63
- package/src/components/Containers/Carousel/index.vue +14 -7
- package/src/components/Containers/HomepageHeader/index.stories.js +60 -36
- package/src/components/Containers/HomepageHeader/index.vue +2 -26
- package/src/components/Containers/HomepageHeaderNew/index.stories.js +15 -15
- package/src/components/Containers/HomepageHeaderNew/index.vue +97 -68
- package/src/components/Containers/SectionGroup/index.vue +1 -1
- package/src/components/Containers/Subheader/index.vue +5 -1
- package/src/components/Global/AppFooter/FooterSocialShare/index.vue +1 -1
- package/src/components/Global/AppFooter/index.vue +14 -7
- package/src/components/Global/AppFooter/styles.scss +3 -0
- package/src/components/Global/AppHeaderNew/styles.scss +10 -15
- package/src/components/Global/BackToTop/index.vue +8 -8
- package/src/components/Global/Cookies/index.stories.js +16 -10
- package/src/components/Global/Cookies/index.vue +280 -243
- package/src/components/Global/Cookies/styles.scss +54 -54
- package/src/components/Global/DirectoryFilters/SingleTaxonomy/index.vue +50 -133
- package/src/components/Global/DirectoryFilters/index.vue +3 -0
- package/src/components/Global/GlobalNotice/index.vue +79 -100
- package/src/components/Global/SocialShare/index.vue +1 -1
- package/src/components/Global/Strip/index.vue +1 -1
- package/src/components/Paragraphs/Accordion/AccordionItem/index.vue +8 -4
- package/src/components/Paragraphs/Accordion/StepperItem/index.vue +23 -23
- package/src/components/Paragraphs/Accordion/index.stories.js +21 -18
- package/src/components/Paragraphs/Accordion/index.vue +52 -48
- package/src/components/Paragraphs/BrowseContent/index.vue +1 -1
- package/src/components/Paragraphs/BrowseContent/setup.vue +284 -0
- package/src/components/Paragraphs/Chart/Constants.js +952 -952
- package/src/components/Paragraphs/Chart/index.vue +232 -241
- package/src/components/Paragraphs/Directory/HSCP/Records/SingleRecord/index.stories.js +34 -0
- package/src/components/Paragraphs/Directory/HSCP/Records/SingleRecord/index.vue +321 -0
- package/src/components/Paragraphs/Directory/HSCP/Records/index.stories.js +19 -0
- package/src/components/Paragraphs/Directory/HSCP/Records/index.vue +345 -0
- package/src/components/Paragraphs/Directory/HSCP/Records/pagination.vue +179 -0
- package/src/components/Paragraphs/Directory/Records/CJ/index.vue +1 -1
- package/src/components/Paragraphs/Directory/Records/ISP/index.vue +1 -1
- package/src/components/Paragraphs/Directory/Records/PRS/index.stories.js +34 -0
- package/src/components/Paragraphs/Directory/Records/PRS/index.vue +5 -1
- package/src/components/Paragraphs/Directory/Records/index.storieshide.js +47 -0
- package/src/components/Paragraphs/Directory/Records/index.vue +52 -33
- package/src/components/Paragraphs/Directory/constants.js +23 -5
- package/src/components/Paragraphs/Directory/index.vue +14 -14
- package/src/components/Paragraphs/Directory/{Records/styles.scss → styles.scss} +5 -3
- package/src/components/Paragraphs/ListGroup/index.vue +5 -1
- package/src/components/Paragraphs/Map/Constants.js +4790 -0
- package/src/components/Paragraphs/Map/index.mdx +29 -0
- package/src/components/Paragraphs/Map/index.stories.js +15 -0
- package/src/components/Paragraphs/Map/index.vue +295 -0
- package/src/components/Paragraphs/Map/postcode_location.json +3543 -0
- package/src/components/Paragraphs/ScrollSpy/index.vue +23 -14
- package/src/components/Paragraphs/SelectableCards/index.vue +15 -12
- package/src/components/Paragraphs/TabbedCards/index.vue +13 -14
- package/src/components/Paragraphs/Tabs/index.vue +19 -17
- package/src/components/Paragraphs/TextMedia/MediaTypes/Video/index.vue +9 -9
- package/src/components/Paragraphs/TextMedia/index.vue +20 -16
- package/src/components/Paragraphs/VideoGrid/index.stories.js +43 -19
- package/src/components/Paragraphs/VideoGrid/index.vue +13 -13
- package/src/components/Paragraphs/Webform/index.stories.js +82 -69
- package/src/components/SubComponents/Breadcrumb/index.vue +4 -0
- package/src/components/SubComponents/CardGroup/index.vue +5 -1
- package/src/components/SubComponents/FormAddressPostcode/index.vue +35 -37
- package/src/components/SubComponents/FormInstance/components/handler/index.vue +25 -29
- package/src/components/SubComponents/FormInstance/components/renderer/index.vue +81 -30
- package/src/components/SubComponents/FormInstance/models/overrides/file.js +38 -40
- package/src/components/SubComponents/FormInstance/services/form-submit-parser.js +22 -15
- package/src/components/SubComponents/FormInstance/services/registry-factory.js +1 -1
- package/src/components/SubComponents/FormInstance/stories/fileupload.stories.js +57 -0
- package/src/components/SubComponents/FormInstance/stories/mocks/fileupload.json +25 -0
- package/src/components/SubComponents/FormInstance/style.scss +2 -2
- package/src/components/SubComponents/FormInstance/tests/address.test.js +4 -4
- package/src/components/SubComponents/FormInstance/tests/checkboxes.test.js +7 -7
- package/src/components/SubComponents/FormInstance/tests/customcomposite.test.js +15 -15
- package/src/components/SubComponents/FormInstance/tests/date.test.js +8 -8
- package/src/components/SubComponents/FormInstance/tests/form-test-utils.js +9 -9
- package/src/components/SubComponents/FormInstance/tests/multiple.test.js +13 -13
- package/src/components/SubComponents/FormInstance/tests/rule-visible.test.js +120 -120
- package/src/components/SubComponents/FormInstance/tests/scale.test.js +6 -6
- package/src/components/SubComponents/FormInstance/tests/url.test.js +13 -10
- package/src/components/SubComponents/Pagination/index.vue +19 -18
- package/src/components/SubComponents/ResourceGroup/index.vue +5 -1
- package/src/components/SubComponents/Search/SearchListing/index.vue +20 -20
- package/src/components/SubComponents/Search/index.vue +42 -35
- package/src/components/SubComponents/VideoThumbnail/index.vue +48 -133
- package/src/includes/scss/vars/src/colors.module.scss +28 -1
- package/src/index.js +25 -3
- package/src/main.js +2 -10
- package/src/mock/carousel-items.js +71 -46
- package/src/mock/course-provider.js +273 -0
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
@nextPage="next($event)"
|
|
13
13
|
@prevPage="prev($event)"
|
|
14
14
|
></formio>
|
|
15
|
+
<BModal centered v-model="modal" title="File Error" ok-only>
|
|
16
|
+
{{ fileMessage }}</BModal
|
|
17
|
+
>
|
|
15
18
|
</div>
|
|
16
19
|
</template>
|
|
17
20
|
|
|
18
21
|
<script>
|
|
19
|
-
|
|
22
|
+
import { BModal } from 'bootstrap-vue-next'
|
|
20
23
|
import { Form, Formio } from '@formio/vue'
|
|
21
24
|
import '@fortawesome/fontawesome-free/css/all.min.css'
|
|
22
25
|
import '@fortawesome/fontawesome-free/css/v4-shims.min.css'
|
|
@@ -24,29 +27,31 @@ import 'formiojs/dist/formio.builder.min.css'
|
|
|
24
27
|
|
|
25
28
|
export default {
|
|
26
29
|
name: 'FormRenderer',
|
|
27
|
-
components: { formio: Form },
|
|
30
|
+
components: { formio: Form, BModal },
|
|
28
31
|
props: {
|
|
29
32
|
formiodefinition: {
|
|
30
33
|
type: Object,
|
|
31
|
-
required: true
|
|
34
|
+
required: true,
|
|
32
35
|
},
|
|
33
36
|
options: {
|
|
34
37
|
type: Object,
|
|
35
|
-
required: true
|
|
38
|
+
required: true,
|
|
36
39
|
},
|
|
37
40
|
overrideCSS: {
|
|
38
41
|
type: String,
|
|
39
42
|
required: true,
|
|
40
|
-
default: ''
|
|
43
|
+
default: '',
|
|
41
44
|
},
|
|
42
|
-
processID: { type: String, required: true }
|
|
45
|
+
processID: { type: String, required: true },
|
|
43
46
|
},
|
|
44
47
|
data() {
|
|
45
48
|
return {
|
|
46
49
|
debouncedChanges: this.debounce(this.changed, 250),
|
|
47
50
|
debouncedSubmission: this.debounce(this.submit, 250),
|
|
48
51
|
firstEl: null,
|
|
49
|
-
started: false
|
|
52
|
+
started: false,
|
|
53
|
+
modal: false,
|
|
54
|
+
fileMessage: '',
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
mounted() {
|
|
@@ -55,7 +60,7 @@ export default {
|
|
|
55
60
|
this.$el.appendChild(styleTag)
|
|
56
61
|
|
|
57
62
|
const tooltips = document.getElementsByClassName(
|
|
58
|
-
'fa fa-question-circle text-muted'
|
|
63
|
+
'fa fa-question-circle text-muted',
|
|
59
64
|
)
|
|
60
65
|
if (tooltips.length) {
|
|
61
66
|
;[...tooltips].forEach((tt) => {
|
|
@@ -66,11 +71,11 @@ export default {
|
|
|
66
71
|
category: 'form help',
|
|
67
72
|
data: e.target.parentElement.innerText,
|
|
68
73
|
label: 'tooltip',
|
|
69
|
-
processId: this.processID
|
|
74
|
+
processId: this.processID,
|
|
70
75
|
}
|
|
71
76
|
this.$gtm.push({
|
|
72
77
|
event: 'custom.form.interaction.tooltip.show',
|
|
73
|
-
...attrs
|
|
78
|
+
...attrs,
|
|
74
79
|
})
|
|
75
80
|
}
|
|
76
81
|
})
|
|
@@ -91,17 +96,63 @@ export default {
|
|
|
91
96
|
let attrs = {
|
|
92
97
|
group: document.title,
|
|
93
98
|
label: ev.component.key,
|
|
94
|
-
data: ev._data[ev.component.key]
|
|
99
|
+
data: ev._data[ev.component.key],
|
|
95
100
|
}
|
|
96
101
|
if (this.$gtm) {
|
|
97
102
|
this.$gtm.push({
|
|
98
103
|
event: 'custom.form.progress.field.complete',
|
|
99
|
-
...attrs
|
|
104
|
+
...attrs,
|
|
100
105
|
})
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
},
|
|
104
|
-
changed(_e, event) {
|
|
109
|
+
async changed(_e, event) {
|
|
110
|
+
// File upload validation
|
|
111
|
+
if (event.changed?.component.type === 'file') {
|
|
112
|
+
const maxFiles = event.changed.component.fileMaxCount || 1
|
|
113
|
+
const convertToBytes = (size) => {
|
|
114
|
+
const units = {
|
|
115
|
+
KB: 1024,
|
|
116
|
+
MB: 1024 * 1024,
|
|
117
|
+
GB: 1024 * 1024 * 1024,
|
|
118
|
+
}
|
|
119
|
+
const match = size.match(/^(\d+(?:\.\d+)?)\s*(KB|MB|GB)$/i)
|
|
120
|
+
if (!match) {
|
|
121
|
+
throw new Error("Invalid size format. Use 'KB', 'MB', or 'GB'.")
|
|
122
|
+
}
|
|
123
|
+
const value = parseFloat(match[1])
|
|
124
|
+
const unit = match[2].toUpperCase()
|
|
125
|
+
return value * units[unit]
|
|
126
|
+
}
|
|
127
|
+
const maxTotalSize = event.changed.component.fileMaxSize
|
|
128
|
+
const maxTotalBytes = convertToBytes(maxTotalSize)
|
|
129
|
+
const files = event.changed.instance.dataValue || []
|
|
130
|
+
if (files.length > maxFiles) {
|
|
131
|
+
event.changed.instance.dataValue = files.slice(0, maxFiles)
|
|
132
|
+
this.fileMessage = `You have exceeded the maximum number of files allowed. Only the first ${maxFiles} files have been uploaded.`
|
|
133
|
+
this.modal = true
|
|
134
|
+
|
|
135
|
+
event.changed.instance.triggerChange()
|
|
136
|
+
event.changed.instance.triggerRedraw()
|
|
137
|
+
}
|
|
138
|
+
let totalSize = files.reduce((sum, file) => sum + (file.size || 0), 0)
|
|
139
|
+
if (totalSize > maxTotalBytes) {
|
|
140
|
+
let limit = []
|
|
141
|
+
while (totalSize > maxTotalBytes) {
|
|
142
|
+
const file = files.pop()
|
|
143
|
+
limit.push(file.name)
|
|
144
|
+
totalSize -= file.size
|
|
145
|
+
}
|
|
146
|
+
event.changed.instance.dataValue = files //.slice(0, files.length - 1)
|
|
147
|
+
this.fileMessage = `You have exceeded the maximum total file size allowed. Only ${files.length} files have been uploaded.`
|
|
148
|
+
this.modal = true
|
|
149
|
+
console.log('🚀 ~ changed ~ limit.length:', limit.length)
|
|
150
|
+
event.changed.instance.triggerChange()
|
|
151
|
+
event.changed.instance.triggerRedraw()
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
105
156
|
if (
|
|
106
157
|
this.$gtm &&
|
|
107
158
|
!this.started &&
|
|
@@ -115,7 +166,7 @@ export default {
|
|
|
115
166
|
category: '',
|
|
116
167
|
label: 'Start',
|
|
117
168
|
targetElement: this.firstEl,
|
|
118
|
-
processId: this.processID
|
|
169
|
+
processId: this.processID,
|
|
119
170
|
}
|
|
120
171
|
this.$gtm.push({ event: 'custom.form.progress.start', ...attrs })
|
|
121
172
|
}
|
|
@@ -133,11 +184,11 @@ export default {
|
|
|
133
184
|
let attrs = {
|
|
134
185
|
group: document.title,
|
|
135
186
|
label: event.changed.component.key,
|
|
136
|
-
data: event.changed.value
|
|
187
|
+
data: event.changed.value,
|
|
137
188
|
}
|
|
138
189
|
this.$gtm.push({
|
|
139
190
|
event: 'custom.form.progress.field.complete',
|
|
140
|
-
...attrs
|
|
191
|
+
...attrs,
|
|
141
192
|
})
|
|
142
193
|
}
|
|
143
194
|
}
|
|
@@ -145,22 +196,22 @@ export default {
|
|
|
145
196
|
if (event?.changed?.component) {
|
|
146
197
|
this.$emit('changed', {
|
|
147
198
|
...event.changed,
|
|
148
|
-
key: event.changed.component.key
|
|
199
|
+
key: event.changed.component.key,
|
|
149
200
|
})
|
|
150
201
|
}
|
|
151
202
|
},
|
|
152
203
|
submit(submission) {
|
|
153
204
|
this.$emit('submitted', {
|
|
154
205
|
submission,
|
|
155
|
-
formioinstance: Object.values(Formio.forms)[0]
|
|
206
|
+
formioinstance: Object.values(Formio.forms)[0],
|
|
156
207
|
})
|
|
157
208
|
},
|
|
158
209
|
debounce(func, wait, immediate) {
|
|
159
210
|
let timeout
|
|
160
|
-
return function() {
|
|
211
|
+
return function () {
|
|
161
212
|
const context = this,
|
|
162
213
|
args = arguments
|
|
163
|
-
const later = function() {
|
|
214
|
+
const later = function () {
|
|
164
215
|
timeout = null
|
|
165
216
|
if (!immediate) func.apply(context, args)
|
|
166
217
|
}
|
|
@@ -180,9 +231,9 @@ export default {
|
|
|
180
231
|
step: {
|
|
181
232
|
label: this.formiodefinition.components[ev.page - 1].title,
|
|
182
233
|
stepNumber: ev.page + 1,
|
|
183
|
-
subStepNumber: undefined
|
|
234
|
+
subStepNumber: undefined,
|
|
184
235
|
},
|
|
185
|
-
processId: this.processID
|
|
236
|
+
processId: this.processID,
|
|
186
237
|
}
|
|
187
238
|
this.$gtm.push({ event: 'custom.form.progress.step', ...attrs })
|
|
188
239
|
}
|
|
@@ -195,9 +246,9 @@ export default {
|
|
|
195
246
|
step: {
|
|
196
247
|
label: this.formiodefinition.components[ev.page + 1].title,
|
|
197
248
|
stepNumber: ev.page + 1,
|
|
198
|
-
subStepNumber: undefined
|
|
249
|
+
subStepNumber: undefined,
|
|
199
250
|
},
|
|
200
|
-
processId: this.processID
|
|
251
|
+
processId: this.processID,
|
|
201
252
|
}
|
|
202
253
|
this.$gtm.push({ event: 'custom.form.progress.step', ...attrs })
|
|
203
254
|
}
|
|
@@ -211,10 +262,10 @@ export default {
|
|
|
211
262
|
{
|
|
212
263
|
errorId: '',
|
|
213
264
|
errorDetail: ev.messages[0].key,
|
|
214
|
-
errorMessage: ev.messages[0].message
|
|
215
|
-
}
|
|
216
|
-
]
|
|
217
|
-
}
|
|
265
|
+
errorMessage: ev.messages[0].message,
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
},
|
|
218
269
|
}
|
|
219
270
|
if (ev.messages[0].context?.validator === 'required') {
|
|
220
271
|
attrs.event = 'custom.form.error.required'
|
|
@@ -230,8 +281,8 @@ export default {
|
|
|
230
281
|
if (this.$gtm) {
|
|
231
282
|
this.$gtm.push({ event: attrs.event, ...attrs.data })
|
|
232
283
|
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
284
|
+
},
|
|
285
|
+
},
|
|
235
286
|
}
|
|
236
287
|
</script>
|
|
237
288
|
<style lang="scss">
|
|
@@ -5,52 +5,50 @@ export class FileFormElement extends BaseFormElement {
|
|
|
5
5
|
return 'file'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
// .reduce(() => '')
|
|
38
|
-
// return data
|
|
39
|
-
// }
|
|
8
|
+
async transformSubmissionValue(value, axios) {
|
|
9
|
+
const promises = await Promise.all(
|
|
10
|
+
value.map((file) => {
|
|
11
|
+
const base64Data = file.url.split(',')[1]
|
|
12
|
+
//const buffer = Buffer.from(base64Data, 'base64')
|
|
13
|
+
const binaryData = atob(base64Data)
|
|
14
|
+
const byteArray = new Uint8Array(binaryData.length)
|
|
15
|
+
for (let i = 0; i < binaryData.length; i++) {
|
|
16
|
+
byteArray[i] = binaryData.charCodeAt(i)
|
|
17
|
+
}
|
|
18
|
+
const blob = new Blob([byteArray], { type: 'text/plain' })
|
|
19
|
+
|
|
20
|
+
return axios.post(
|
|
21
|
+
`https://content-dev-v2.api.worksafe.vic.gov.au/webform_rest/${this.webformElement['#webform']}/upload/${this.webformElement['#webform_key']}`,
|
|
22
|
+
blob,
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/octet-stream',
|
|
26
|
+
'Content-Disposition': `file;filename="${file.name}"`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
return promises.map((data) => data.data.fid[0].value)
|
|
33
|
+
}
|
|
40
34
|
|
|
41
35
|
getCustomProperties() {
|
|
42
36
|
return {
|
|
43
37
|
storage: 'base64',
|
|
38
|
+
required: true,
|
|
44
39
|
webcam: false,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
multiple: true,
|
|
41
|
+
description: `No more than ${this.webformElement['#multiple']} files accepted. Maximum total size is ${this.webformElement['#max_filesize']}MB.`,
|
|
42
|
+
filePattern: this.webformElement['#file_extensions']
|
|
43
|
+
? this.webformElement['#file_extensions']
|
|
44
|
+
.split(' ')
|
|
45
|
+
.map((ext) => `.${ext}`)
|
|
46
|
+
.join(',')
|
|
47
|
+
: '',
|
|
48
|
+
|
|
52
49
|
fileKey: `files[${this.webformElement['#name']}]`,
|
|
53
|
-
|
|
50
|
+
fileMaxSize: `${this.webformElement['#max_filesize']}MB`,
|
|
51
|
+
fileMaxCount: this.webformElement['#multiple'],
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
}
|
|
@@ -4,11 +4,16 @@ export class FormSubmitParser {
|
|
|
4
4
|
this.axios = axios
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
parse = (submission, form, formioinstance) => {
|
|
7
|
+
parse = async (submission, form, formioinstance) => {
|
|
8
8
|
try {
|
|
9
|
+
let parseData = await this.parseFormInstance(
|
|
10
|
+
submission.data,
|
|
11
|
+
form,
|
|
12
|
+
formioinstance,
|
|
13
|
+
)
|
|
9
14
|
return {
|
|
10
15
|
webform_id: this.formId,
|
|
11
|
-
...
|
|
16
|
+
...parseData,
|
|
12
17
|
}
|
|
13
18
|
} catch (e) {
|
|
14
19
|
console.error(e)
|
|
@@ -16,45 +21,47 @@ export class FormSubmitParser {
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
parseFormInstance = (formSubmissionMap, form, formioinstance) => {
|
|
24
|
+
parseFormInstance = async (formSubmissionMap, form, formioinstance) => {
|
|
20
25
|
return Object.keys(formSubmissionMap)
|
|
21
26
|
.filter((key) => key !== 'actions')
|
|
22
27
|
.filter((key) => !!form.tree[key])
|
|
23
|
-
.reduce((previous, key) => {
|
|
28
|
+
.reduce(async (previous, key) => {
|
|
24
29
|
const formTreeElement = form.tree[key]
|
|
25
30
|
const value = formSubmissionMap[key]
|
|
26
31
|
const component = formioinstance.components.find(
|
|
27
|
-
(component) => component.originalComponent?.key === key
|
|
32
|
+
(component) => component.originalComponent?.key === key,
|
|
28
33
|
)
|
|
29
34
|
const isDisabled = component?.disabled
|
|
30
35
|
const ignore =
|
|
31
36
|
isDisabled || formTreeElement.shouldIgnoreSubmissionValue()
|
|
32
37
|
if (formTreeElement.isLayoutComponent() && ignore) {
|
|
33
|
-
const containerSubmissions = this.parseFormInstance(
|
|
38
|
+
const containerSubmissions = await this.parseFormInstance(
|
|
34
39
|
value,
|
|
35
40
|
form,
|
|
36
|
-
formioinstance
|
|
41
|
+
formioinstance,
|
|
37
42
|
)
|
|
38
43
|
previous = {
|
|
39
|
-
...previous,
|
|
40
|
-
...containerSubmissions
|
|
44
|
+
...(await previous),
|
|
45
|
+
...containerSubmissions,
|
|
41
46
|
}
|
|
42
47
|
} else if (!ignore) {
|
|
43
|
-
const returnValue = formTreeElement.transformSubmissionValue(
|
|
48
|
+
const returnValue = await formTreeElement.transformSubmissionValue(
|
|
44
49
|
value,
|
|
45
50
|
this.axios,
|
|
46
|
-
previous
|
|
51
|
+
await previous,
|
|
47
52
|
)
|
|
48
53
|
if (typeof returnValue === 'object' && !Array.isArray(returnValue)) {
|
|
49
54
|
previous = {
|
|
50
|
-
...previous,
|
|
51
|
-
...returnValue
|
|
55
|
+
...(await previous),
|
|
56
|
+
...returnValue,
|
|
52
57
|
}
|
|
53
58
|
} else {
|
|
54
|
-
previous
|
|
59
|
+
previous = {
|
|
60
|
+
...(await previous),
|
|
61
|
+
[key]: returnValue,
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
|
|
58
65
|
return previous
|
|
59
66
|
}, {})
|
|
60
67
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import FormInstance from '../index.vue'
|
|
2
|
+
import fileupload from './mocks/fileupload.json'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Form/File Upload',
|
|
6
|
+
component: FormInstance,
|
|
7
|
+
argTypes: {
|
|
8
|
+
preview: {
|
|
9
|
+
control: 'boolean',
|
|
10
|
+
defaultValue: true,
|
|
11
|
+
table: {
|
|
12
|
+
disable: true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
contentApiUrl: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
defaultValue: process.env.CONTENT_API_URL
|
|
18
|
+
},
|
|
19
|
+
processID: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
defaultValue: 'proc-id-form-advanced-controls',
|
|
22
|
+
table: {
|
|
23
|
+
disable: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
formid: {
|
|
27
|
+
control: 'string',
|
|
28
|
+
defaultValue: '',
|
|
29
|
+
table: {
|
|
30
|
+
disable: true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
type: {
|
|
34
|
+
control: 'text',
|
|
35
|
+
defaultValue: '',
|
|
36
|
+
table: {
|
|
37
|
+
disable: true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
webFormJson: {
|
|
41
|
+
control: 'object'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
args: {
|
|
45
|
+
processID: 'proc-id-form-advanced-controls',
|
|
46
|
+
preview: true,
|
|
47
|
+
contentApiUrl:process.env.CONTENT_API_URL
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const FileUpload = {args : {
|
|
53
|
+
type: 'managed_file',
|
|
54
|
+
webFormJson: fileupload,
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"c1": {
|
|
3
|
+
"#type": "managed_file",
|
|
4
|
+
"#title": "file1",
|
|
5
|
+
"#webform": "kitchen_sink_formio_v1",
|
|
6
|
+
"#webform_id": "kitchen_sink_formio_v1--file1",
|
|
7
|
+
"#webform_key": "file1",
|
|
8
|
+
"#description": {
|
|
9
|
+
"#theme": "webform_html_editor_markup",
|
|
10
|
+
"#markup": "Sign above"
|
|
11
|
+
},
|
|
12
|
+
"#description_display": "after",
|
|
13
|
+
"#webform_element": true,
|
|
14
|
+
"#input": true,
|
|
15
|
+
"#markup": "",
|
|
16
|
+
"#required": false,
|
|
17
|
+
"#title_display": "before",
|
|
18
|
+
"#id": "edit-file1",
|
|
19
|
+
"#name": "file1",
|
|
20
|
+
"#value": "",
|
|
21
|
+
"#label_attributes": {
|
|
22
|
+
"webform-remove-for-attribute": true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -99,8 +99,8 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
99
99
|
)
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
-
it(`should return a submission value for manual mode`, () => {
|
|
103
|
-
const submission = FormTestUtils.handleSubmission(json, {
|
|
102
|
+
it(`should return a submission value for manual mode`, async () => {
|
|
103
|
+
const submission = await FormTestUtils.handleSubmission(json, {
|
|
104
104
|
mode: 'manual',
|
|
105
105
|
address: {
|
|
106
106
|
address: 'a1',
|
|
@@ -123,8 +123,8 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
123
123
|
})
|
|
124
124
|
})
|
|
125
125
|
|
|
126
|
-
it(`should return a submission value for api mode`, () => {
|
|
127
|
-
const submission = FormTestUtils.handleSubmission(json, {
|
|
126
|
+
it(`should return a submission value for api mode`, async () => {
|
|
127
|
+
const submission = await FormTestUtils.handleSubmission(json, {
|
|
128
128
|
mode: 'autocomplete',
|
|
129
129
|
address: {
|
|
130
130
|
description: '715 Sydney Rd, Brunswick VIC 3056, Australia',
|
|
@@ -27,17 +27,17 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
27
27
|
validate: { required: false },
|
|
28
28
|
values: [
|
|
29
29
|
{ label: 'l1', value: 'value1' },
|
|
30
|
-
{ label: 'value2', value: 'value2' }
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
])
|
|
30
|
+
{ label: 'value2', value: 'value2' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
]),
|
|
34
34
|
)
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
-
it(`should return a submission value`, () => {
|
|
38
|
-
const submission = FormTestUtils.handleSubmission(json, {
|
|
37
|
+
it(`should return a submission value`, async () => {
|
|
38
|
+
const submission = await FormTestUtils.handleSubmission(json, {
|
|
39
39
|
value1: false,
|
|
40
|
-
value2: true
|
|
40
|
+
value2: true,
|
|
41
41
|
})
|
|
42
42
|
expect(submission).toEqual({ checkboxes1: ['value2'] })
|
|
43
43
|
})
|
|
@@ -24,7 +24,7 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
24
24
|
labelPosition: 'top',
|
|
25
25
|
mask: false,
|
|
26
26
|
type: 'textfield',
|
|
27
|
-
validate: {}
|
|
27
|
+
validate: {},
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
attributes: { counter: 4 },
|
|
@@ -39,8 +39,8 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
39
39
|
labelPosition: 'top',
|
|
40
40
|
mask: false,
|
|
41
41
|
type: 'checkbox',
|
|
42
|
-
validate: {}
|
|
43
|
-
}
|
|
42
|
+
validate: {},
|
|
43
|
+
},
|
|
44
44
|
],
|
|
45
45
|
customClass: 'custom-formio-1',
|
|
46
46
|
defaultValue: {},
|
|
@@ -53,34 +53,34 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
53
53
|
labelPosition: 'top',
|
|
54
54
|
mask: false,
|
|
55
55
|
type: 'editgrid',
|
|
56
|
-
validate: { maxLength: 20, minLength: 0 }
|
|
57
|
-
}
|
|
58
|
-
])
|
|
56
|
+
validate: { maxLength: 20, minLength: 0 },
|
|
57
|
+
},
|
|
58
|
+
]),
|
|
59
59
|
)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
it(`should return a submission value`, () => {
|
|
62
|
+
it(`should return a submission value`, async () => {
|
|
63
63
|
const formioform = FormTestUtils.getParsedFormFromJSON(json)
|
|
64
|
-
const submission = FormTestUtils.getSubmissionValue(
|
|
64
|
+
const submission = await FormTestUtils.getSubmissionValue(
|
|
65
65
|
{
|
|
66
66
|
person: [
|
|
67
67
|
{
|
|
68
68
|
firstname: 'john',
|
|
69
|
-
coming: false
|
|
69
|
+
coming: false,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
firstname: 'james',
|
|
73
|
-
coming: true
|
|
74
|
-
}
|
|
75
|
-
]
|
|
73
|
+
coming: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
76
|
},
|
|
77
|
-
formioform
|
|
77
|
+
formioform,
|
|
78
78
|
)
|
|
79
79
|
expect(submission).toEqual({
|
|
80
80
|
person: [
|
|
81
81
|
{ coming: false, firstname: 'john' },
|
|
82
|
-
{ coming: true, firstname: 'james' }
|
|
83
|
-
]
|
|
82
|
+
{ coming: true, firstname: 'james' },
|
|
83
|
+
],
|
|
84
84
|
})
|
|
85
85
|
})
|
|
86
86
|
})
|
|
@@ -15,7 +15,7 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
15
15
|
disableFunction: 'date.getDay() === 5',
|
|
16
16
|
disableWeekdays: false,
|
|
17
17
|
disableWeekends: false,
|
|
18
|
-
enableTime: false
|
|
18
|
+
enableTime: false,
|
|
19
19
|
},
|
|
20
20
|
disabled: false,
|
|
21
21
|
enableMaxDateInput: false,
|
|
@@ -46,17 +46,17 @@ describe(`Form ${testComponent} parser`, () => {
|
|
|
46
46
|
noCalendar: false,
|
|
47
47
|
time_24hr: false,
|
|
48
48
|
type: 'calendar',
|
|
49
|
-
useLocaleSettings: false
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
])
|
|
49
|
+
useLocaleSettings: false,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
]),
|
|
53
53
|
)
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
it(`should return a submission value`, () => {
|
|
57
|
-
const submission = FormTestUtils.handleSubmission(
|
|
56
|
+
it(`should return a submission value`, async () => {
|
|
57
|
+
const submission = await FormTestUtils.handleSubmission(
|
|
58
58
|
json,
|
|
59
|
-
'2021-08-19T00:00:00+10:00'
|
|
59
|
+
'2021-08-19T00:00:00+10:00',
|
|
60
60
|
)
|
|
61
61
|
expect(submission).toEqual({ date1: '2021-08-19T00:00:00+10:00' })
|
|
62
62
|
})
|