glib-web 4.35.2 → 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++) {
@@ -16,9 +16,11 @@
16
16
  <glib-component :spec="item.raw" />
17
17
  </v-list-subheader>
18
18
  <v-divider v-else-if="item.raw.divider"></v-divider>
19
- <select-item-default v-else-if="!item.raw.imageUrl" :context="props" :item="item"
20
- :spec="spec"></select-item-default>
21
- <select-item-with-image :context="props" :item="item" :spec="spec" v-else></select-item-with-image>
19
+ <select-item-with-image :context="props" :item="item" :spec="spec"
20
+ v-else-if="item.raw.imageUrl"></select-item-with-image>
21
+ <select-item-with-icon :context="props" :item="item" :spec="spec"
22
+ v-else-if="item.raw.icon"></select-item-with-icon>
23
+ <select-item-default v-else :context="props" :item="item" :spec="spec"></select-item-default>
22
24
  </div>
23
25
  </template>
24
26
 
@@ -57,18 +59,19 @@
57
59
  import inputVariant from '../mixins/inputVariant';
58
60
  import { determineDensity } from "../../utils/constant";
59
61
  import { triggerOnChange, triggerOnInput, useGlibInput } from "../composable/form";
60
- import Hash from '../../utils/hash';
61
62
  import { isBoolean } from '../../utils/type';
62
63
 
63
64
  import { useGlibSelectable, watchNoneOfAbove } from '../composable/selectable';
64
65
  import { ref } from 'vue';
65
66
  import SelectItemDefault from "./_selectItemDefault.vue";
66
67
  import SelectItemWithImage from "./_selectItemWithImage.vue";
68
+ import SelectItemWithIcon from "./_selectItemWithIcon.vue";
67
69
 
68
70
  export default {
69
71
  components: {
70
72
  'select-item-default': SelectItemDefault,
71
- 'select-item-with-image': SelectItemWithImage
73
+ 'select-item-with-image': SelectItemWithImage,
74
+ 'select-item-with-icon': SelectItemWithIcon
72
75
  },
73
76
  mixins: [inputVariant],
74
77
  props: {
@@ -167,21 +170,6 @@ export default {
167
170
  },
168
171
  $registryEnabled() {
169
172
  return false;
170
- },
171
- itemIconSpec(iconSpec) {
172
- const hash = new Hash(iconSpec);
173
- const name = hash.remove('name');
174
- const size = hash.remove('size');
175
- const color = hash.remove('color');
176
-
177
- return hash.deepMerge({
178
- view: 'icon',
179
- material: {
180
- name: name,
181
- size: size,
182
- color: color
183
- }
184
- });
185
173
  }
186
174
  }
187
175
  };
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <v-list-item v-bind="props.context" :disabled="props.item.raw.disabled">
3
3
  <template v-slot:prepend="{ isActive }">
4
- <glib-component v-if="props.item.raw.icon" :spec="itemIconSpec(props.item.raw.icon)" />
5
4
  <v-list-item-action start v-if="props.spec.multiple">
6
5
  <v-checkbox-btn :model-value="isActive"></v-checkbox-btn>
7
6
  </v-list-item-action>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <v-list-item v-bind="props.context" :disabled="props.item.raw.disabled">
3
+ <template v-slot:prepend="{ isActive }">
4
+ <v-list-item-action v-if="props.spec.multiple">
5
+ <v-checkbox-btn :model-value="isActive"></v-checkbox-btn>
6
+ </v-list-item-action>
7
+ <glib-component :spec="itemIconSpec(props.item.raw.icon)" />
8
+ </template>
9
+ </v-list-item>
10
+ </template>
11
+
12
+ <script setup>
13
+ import Hash from "../../utils/hash";
14
+
15
+ const props = defineProps(['context', 'item', 'spec']);
16
+
17
+ function itemIconSpec(iconSpec) {
18
+ const hash = new Hash(iconSpec);
19
+ const name = hash.remove('name');
20
+ const size = hash.remove('size');
21
+ const color = hash.remove('color');
22
+
23
+ return hash.deepMerge({
24
+ view: 'icon',
25
+ material: {
26
+ name: name,
27
+ size: size,
28
+ color: color
29
+ }
30
+ });
31
+ }
32
+ </script>
@@ -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/nav/appBar.vue CHANGED
@@ -16,13 +16,13 @@
16
16
  </span>
17
17
  <v-spacer></v-spacer>
18
18
 
19
- <v-toolbar-items :class="navBar.collapseButtonsOnMobile ? 'hidden-sm-and-down' : null">
19
+ <div :class="navBar.collapseButtonsOnMobile ? 'hidden-sm-and-down' : null">
20
20
  <template v-for="(btn, index) in navBar.rightButtons">
21
21
  <common-dropdownMenu v-if="btn.childButtons" :key="index" :spec="btn" />
22
22
  <v-divider vertical thickness="1" v-else-if="btn.type == 'divider'" :key="`divider_${index}`"></v-divider>
23
23
  <common-button v-else :key="`right_${index}`" :spec="buttonSpec(btn)" />
24
24
  </template>
25
- </v-toolbar-items>
25
+ </div>
26
26
 
27
27
  <common-dropdownMenu v-if="showMobileMenu" class="hidden-md-and-up" :spec="mobileMenu" />
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "4.35.2",
3
+ "version": "4.35.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {