vue-intergrall-plugins 0.0.503 → 0.0.504

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.
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <span class="text-footer-actions--btn" :class="{'files-activated' : openFiles || file.name}" @click="openFilesByClip()"> <!-- || file.length -->
2
+ <span
3
+ class="text-footer-actions--btn"
4
+ :class="{ 'files-activated': openFiles || file.name }"
5
+ @click="openFilesByClip()"
6
+ >
7
+ <!-- || file.length -->
3
8
  <!-- <transition name="fade">
4
9
  <span v-if="fileSize > 0" @click.stop="toggleFilePreview" v-tippy :content="`Visualizar ${fileSize} arquivo(s)`" class="files-counter">
5
10
  {{ fileSize }}
@@ -7,7 +12,19 @@
7
12
  </transition> -->
8
13
  <fa-icon :icon="['fas', 'paperclip']" :title="dictionary.title_selecionar_anexo" />
9
14
  <transition name="fade">
10
- <span v-if="fileSize > 0" @click.stop="toggleFilePreview" v-tippy :content="!fileSettings.handleFilePreview ? dictionary.msg_abrir_anexos : `${file.length} anexo(s) selecionado(s)`" :class="`${fileSettings.filePreviewStyle == 2 ? 'files-counter-2' : 'files-counter'}`">
15
+ <span
16
+ v-if="fileSize > 0"
17
+ @click.stop="toggleFilePreview"
18
+ v-tippy
19
+ :content="
20
+ !fileSettings.handleFilePreview
21
+ ? dictionary.msg_abrir_anexos
22
+ : `${file.length} anexo(s) selecionado(s)`
23
+ "
24
+ :class="`${
25
+ fileSettings.filePreviewStyle == 2 ? 'files-counter-2' : 'files-counter'
26
+ }`"
27
+ >
11
28
  <template v-if="fileSettings.filePreviewStyle == 1">
12
29
  {{ fileSize }}
13
30
  </template>
@@ -17,32 +34,80 @@
17
34
  </span>
18
35
  </transition>
19
36
  <transition name="show">
20
- <div v-if="openFiles && hasButtonFiles" class="text-footer-files-container" :class="{'horizontal' : cssStyle.outsideButtons}">
37
+ <div
38
+ v-if="openFiles && hasButtonFiles"
39
+ class="text-footer-files-container"
40
+ :class="{ horizontal: cssStyle.outsideButtons }"
41
+ >
21
42
  <template v-if="!fileSettings.multiple">
22
- <div class="files-btn images" :class="{'margin-bottom' : cssStyle.outsideButtons}" :title="dictionary.title_anexo_img" @click="openSelectFileHandler('img')">
43
+ <div
44
+ class="files-btn images"
45
+ :class="{ 'margin-bottom': cssStyle.outsideButtons }"
46
+ :title="dictionary.title_anexo_img"
47
+ @click="openSelectFileHandler('img')"
48
+ >
23
49
  <fa-icon :icon="['fas', 'image']" />
24
50
  </div>
25
- <div class="files-btn docs" :title="dictionary.title_anexo_doc" @click="openSelectFileHandler('doc')">
51
+ <div
52
+ class="files-btn docs"
53
+ :title="dictionary.title_anexo_doc"
54
+ @click="openSelectFileHandler('doc')"
55
+ >
26
56
  <fa-icon :icon="['fas', 'file-alt']" />
27
57
  </div>
28
58
  </template>
29
- <div v-else class="files-btn both" :title="dictionary.title_anexo_arq" @click="openSelectFileHandler('both')">
59
+ <div
60
+ v-else
61
+ class="files-btn both"
62
+ :title="dictionary.title_anexo_arq"
63
+ @click="openSelectFileHandler('both')"
64
+ >
30
65
  <fa-icon :icon="['fas', 'image']" />
31
66
  <fa-icon :icon="['fas', 'file-alt']" />
32
67
  </div>
33
- <div v-if="fileSettings.systemButton" class="files-btn system" :title="dictionary.title_anexo_sistema" @click="openSelectFileHandler('system')">
68
+ <div
69
+ v-if="fileSettings.systemButton"
70
+ class="files-btn system"
71
+ :title="dictionary.title_anexo_sistema"
72
+ @click="openSelectFileHandler('system')"
73
+ >
34
74
  <fa-icon :icon="['fas', 'server']" />
35
75
  </div>
36
76
  </div>
37
77
  </transition>
38
78
  <div class="files-pointers d-none">
39
- <input v-if="fileSettings.multiple" type="file" :id="`both-${textId}`" :accept="acceptedExtensions" multiple @change="fileUpload($event, 'both')" />
40
- <input v-if="!fileSettings.multiple" type="file" :id="`img-${textId}`" :accept="acceptedExtensions" @change="fileUpload($event, 'img')" />
41
- <input v-if="!fileSettings.multiple" type="file" :id="`doc-${textId}`" :accept="acceptedExtensions" @change="fileUpload($event, 'doc')" />
79
+ <input
80
+ v-if="fileSettings.multiple"
81
+ type="file"
82
+ :id="`both-${textId}`"
83
+ :accept="acceptedExtensions"
84
+ multiple
85
+ @change="fileUpload($event, 'both')"
86
+ />
87
+ <input
88
+ v-if="!fileSettings.multiple"
89
+ type="file"
90
+ :id="`img-${textId}`"
91
+ :accept="acceptedExtensions"
92
+ @change="fileUpload($event, 'img')"
93
+ />
94
+ <input
95
+ v-if="!fileSettings.multiple"
96
+ type="file"
97
+ :id="`doc-${textId}`"
98
+ :accept="acceptedExtensions"
99
+ @change="fileUpload($event, 'doc')"
100
+ />
42
101
  </div>
43
102
  <transition name="fade">
44
- <div class="text-footer-preview-container" @click.stop v-show="showFilePreview" :class="[previewContainerClass]" v-on-clickaway="away">
45
- <SingleFilePreview
103
+ <div
104
+ class="text-footer-preview-container"
105
+ @click.stop
106
+ v-show="showFilePreview"
107
+ :class="[previewContainerClass]"
108
+ v-on-clickaway="away"
109
+ >
110
+ <SingleFilePreview
46
111
  v-if="!fileSettings.multiple && showFilePreview"
47
112
  :dictionary="dictionary"
48
113
  :file="file"
@@ -55,7 +120,7 @@
55
120
  @open-image="openImage"
56
121
  @close="away"
57
122
  />
58
- <MultipleFilePreview
123
+ <MultipleFilePreview
59
124
  v-else-if="fileSettings.multiple && showFilePreview"
60
125
  :dictionary="dictionary"
61
126
  :file="file"
@@ -87,7 +152,7 @@
87
152
  transform: translate(17.5px, -15px);
88
153
  background-color: #888;
89
154
  z-index: 1;
90
- font-size: .5rem;
155
+ font-size: 8px;
91
156
  width: 15px;
92
157
  height: 15px;
93
158
  border-radius: 50%;
@@ -95,23 +160,23 @@
95
160
  justify-content: center;
96
161
  align-items: center;
97
162
  cursor: pointer;
98
- opacity: .9;
163
+ opacity: 0.9;
99
164
  transition: all 300ms;
100
- color: #FFF;
165
+ color: #fff;
101
166
  font-weight: 900;
102
167
  }
103
168
  .files-counter:hover {
104
- opacity: 1
169
+ opacity: 1;
105
170
  }
106
171
  .files-counter-2 {
107
172
  transform: translate(-15px, 28px);
108
- opacity: .9;
173
+ opacity: 0.9;
109
174
  position: absolute;
110
175
  display: flex;
111
176
  justify-content: center;
112
177
  align-items: center;
113
178
  color: #888;
114
- font-size: .8rem
179
+ font-size: 12.8px;
115
180
  }
116
181
  .files-counter-2 svg {
117
182
  margin-left: 5px;
@@ -123,38 +188,38 @@
123
188
  </style>
124
189
 
125
190
  <script>
126
- import { mixin as clickaway } from 'vue-clickaway'
127
- import SingleFilePreview from "./SingleFilePreview"
128
- import MultipleFilePreview from "./MultipleFilePreview"
191
+ import { mixin as clickaway } from "vue-clickaway";
192
+ import SingleFilePreview from "./SingleFilePreview";
193
+ import MultipleFilePreview from "./MultipleFilePreview";
129
194
 
130
195
  export default {
131
196
  components: { SingleFilePreview, MultipleFilePreview },
132
- mixins: [ clickaway ],
197
+ mixins: [clickaway],
133
198
  props: {
134
199
  textId: {
135
200
  type: String,
136
- required: true
201
+ required: true,
137
202
  },
138
203
  dictionary: {
139
204
  type: Object,
140
- required: true
205
+ required: true,
141
206
  },
142
207
  fileSettings: {
143
208
  type: Object,
144
- required: false
209
+ required: false,
145
210
  },
146
211
  cssStyle: {
147
212
  type: Object,
148
- required: false
213
+ required: false,
149
214
  },
150
215
  hasButtonFiles: {
151
216
  type: Boolean,
152
- required: false
217
+ required: false,
153
218
  },
154
219
  externalFiles: {
155
220
  type: Array,
156
- required: false
157
- }
221
+ required: false,
222
+ },
158
223
  },
159
224
  data() {
160
225
  return {
@@ -168,248 +233,309 @@ export default {
168
233
  validFileFormats: "",
169
234
  hasAnyFile: false,
170
235
  externalFilesAux: [],
171
- }
236
+ };
172
237
  },
173
238
  computed: {
174
239
  previewContainerClass() {
175
- if(this.fileFormatError) return "isError"
176
- if(this.fileSettings.multiple) return "isMultiple"
177
- if(this.isDoc) return "isDoc"
178
- return "isMsg"
240
+ if (this.fileFormatError) return "isError";
241
+ if (this.fileSettings.multiple) return "isMultiple";
242
+ if (this.isDoc) return "isDoc";
243
+ return "isMsg";
179
244
  },
180
245
  acceptedExtensions() {
181
- let str = ""
182
- if(this.fileSettings.docsExtensions && this.fileSettings.imagesExtensions) {
183
- str = `${this.fileSettings.docsExtensions.split("|").join(',')}${this.fileSettings.imagesExtensions.split("|").join(',')}`
184
- }else if(this.fileSettings.docsExtensions) {
185
- str = this.fileSettings.docsExtensions.split("|").join(',')
186
- }else if(this.fileSettings.imagesExtensions) {
187
- str = this.fileSettings.imagesExtensions.split("|").join(',')
246
+ let str = "";
247
+ if (this.fileSettings.docsExtensions && this.fileSettings.imagesExtensions) {
248
+ str = `${this.fileSettings.docsExtensions
249
+ .split("|")
250
+ .join(",")}${this.fileSettings.imagesExtensions.split("|").join(",")}`;
251
+ } else if (this.fileSettings.docsExtensions) {
252
+ str = this.fileSettings.docsExtensions.split("|").join(",");
253
+ } else if (this.fileSettings.imagesExtensions) {
254
+ str = this.fileSettings.imagesExtensions.split("|").join(",");
188
255
  }
189
- if(str) {
190
- const arr = str.split(",").map(ext => {
191
- ext = ext && ext.startsWith(".") ? ext : `.${ext}`
192
- return ext
193
- })
194
- str = arr.join(",")
256
+ if (str) {
257
+ const arr = str.split(",").map((ext) => {
258
+ ext = ext && ext.startsWith(".") ? ext : `.${ext}`;
259
+ return ext;
260
+ });
261
+ str = arr.join(",");
195
262
  }
196
- if(this.fileSettings.multiple) return str ? str : "image/*,application/*"
197
- if(this.isDoc) return str ? str : "application/*"
198
- return str ? str : "image/*"
263
+ if (this.fileSettings.multiple) return str ? str : "image/*,application/*";
264
+ if (this.isDoc) return str ? str : "application/*";
265
+ return str ? str : "image/*";
199
266
  },
200
267
  },
201
268
  watch: {
202
269
  externalFiles() {
203
- if(!this.externalFiles.length) return
204
- if(this.externalFiles.length > this.fileSettings.max) {
205
- this.$emit("reset-file-system")
206
- return this.$toasted.global.defaultInfo({ msg: `Limite de ${this.fileSettings.max} arquivos` })
270
+ if (!this.externalFiles.length) return;
271
+ if (this.externalFiles.length > this.fileSettings.max) {
272
+ this.$emit("reset-file-system");
273
+ return this.$toasted.global.defaultInfo({
274
+ msg: `Limite de ${this.fileSettings.max} arquivos`,
275
+ });
207
276
  }
208
- this.file = []
209
- this.externalFilesAux = Array.from(this.externalFiles)
210
- this.externalFilesAux.forEach(files => {
211
- this.file.push(files)
212
- })
213
- this.fileSize = this.file.length
214
- this.multipleFileUpload()
215
- }
277
+ this.file = [];
278
+ this.externalFilesAux = Array.from(this.externalFiles);
279
+ this.externalFilesAux.forEach((files) => {
280
+ this.file.push(files);
281
+ });
282
+ this.fileSize = this.file.length;
283
+ this.multipleFileUpload();
284
+ },
216
285
  },
217
286
  methods: {
218
- openFilesByClip(){
219
- if(this.fileSettings.handleFileClick) return this.$emit("handle-file-click")
220
- if(this.fileSettings.multiple && !this.hasButtonFiles){
221
- return this.openSelectFileHandler('both')
287
+ openFilesByClip() {
288
+ if (this.fileSettings.handleFileClick) return this.$emit("handle-file-click");
289
+ if (this.fileSettings.multiple && !this.hasButtonFiles) {
290
+ return this.openSelectFileHandler("both");
222
291
  }
223
- return this.toggleFiles()
292
+ return this.toggleFiles();
224
293
  },
225
294
  away() {
226
- this.showFilePreview = false
295
+ this.showFilePreview = false;
227
296
  },
228
297
  toggleFiles() {
229
- this.openFiles = !this.openFiles
298
+ this.openFiles = !this.openFiles;
230
299
  },
231
300
  openSelectFileHandler(type) {
232
- if(this.fileSettings.handleFileClick) return this.$emit("handle-file-click")
233
- if(type == "system") return this.$emit("open-file-system")
234
- if(this.fileSettings.multiple){ type = 'both' }
235
- const fileInput = document.querySelector(`#${type}-${this.textId}`)
236
- if(fileInput) fileInput.click()
237
- if(!fileInput) if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError()
301
+ if (this.fileSettings.handleFileClick) return this.$emit("handle-file-click");
302
+ if (type == "system") return this.$emit("open-file-system");
303
+ if (this.fileSettings.multiple) {
304
+ type = "both";
305
+ }
306
+ const fileInput = document.querySelector(`#${type}-${this.textId}`);
307
+ if (fileInput) fileInput.click();
308
+ if (!fileInput)
309
+ if (!document.querySelector(".toasted.toasted-primary.error"))
310
+ this.$toasted.global.defaultError();
238
311
  },
239
312
  isFileValid(type, fileName, fileType) {
240
- if((type == "img" && !this.fileSettings.imagesExtensions) || (type == "doc" && !this.fileSettings.docsExtensions)) {
241
- this.$toasted.global.defaultInfo({ msg: this.dictionary.sem_extensoes_parametrizadas })
242
- this.hasAnyFile = false
243
- return false
313
+ if (
314
+ (type == "img" && !this.fileSettings.imagesExtensions) ||
315
+ (type == "doc" && !this.fileSettings.docsExtensions)
316
+ ) {
317
+ this.$toasted.global.defaultInfo({
318
+ msg: this.dictionary.sem_extensoes_parametrizadas,
319
+ });
320
+ this.hasAnyFile = false;
321
+ return false;
244
322
  }
245
- const extensions = type === "img" ? this.fileSettings.imagesExtensions : this.fileSettings.docsExtensions
246
- const regex = new RegExp("("+extensions+")", "i")
247
- if(regex.test(fileName) || regex.test(fileType)) return true
248
- this.hasAnyFile = false
249
- this.showToastedValidFormats()
250
- return false
323
+ const extensions =
324
+ type === "img"
325
+ ? this.fileSettings.imagesExtensions
326
+ : this.fileSettings.docsExtensions;
327
+ const regex = new RegExp("(" + extensions + ")", "i");
328
+ if (regex.test(fileName) || regex.test(fileType)) return true;
329
+ this.hasAnyFile = false;
330
+ this.showToastedValidFormats();
331
+ return false;
251
332
  },
252
333
  showToastedValidFormats() {
253
- if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
254
- const str = {
255
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
256
- doc: this.fileSettings.docsExtensions.split("|").join(", ")
257
- }
258
- if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
334
+ if (!document.querySelector(".toasted.toasted-primary.error"))
335
+ this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido });
336
+ const str = {
337
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
338
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
339
+ };
340
+ if (!document.querySelector(".toasted.toasted-primary.info"))
341
+ this.$toasted.global.showValidFormats({
342
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
343
+ });
259
344
  },
260
345
  fileUpload(event, type, externalCall) {
261
346
  try {
262
- this.fileSize = 0
263
- if(this.fileFormatError) this.file = []
264
- this.openFiles = false
265
- const filesAux = !externalCall ? event.target.files ? event.target.files : event.dataTransfer.files : event
266
- const isStackable = this.fileSettings.stackFiles && this.fileSettings.multiple
267
- this.file = filesAux.length ? isStackable ? this.file.concat(...filesAux) : filesAux : this.file
268
- if(!this.file.length) return
347
+ this.fileSize = 0;
348
+ if (this.fileFormatError) this.file = [];
349
+ this.openFiles = false;
350
+ const filesAux = !externalCall
351
+ ? event.target.files
352
+ ? event.target.files
353
+ : event.dataTransfer.files
354
+ : event;
355
+ const isStackable = this.fileSettings.stackFiles && this.fileSettings.multiple;
356
+ this.file = filesAux.length
357
+ ? isStackable
358
+ ? this.file.concat(...filesAux)
359
+ : filesAux
360
+ : this.file;
361
+ if (!this.file.length) return;
269
362
 
270
- let sizeInBytes = 0
271
- Array.from(this.file).forEach(file => sizeInBytes += file.size)
272
- const sizeInMb = parseFloat((sizeInBytes / (1024*1024)).toFixed(2))
273
- if(sizeInMb == 0) {
274
- this.file = []
275
- return this.$toasted.global.defaultInfo({ msg: this.dictionary.msg_arquivo_invalido })
363
+ let sizeInBytes = 0;
364
+ Array.from(this.file).forEach((file) => (sizeInBytes += file.size));
365
+ const sizeInMb = parseFloat((sizeInBytes / (1024 * 1024)).toFixed(2));
366
+ if (sizeInMb == 0) {
367
+ this.file = [];
368
+ return this.$toasted.global.defaultInfo({
369
+ msg: this.dictionary.msg_arquivo_invalido,
370
+ });
276
371
  }
277
- if(sizeInMb >= 15) {
278
- this.file = []
279
- return this.$toasted.global.defaultInfo({ msg: `Limite de 15 MB por arquivo` })
372
+ if (sizeInMb >= 15) {
373
+ this.file = [];
374
+ return this.$toasted.global.defaultInfo({ msg: `Limite de 15 MB por arquivo` });
280
375
  }
281
376
 
282
- if(this.file.length > this.fileSettings.max) {
283
- this.file = []
284
- return this.$toasted.global.defaultInfo({ msg: `Limite de ${this.fileSettings.max} arquivos` })
377
+ if (this.file.length > this.fileSettings.max) {
378
+ this.file = [];
379
+ return this.$toasted.global.defaultInfo({
380
+ msg: `Limite de ${this.fileSettings.max} arquivos`,
381
+ });
285
382
  }
286
- this.hasAnyFile = true
287
- this.fileSize = this.file.length
288
- if(!this.fileSettings.multiple) {
289
- this.file = this.file[0]
290
- this.singleFileUpload(type, this.file.name, this.file.type)
291
- }else {
292
- this.multipleFileUpload()
383
+ this.hasAnyFile = true;
384
+ this.fileSize = this.file.length;
385
+ if (!this.fileSettings.multiple) {
386
+ this.file = this.file[0];
387
+ this.singleFileUpload(type, this.file.name, this.file.type);
388
+ } else {
389
+ this.multipleFileUpload();
293
390
  }
294
- }catch(e) {
295
- console.error("Error file upload")
296
- console.error(e)
391
+ } catch (e) {
392
+ console.error("Error file upload");
393
+ console.error(e);
297
394
  }
298
395
  },
299
396
  returnFileType(file) {
300
- if(!this.fileSettings.imagesExtensions && !this.fileSettings.docsExtensions) return ""
397
+ if (!this.fileSettings.imagesExtensions && !this.fileSettings.docsExtensions)
398
+ return "";
301
399
 
302
- const imgRegex = new RegExp("\.("+this.fileSettings.imagesExtensions+")", "i")
303
- if(imgRegex.test(file.name)) return "img"
400
+ const imgRegex = new RegExp("\.(" + this.fileSettings.imagesExtensions + ")", "i");
401
+ if (imgRegex.test(file.name)) return "img";
304
402
 
305
- const docRegex = new RegExp("\.("+this.fileSettings.docsExtensions+")", "i")
306
- if(docRegex.test(file.name)) return "doc"
403
+ const docRegex = new RegExp("\.(" + this.fileSettings.docsExtensions + ")", "i");
404
+ if (docRegex.test(file.name)) return "doc";
307
405
 
308
- return ""
406
+ return "";
309
407
  },
310
408
  multipleFileUpload() {
311
- const hasImgExt = this.fileSettings.imagesExtensions ? true : false
312
- const hasDocExt = this.fileSettings.docsExtensions ? true : false
313
- if(!hasImgExt && !hasDocExt) {
314
- this.file = []
315
- this.fileSize = 0
316
- return this.$toasted.global.defaultInfo({ msg: this.dictionary.sem_extensoes_parametrizadas })
409
+ const hasImgExt = this.fileSettings.imagesExtensions ? true : false;
410
+ const hasDocExt = this.fileSettings.docsExtensions ? true : false;
411
+ if (!hasImgExt && !hasDocExt) {
412
+ this.file = [];
413
+ this.fileSize = 0;
414
+ return this.$toasted.global.defaultInfo({
415
+ msg: this.dictionary.sem_extensoes_parametrizadas,
416
+ });
317
417
  }
318
- let waitForImageLoad = false
319
- let hasAnyInvalidFile = false
320
- this.file = Array.from(this.file)
321
- this.file.forEach(file => {
322
- const singleFileType = this.returnFileType(file)
323
- if(!singleFileType) file.invalid = true
324
- file.imgOrDoc = singleFileType ? singleFileType : ""
325
- if(this.isFileValid(file.imgOrDoc, file.name, file.type)) {
326
- if(file.imgOrDoc == "img") {
418
+ let waitForImageLoad = false;
419
+ let hasAnyInvalidFile = false;
420
+ this.file = Array.from(this.file);
421
+ this.file.forEach((file) => {
422
+ const singleFileType = this.returnFileType(file);
423
+ if (!singleFileType) file.invalid = true;
424
+ file.imgOrDoc = singleFileType ? singleFileType : "";
425
+ if (this.isFileValid(file.imgOrDoc, file.name, file.type)) {
426
+ if (file.imgOrDoc == "img") {
327
427
  const fileReader = new FileReader();
328
- waitForImageLoad = true
329
- fileReader.onload = () => file.src = fileReader.result
330
- fileReader.onloadend = () => this.emitFileVars(true)
331
- fileReader.readAsDataURL(file)
428
+ waitForImageLoad = true;
429
+ fileReader.onload = () => (file.src = fileReader.result);
430
+ fileReader.onloadend = () => this.emitFileVars(true);
431
+ fileReader.readAsDataURL(file);
332
432
  }
333
- if(file.imgOrDoc === "doc") this.isDoc = true
334
- file.invalid = false
335
- this.fileFormatError = !hasAnyInvalidFile ? false : true
336
- }else{
337
- hasAnyInvalidFile = true
338
- file.invalid = true
339
- this.fileFormatError = true
340
- if(hasImgExt && !hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions.split("|").join(", ")}`
341
- if(hasDocExt && hasImgExt) this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions.split("|").join(", ")}`
342
- if(hasImgExt && hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions.split("|").join(", ")} - Documentos: ${this.fileSettings.docsExtensions.split("|").join(", ")}`
433
+ if (file.imgOrDoc === "doc") this.isDoc = true;
434
+ file.invalid = false;
435
+ this.fileFormatError = !hasAnyInvalidFile ? false : true;
436
+ } else {
437
+ hasAnyInvalidFile = true;
438
+ file.invalid = true;
439
+ this.fileFormatError = true;
440
+ if (hasImgExt && !hasDocExt)
441
+ this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions
442
+ .split("|")
443
+ .join(", ")}`;
444
+ if (hasDocExt && hasImgExt)
445
+ this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions
446
+ .split("|")
447
+ .join(", ")}`;
448
+ if (hasImgExt && hasDocExt)
449
+ this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions
450
+ .split("|")
451
+ .join(", ")} - Documentos: ${this.fileSettings.docsExtensions
452
+ .split("|")
453
+ .join(", ")}`;
343
454
  }
344
- })
455
+ });
345
456
 
346
- if(this.fileFormatError) {
347
- this.file = []
348
- this.fileSize = 0
457
+ if (this.fileFormatError) {
458
+ this.file = [];
459
+ this.fileSize = 0;
349
460
  }
350
461
 
351
- if(this.isDoc && !waitForImageLoad) this.emitFileVars()
462
+ if (this.isDoc && !waitForImageLoad) this.emitFileVars();
352
463
  },
353
464
  singleFileUpload(type, fileName, fileType) {
354
- if(this.isFileValid(type, fileName, fileType)) {
355
- const fileReader = new FileReader()
356
- if(type === "img") {
357
- fileReader.onload = () => this.imagePreview = fileReader.result
358
- fileReader.onloadend = () => this.emitFileVars()
359
- fileReader.readAsDataURL(this.file)
465
+ if (this.isFileValid(type, fileName, fileType)) {
466
+ const fileReader = new FileReader();
467
+ if (type === "img") {
468
+ fileReader.onload = () => (this.imagePreview = fileReader.result);
469
+ fileReader.onloadend = () => this.emitFileVars();
470
+ fileReader.readAsDataURL(this.file);
360
471
  }
361
- if(type === "doc") this.isDoc = true
362
-
363
- this.fileFormatError = false
364
- }else {
365
- this.fileFormatError = true
366
- const hasImgExt = this.fileSettings.imagesExtensions ? true : false
367
- const hasDocExt = this.fileSettings.docsExtensions ? true : false
368
- if(hasImgExt && !hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions}`
369
- if(hasDocExt && hasImgExt) this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions}`
370
- if(hasImgExt && hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions} - Documentos: ${this.fileSettings.docsExtensions}`
472
+ if (type === "doc") this.isDoc = true;
473
+
474
+ this.fileFormatError = false;
475
+ } else {
476
+ this.fileFormatError = true;
477
+ const hasImgExt = this.fileSettings.imagesExtensions ? true : false;
478
+ const hasDocExt = this.fileSettings.docsExtensions ? true : false;
479
+ if (hasImgExt && !hasDocExt)
480
+ this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions}`;
481
+ if (hasDocExt && hasImgExt)
482
+ this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions}`;
483
+ if (hasImgExt && hasDocExt)
484
+ this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions} - Documentos: ${this.fileSettings.docsExtensions}`;
371
485
  }
372
486
 
373
- if(this.isDoc) this.emitFileVars()
487
+ if (this.isDoc) this.emitFileVars();
374
488
  },
375
489
  toggleFilePreview() {
376
- if(this.fileSettings.handleFileClick) return this.$emit("handle-file-click")
377
- if(this.fileSettings.handleFilePreview) {
378
- this.emitFileVars()
379
- return this.$emit("handle-file-preview")
490
+ if (this.fileSettings.handleFileClick) return this.$emit("handle-file-click");
491
+ if (this.fileSettings.handleFilePreview) {
492
+ this.emitFileVars();
493
+ return this.$emit("handle-file-preview");
380
494
  }
381
- this.showFilePreview = !this.showFilePreview
382
- if(this.showFilePreview && this.openFiles) this.toggleFiles()
495
+ this.showFilePreview = !this.showFilePreview;
496
+ if (this.showFilePreview && this.openFiles) this.toggleFiles();
383
497
  },
384
498
  emitFileVars() {
385
- const vars = { file: this.file, isDoc: this.isDoc, imagePreview: this.imagePreview, fileFormatError: this.fileFormatError, hasAnyFile: this.hasAnyFile }
499
+ const vars = {
500
+ file: this.file,
501
+ isDoc: this.isDoc,
502
+ imagePreview: this.imagePreview,
503
+ fileFormatError: this.fileFormatError,
504
+ hasAnyFile: this.hasAnyFile,
505
+ };
386
506
 
387
- this.$emit("set-file-vars", vars)
388
- this.$parent.focusTextarea()
507
+ this.$emit("set-file-vars", vars);
508
+ this.$parent.focusTextarea();
389
509
  },
390
510
  deleteSpecificFile(obj) {
391
- const { fileName } = obj
392
- this.file = this.file.filter(file => {
393
- return file.name != fileName
394
- })
511
+ const { fileName } = obj;
512
+ this.file = this.file.filter((file) => {
513
+ return file.name != fileName;
514
+ });
395
515
  this.fileSize = this.file.length;
396
- this.file.length ? this.emitFileVars(true) : this.deleteFile()
516
+ this.file.length ? this.emitFileVars(true) : this.deleteFile();
397
517
  },
398
518
  deleteFile() {
399
519
  this.fileSize = this.file.length;
400
- this.$emit("set-file-vars", { file: [], isDoc: false, imagePreview: "", fileFormatError: false, hasAnyFile: false })
520
+ this.$emit("set-file-vars", {
521
+ file: [],
522
+ isDoc: false,
523
+ imagePreview: "",
524
+ fileFormatError: false,
525
+ hasAnyFile: false,
526
+ });
401
527
 
402
- this.file = []
403
- this.isDoc = false
404
- this.showFilePreview = false
405
- this.hasAnyFile = false
406
- this.imagePreview = ""
407
- this.fileFormatError = false
408
- this.validFileFormats = ""
528
+ this.file = [];
529
+ this.isDoc = false;
530
+ this.showFilePreview = false;
531
+ this.hasAnyFile = false;
532
+ this.imagePreview = "";
533
+ this.fileFormatError = false;
534
+ this.validFileFormats = "";
409
535
  },
410
536
  openImage(imagePreview) {
411
- this.$emit("open-image", !imagePreview ? this.imagePreview : imagePreview)
412
- }
413
- }
414
- }
537
+ this.$emit("open-image", !imagePreview ? this.imagePreview : imagePreview);
538
+ },
539
+ },
540
+ };
415
541
  </script>