@worksafevictoria/wcl7.5 1.4.0 → 1.6.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 +4 -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 +69 -49
- package/src/components/Common/CardGridItem/card-grid-item-caret.vue +7 -4
- package/src/components/Common/CardGridItem/index.vue +95 -71
- 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/AppHeaderNew/index.vue +304 -233
- package/src/components/Global/AppHeaderNew/styles.scss +29 -8
- package/src/components/Global/BackToTop/index.vue +8 -8
- package/src/components/Global/ContrastMode/index.vue +1 -1
- package/src/components/Global/Cookies/index.stories.js +16 -10
- package/src/components/Global/Cookies/index.vue +281 -237
- package/src/components/Global/Cookies/styles.scss +54 -54
- package/src/components/Global/DirectoryFilters/SingleTaxonomy/index.vue +50 -133
- 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 +485 -485
- package/src/components/Paragraphs/Chart/index.vue +232 -241
- package/src/components/Paragraphs/Directory/Records/HSCP/index.stories.js +33 -0
- package/src/components/Paragraphs/Directory/Records/HSCP/index.vue +334 -0
- package/src/components/Paragraphs/Directory/Records/ISP/index.vue +2 -2
- package/src/components/Paragraphs/Directory/Records/index.vue +63 -27
- package/src/components/Paragraphs/Directory/Records/styles.scss +1 -0
- package/src/components/Paragraphs/Directory/constants.js +23 -5
- package/src/components/Paragraphs/Directory/index.vue +14 -14
- package/src/components/Paragraphs/ListGroup/index.vue +5 -1
- 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/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 +63 -28
- package/src/components/SubComponents/FormInstance/models/overrides/file.js +33 -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 +35 -33
- package/src/components/SubComponents/VideoThumbnail/index.vue +48 -133
- package/src/includes/scss/mixins/src/units.scss +25 -4
- package/src/includes/scss/vars/src/colors.module.scss +28 -1
- package/src/index.js +21 -3
- package/src/main.js +2 -10
- package/src/mock/app-header-new.js +27 -15
- package/src/mock/carousel-items.js +71 -46
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script>
|
|
19
|
-
// import { Form, Formio } from 'vue-formio'
|
|
20
19
|
import { Form, Formio } from '@formio/vue'
|
|
21
20
|
import '@fortawesome/fontawesome-free/css/all.min.css'
|
|
22
21
|
import '@fortawesome/fontawesome-free/css/v4-shims.min.css'
|
|
@@ -28,25 +27,25 @@ export default {
|
|
|
28
27
|
props: {
|
|
29
28
|
formiodefinition: {
|
|
30
29
|
type: Object,
|
|
31
|
-
required: true
|
|
30
|
+
required: true,
|
|
32
31
|
},
|
|
33
32
|
options: {
|
|
34
33
|
type: Object,
|
|
35
|
-
required: true
|
|
34
|
+
required: true,
|
|
36
35
|
},
|
|
37
36
|
overrideCSS: {
|
|
38
37
|
type: String,
|
|
39
38
|
required: true,
|
|
40
|
-
default: ''
|
|
39
|
+
default: '',
|
|
41
40
|
},
|
|
42
|
-
processID: { type: String, required: true }
|
|
41
|
+
processID: { type: String, required: true },
|
|
43
42
|
},
|
|
44
43
|
data() {
|
|
45
44
|
return {
|
|
46
45
|
debouncedChanges: this.debounce(this.changed, 250),
|
|
47
46
|
debouncedSubmission: this.debounce(this.submit, 250),
|
|
48
47
|
firstEl: null,
|
|
49
|
-
started: false
|
|
48
|
+
started: false,
|
|
50
49
|
}
|
|
51
50
|
},
|
|
52
51
|
mounted() {
|
|
@@ -55,7 +54,7 @@ export default {
|
|
|
55
54
|
this.$el.appendChild(styleTag)
|
|
56
55
|
|
|
57
56
|
const tooltips = document.getElementsByClassName(
|
|
58
|
-
'fa fa-question-circle text-muted'
|
|
57
|
+
'fa fa-question-circle text-muted',
|
|
59
58
|
)
|
|
60
59
|
if (tooltips.length) {
|
|
61
60
|
;[...tooltips].forEach((tt) => {
|
|
@@ -66,11 +65,11 @@ export default {
|
|
|
66
65
|
category: 'form help',
|
|
67
66
|
data: e.target.parentElement.innerText,
|
|
68
67
|
label: 'tooltip',
|
|
69
|
-
processId: this.processID
|
|
68
|
+
processId: this.processID,
|
|
70
69
|
}
|
|
71
70
|
this.$gtm.push({
|
|
72
71
|
event: 'custom.form.interaction.tooltip.show',
|
|
73
|
-
...attrs
|
|
72
|
+
...attrs,
|
|
74
73
|
})
|
|
75
74
|
}
|
|
76
75
|
})
|
|
@@ -91,17 +90,53 @@ export default {
|
|
|
91
90
|
let attrs = {
|
|
92
91
|
group: document.title,
|
|
93
92
|
label: ev.component.key,
|
|
94
|
-
data: ev._data[ev.component.key]
|
|
93
|
+
data: ev._data[ev.component.key],
|
|
95
94
|
}
|
|
96
95
|
if (this.$gtm) {
|
|
97
96
|
this.$gtm.push({
|
|
98
97
|
event: 'custom.form.progress.field.complete',
|
|
99
|
-
...attrs
|
|
98
|
+
...attrs,
|
|
100
99
|
})
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
},
|
|
104
103
|
changed(_e, event) {
|
|
104
|
+
// File upload validation
|
|
105
|
+
if (event.changed?.component.type === 'file') {
|
|
106
|
+
const maxFiles = event.changed.component.fileMaxCount || 1
|
|
107
|
+
const convertToBytes = (size) => {
|
|
108
|
+
const units = {
|
|
109
|
+
KB: 1024,
|
|
110
|
+
MB: 1024 * 1024,
|
|
111
|
+
GB: 1024 * 1024 * 1024,
|
|
112
|
+
}
|
|
113
|
+
const match = size.match(/^(\d+(?:\.\d+)?)\s*(KB|MB|GB)$/i)
|
|
114
|
+
if (!match) {
|
|
115
|
+
throw new Error("Invalid size format. Use 'KB', 'MB', or 'GB'.")
|
|
116
|
+
}
|
|
117
|
+
const value = parseFloat(match[1])
|
|
118
|
+
const unit = match[2].toUpperCase()
|
|
119
|
+
return value * units[unit]
|
|
120
|
+
}
|
|
121
|
+
const maxTotalSize = event.changed.component.fileMaxSize
|
|
122
|
+
const maxTotalBytes = convertToBytes(maxTotalSize)
|
|
123
|
+
const files = event.changed.instance.dataValue || []
|
|
124
|
+
if (files.length > maxFiles) {
|
|
125
|
+
event.changed.instance.dataValue = files.slice(0, files.length - 1)
|
|
126
|
+
event.changed.instance.triggerChange()
|
|
127
|
+
event.changed.instance.triggerRedraw()
|
|
128
|
+
alert(`You can only upload up to ${maxFiles} files.`)
|
|
129
|
+
}
|
|
130
|
+
const totalSize = files.reduce((sum, file) => sum + (file.size || 0), 0)
|
|
131
|
+
if (totalSize > maxTotalBytes) {
|
|
132
|
+
event.changed.instance.dataValue = files.slice(0, files.length - 1)
|
|
133
|
+
event.changed.instance.triggerChange()
|
|
134
|
+
event.changed.instance.triggerRedraw()
|
|
135
|
+
alert(`Total file size cannot exceed ${maxTotalSize}.`)
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
105
140
|
if (
|
|
106
141
|
this.$gtm &&
|
|
107
142
|
!this.started &&
|
|
@@ -115,7 +150,7 @@ export default {
|
|
|
115
150
|
category: '',
|
|
116
151
|
label: 'Start',
|
|
117
152
|
targetElement: this.firstEl,
|
|
118
|
-
processId: this.processID
|
|
153
|
+
processId: this.processID,
|
|
119
154
|
}
|
|
120
155
|
this.$gtm.push({ event: 'custom.form.progress.start', ...attrs })
|
|
121
156
|
}
|
|
@@ -133,11 +168,11 @@ export default {
|
|
|
133
168
|
let attrs = {
|
|
134
169
|
group: document.title,
|
|
135
170
|
label: event.changed.component.key,
|
|
136
|
-
data: event.changed.value
|
|
171
|
+
data: event.changed.value,
|
|
137
172
|
}
|
|
138
173
|
this.$gtm.push({
|
|
139
174
|
event: 'custom.form.progress.field.complete',
|
|
140
|
-
...attrs
|
|
175
|
+
...attrs,
|
|
141
176
|
})
|
|
142
177
|
}
|
|
143
178
|
}
|
|
@@ -145,22 +180,22 @@ export default {
|
|
|
145
180
|
if (event?.changed?.component) {
|
|
146
181
|
this.$emit('changed', {
|
|
147
182
|
...event.changed,
|
|
148
|
-
key: event.changed.component.key
|
|
183
|
+
key: event.changed.component.key,
|
|
149
184
|
})
|
|
150
185
|
}
|
|
151
186
|
},
|
|
152
187
|
submit(submission) {
|
|
153
188
|
this.$emit('submitted', {
|
|
154
189
|
submission,
|
|
155
|
-
formioinstance: Object.values(Formio.forms)[0]
|
|
190
|
+
formioinstance: Object.values(Formio.forms)[0],
|
|
156
191
|
})
|
|
157
192
|
},
|
|
158
193
|
debounce(func, wait, immediate) {
|
|
159
194
|
let timeout
|
|
160
|
-
return function() {
|
|
195
|
+
return function () {
|
|
161
196
|
const context = this,
|
|
162
197
|
args = arguments
|
|
163
|
-
const later = function() {
|
|
198
|
+
const later = function () {
|
|
164
199
|
timeout = null
|
|
165
200
|
if (!immediate) func.apply(context, args)
|
|
166
201
|
}
|
|
@@ -180,9 +215,9 @@ export default {
|
|
|
180
215
|
step: {
|
|
181
216
|
label: this.formiodefinition.components[ev.page - 1].title,
|
|
182
217
|
stepNumber: ev.page + 1,
|
|
183
|
-
subStepNumber: undefined
|
|
218
|
+
subStepNumber: undefined,
|
|
184
219
|
},
|
|
185
|
-
processId: this.processID
|
|
220
|
+
processId: this.processID,
|
|
186
221
|
}
|
|
187
222
|
this.$gtm.push({ event: 'custom.form.progress.step', ...attrs })
|
|
188
223
|
}
|
|
@@ -195,9 +230,9 @@ export default {
|
|
|
195
230
|
step: {
|
|
196
231
|
label: this.formiodefinition.components[ev.page + 1].title,
|
|
197
232
|
stepNumber: ev.page + 1,
|
|
198
|
-
subStepNumber: undefined
|
|
233
|
+
subStepNumber: undefined,
|
|
199
234
|
},
|
|
200
|
-
processId: this.processID
|
|
235
|
+
processId: this.processID,
|
|
201
236
|
}
|
|
202
237
|
this.$gtm.push({ event: 'custom.form.progress.step', ...attrs })
|
|
203
238
|
}
|
|
@@ -211,10 +246,10 @@ export default {
|
|
|
211
246
|
{
|
|
212
247
|
errorId: '',
|
|
213
248
|
errorDetail: ev.messages[0].key,
|
|
214
|
-
errorMessage: ev.messages[0].message
|
|
215
|
-
}
|
|
216
|
-
]
|
|
217
|
-
}
|
|
249
|
+
errorMessage: ev.messages[0].message,
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
218
253
|
}
|
|
219
254
|
if (ev.messages[0].context?.validator === 'required') {
|
|
220
255
|
attrs.event = 'custom.form.error.required'
|
|
@@ -230,8 +265,8 @@ export default {
|
|
|
230
265
|
if (this.$gtm) {
|
|
231
266
|
this.$gtm.push({ event: attrs.event, ...attrs.data })
|
|
232
267
|
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
268
|
+
},
|
|
269
|
+
},
|
|
235
270
|
}
|
|
236
271
|
</script>
|
|
237
272
|
<style lang="scss">
|
|
@@ -5,52 +5,45 @@ 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
|
-
input: true,
|
|
40
|
+
multiple: true,
|
|
41
|
+
description: `No more than ${this.webformElement['#multiple']} files accepted. Maximum total size is ${this.webformElement['#max_filesize']}MB.`,
|
|
42
|
+
filePattern:
|
|
43
|
+
'*.png,*.jpg,*.jpeg,*.pdf,*.doc,*.docx,*.xls,*.xlsx,*.csv,*.txt',
|
|
52
44
|
fileKey: `files[${this.webformElement['#name']}]`,
|
|
53
|
-
|
|
45
|
+
fileMaxSize: `${this.webformElement['#max_filesize']}MB`,
|
|
46
|
+
fileMaxCount: this.webformElement['#multiple'],
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
49
|
}
|
|
@@ -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
|
})
|