@hostlink/nuxt-light 1.0.7 → 1.0.8

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.0.7"
4
+ "version": "1.0.8"
5
5
  }
@@ -3,8 +3,10 @@ import { VariableType } from "json-to-graphql-query";
3
3
  import { ref, computed, useAttrs } from "vue";
4
4
  import { useLight, m } from '#imports';
5
5
  import { Loading, Dialog } from "quasar";
6
+ import { useI18n } from "vue-i18n";
6
7
 
7
8
  const light = useLight();
9
+ const i18n = useI18n();
8
10
 
9
11
  export interface LFileProps {
10
12
  modelValue?: string;
@@ -59,12 +61,22 @@ const attrs = computed(() => {
59
61
  const uploadFile = ref(null);
60
62
 
61
63
  const onUploadFile = async () => {
64
+
65
+ if (!uploadFile.value) {
66
+ Dialog.create({
67
+ title: "Error",
68
+ message: i18n.t("Please select a file"),
69
+ color: "negative"
70
+ });
71
+ return;
72
+ }
73
+
62
74
  Loading.show({
63
- message: "Uploading file...",
75
+ message: i18n.t("Uploading file..."),
64
76
  });
65
77
 
66
78
  try {
67
- localValue.value = await m("fsUploadFile", {
79
+ let v = await m("fsUploadFile", {
68
80
  path: props.path,
69
81
  file: new VariableType("file"),
70
82
  rename: true
@@ -76,6 +88,12 @@ const onUploadFile = async () => {
76
88
  }
77
89
  }
78
90
  }]);
91
+
92
+ //remove first slash if exists
93
+ if (v.startsWith("/")) v = v.substr(1);
94
+
95
+ localValue.value = v;
96
+
79
97
  Loading.hide();
80
98
 
81
99
  show.value = false;
@@ -83,7 +101,7 @@ const onUploadFile = async () => {
83
101
  return;
84
102
  } catch (e: any) {
85
103
  Dialog.create({
86
- title: "Error",
104
+ title: i18n.t("Error"),
87
105
  message: e.message,
88
106
  });
89
107
  }
@@ -98,12 +116,11 @@ const onUploadFile = async () => {
98
116
  <q-dialog v-model="show" persistent transition-show="scale" transition-hide="scale">
99
117
  <l-card style="width:300px">
100
118
  <q-card-section>
101
- <q-file ref="file" v-model="uploadFile" name="file" label="Files"></q-file>
119
+ <q-file ref="file" v-model="uploadFile" name="file" :label="$t('File')" :accept="accept"></q-file>
102
120
  </q-card-section>
103
-
104
121
  <q-card-actions align="right">
105
- <q-btn flat label="Cancel" color="primary" v-close-popup></q-btn>
106
- <q-btn flat label="Upload" color="primary" @click="onUploadFile"></q-btn>
122
+ <q-btn flat :label="$t('Cancel')" color="primary" v-close-popup></q-btn>
123
+ <q-btn flat :label="$t('Upload')" color="primary" @click="onUploadFile"></q-btn>
107
124
  </q-card-actions>
108
125
  </l-card>
109
126
  </q-dialog>
@@ -22,7 +22,7 @@ const onBlur = () => {
22
22
  }
23
23
  </script>
24
24
  <template>
25
- <l-file-upload v-model="value" :label="context.label" v-bind="context.attrs" :error="error" :type="context.inputType"
25
+ <l-file-upload v-bind="context.attrs" v-model="value" :label="context.label" :error="error" :type="context.inputType"
26
26
  :error-message="errorMessage" @blur="onBlur">
27
27
  <template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
28
28
  <slot :name="name" v-bind="props ?? {}"></slot>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",