glib-web 4.35.3 → 4.35.4

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.
@@ -126,4 +126,16 @@ function validateFile(accepts, file) {
126
126
  return true;
127
127
  }
128
128
 
129
- export { useFileUtils, useFilesState, validateFile };
129
+ function validateFiles({ files, newFiles, accepts }) {
130
+ const { maxFileLength, maxFileLengthErrorText } = accepts;
131
+ if (maxFileLength !== null) {
132
+ const fileLength = newFiles.length + Object.keys(files.value).length;
133
+ if (fileLength > maxFileLength) {
134
+ showError(maxFileLengthErrorText);
135
+ return false;
136
+ }
137
+ }
138
+ return true;
139
+ }
140
+
141
+ export { useFileUtils, useFilesState, validateFile, validateFiles };
@@ -2,7 +2,7 @@ import { watch } from 'vue';
2
2
  import { triggerOnChange } from "./form";
3
3
  import Uploader from "../../utils/glibDirectUpload";
4
4
  import { vueApp } from "../../store";
5
- import { useFilesState, useFileUtils, validateFile } from "./file";
5
+ import { useFilesState, useFileUtils, validateFile, validateFiles } from "./file";
6
6
  const { makeKey, Item } = useFileUtils();
7
7
 
8
8
  function submitOnAllUploaded({ url, formData, files, actionName }) {
@@ -36,6 +36,8 @@ function uploadFiles({ droppedFiles, files, spec, container, onAfterUploaded })
36
36
  let { responseMessages } = spec;
37
37
  responseMessages ||= {};
38
38
 
39
+ if (!validateFiles({ newFiles: droppedFiles, accepts: spec.accepts, files })) return;
40
+
39
41
  let key = '';
40
42
  for (let index = 0; index < droppedFiles.length; index++) {
41
43
  // show new dropped file and track progress
@@ -1,9 +1,12 @@
1
- import { useFileUtils, validateFile } from "./file";
1
+ import { useFileUtils, validateFile, validateFiles } from "./file";
2
2
 
3
3
  const { makeKey, Item } = useFileUtils();
4
4
 
5
5
  function uploadFiles({ droppedFiles, files, spec }) {
6
6
  const { accepts } = spec;
7
+
8
+ if (!validateFiles({ newFiles: droppedFiles, files, accepts })) return;
9
+
7
10
  let key = '';
8
11
  files.value = {};
9
12
  for (let index = 0; index < droppedFiles.length; index++) {
@@ -89,13 +89,13 @@ export default {
89
89
  this.fileValue = null;
90
90
  },
91
91
  displayImagePreview(file, blob) {
92
+ this.fileTitle = file.name;
93
+ this.fileValue = blob.signed_id;
92
94
  if (!file.type.startsWith('image')) return;
93
95
 
94
96
  let reader = new FileReader();
95
97
  reader.onload = (e) => {
96
- this.fileTitle = file.name;
97
98
  this.fileImage = e.target.result;
98
- this.fileValue = blob.signed_id;
99
99
  };
100
100
  reader.readAsDataURL(file);
101
101
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "4.35.3",
3
+ "version": "4.35.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {