@worksafevictoria/wcl7.5 1.1.0-beta.104 → 1.1.0-beta.105

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.
@@ -12,10 +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>
22
+ import { BModal } from 'bootstrap-vue-next'
19
23
  import { Form, Formio } from '@formio/vue'
20
24
  import '@fortawesome/fontawesome-free/css/all.min.css'
21
25
  import '@fortawesome/fontawesome-free/css/v4-shims.min.css'
@@ -23,7 +27,7 @@ import 'formiojs/dist/formio.builder.min.css'
23
27
 
24
28
  export default {
25
29
  name: 'FormRenderer',
26
- components: { formio: Form },
30
+ components: { formio: Form, BModal },
27
31
  props: {
28
32
  formiodefinition: {
29
33
  type: Object,
@@ -46,6 +50,8 @@ export default {
46
50
  debouncedSubmission: this.debounce(this.submit, 250),
47
51
  firstEl: null,
48
52
  started: false,
53
+ modal: false,
54
+ fileMessage: '',
49
55
  }
50
56
  },
51
57
  mounted() {
@@ -100,7 +106,7 @@ export default {
100
106
  }
101
107
  }
102
108
  },
103
- changed(_e, event) {
109
+ async changed(_e, event) {
104
110
  // File upload validation
105
111
  if (event.changed?.component.type === 'file') {
106
112
  const maxFiles = event.changed.component.fileMaxCount || 1
@@ -122,17 +128,27 @@ export default {
122
128
  const maxTotalBytes = convertToBytes(maxTotalSize)
123
129
  const files = event.changed.instance.dataValue || []
124
130
  if (files.length > maxFiles) {
125
- event.changed.instance.dataValue = files.slice(0, files.length - 1)
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
+
126
135
  event.changed.instance.triggerChange()
127
136
  event.changed.instance.triggerRedraw()
128
- alert(`You can only upload up to ${maxFiles} files.`)
129
137
  }
130
- const totalSize = files.reduce((sum, file) => sum + (file.size || 0), 0)
138
+ let totalSize = files.reduce((sum, file) => sum + (file.size || 0), 0)
131
139
  if (totalSize > maxTotalBytes) {
132
- event.changed.instance.dataValue = files.slice(0, files.length - 1)
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)
133
150
  event.changed.instance.triggerChange()
134
151
  event.changed.instance.triggerRedraw()
135
- alert(`Total file size cannot exceed ${maxTotalSize}.`)
136
152
  return
137
153
  }
138
154
  }
@@ -39,8 +39,13 @@ export class FileFormElement extends BaseFormElement {
39
39
  webcam: false,
40
40
  multiple: true,
41
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',
42
+ filePattern: this.webformElement['#file_extensions']
43
+ ? this.webformElement['#file_extensions']
44
+ .split(' ')
45
+ .map((ext) => `.${ext}`)
46
+ .join(',')
47
+ : '',
48
+
44
49
  fileKey: `files[${this.webformElement['#name']}]`,
45
50
  fileMaxSize: `${this.webformElement['#max_filesize']}MB`,
46
51
  fileMaxCount: this.webformElement['#multiple'],
package/src/index.js CHANGED
@@ -43,6 +43,7 @@ import MarketingBanner from './components/Paragraphs/MarketingBanner/index.vue'
43
43
  import RelatedInformation from './components/Paragraphs/RelatedInformation/index.vue'
44
44
  import Calculator from './components/Paragraphs/Calculator/index.vue'
45
45
  import Chart from './components/Paragraphs/Chart/index.vue'
46
+ import GeoChart from './components/Paragraphs/Map/index.vue'
46
47
 
47
48
  // SubComponents
48
49
  import FormAddressPostcode from './components/SubComponents/FormAddressPostcode/index.vue'
@@ -108,6 +109,7 @@ export {
108
109
  RelatedInformation,
109
110
  Calculator,
110
111
  Chart,
112
+ GeoChart,
111
113
  }
112
114
 
113
115
  // Export Sub Components