Refactor #5715
parent
4dec38079a
commit
b52defe6d1
|
@ -639,7 +639,7 @@ declare class FileUpload extends ClassComponent<FileUploadProps, FileUploadSlots
|
||||||
*
|
*
|
||||||
* @memberof FileUpload
|
* @memberof FileUpload
|
||||||
*/
|
*/
|
||||||
basicUpload(): void;
|
upload(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div v-if="isAdvanced" :class="cx('root')" v-bind="ptmi('root')">
|
<div v-if="isAdvanced" :class="cx('root')" v-bind="ptmi('root')">
|
||||||
<input ref="fileInput" type="file" @change="onFileSelect" :multiple="multiple" :accept="accept" :disabled="chooseDisabled" v-bind="ptm('input')" />
|
<input ref="fileInput" type="file" @change="onFileSelect" :multiple="multiple" :accept="accept" :disabled="chooseDisabled" v-bind="ptm('input')" />
|
||||||
<div :class="cx('header')" v-bind="ptm('header')">
|
<div :class="cx('header')" v-bind="ptm('header')">
|
||||||
<slot name="header" :files="files" :uploadedFiles="uploadedFiles" :chooseCallback="choose" :uploadCallback="upload" :clearCallback="clear">
|
<slot name="header" :files="files" :uploadedFiles="uploadedFiles" :chooseCallback="choose" :uploadCallback="uploader" :clearCallback="clear">
|
||||||
<Button :label="chooseButtonLabel" :class="chooseButtonClass" :style="style" :disabled="disabled" :unstyled="unstyled" @click="choose" @keydown.enter="choose" @focus="onFocus" @blur="onBlur" :pt="ptm('pcChooseButton')">
|
<Button :label="chooseButtonLabel" :class="chooseButtonClass" :style="style" :disabled="disabled" :unstyled="unstyled" @click="choose" @keydown.enter="choose" @focus="onFocus" @blur="onBlur" :pt="ptm('pcChooseButton')">
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
<slot name="chooseicon">
|
<slot name="chooseicon">
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-if="showUploadButton" :class="cx('pcUploadButton')" :label="uploadButtonLabel" @click="upload" :disabled="uploadDisabled" :unstyled="unstyled" :pt="ptm('pcUploadButton')">
|
<Button v-if="showUploadButton" :class="cx('pcUploadButton')" :label="uploadButtonLabel" @click="uploader" :disabled="uploadDisabled" :unstyled="unstyled" :pt="ptm('pcUploadButton')">
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
<slot name="uploadicon">
|
<slot name="uploadicon">
|
||||||
<component :is="uploadIcon ? 'span' : 'UploadIcon'" :class="[iconProps.class, uploadIcon]" aria-hidden="true" v-bind="ptm('pcUploadButton')['icon']" data-pc-section="uploadbuttonicon" />
|
<component :is="uploadIcon ? 'span' : 'UploadIcon'" :class="[iconProps.class, uploadIcon]" aria-hidden="true" v-bind="ptm('pcUploadButton')['icon']" data-pc-section="uploadbuttonicon" />
|
||||||
|
@ -94,8 +94,8 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
basicUpload() {
|
upload() {
|
||||||
if (this.hasFiles) this.upload();
|
if (this.hasFiles) this.uploader();
|
||||||
},
|
},
|
||||||
onBasicUploaderClick(event) {
|
onBasicUploaderClick(event) {
|
||||||
if (event.button === 0 && !this.hasFiles) this.$refs.fileInput.click();
|
if (event.button === 0 && !this.hasFiles) this.$refs.fileInput.click();
|
||||||
|
@ -130,7 +130,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.auto && this.hasFiles && !this.isFileLimitExceeded()) {
|
if (this.auto && this.hasFiles && !this.isFileLimitExceeded()) {
|
||||||
this.upload();
|
this.uploader();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type !== 'drop' && this.isIE11()) {
|
if (event.type !== 'drop' && this.isIE11()) {
|
||||||
|
@ -142,7 +142,7 @@ export default {
|
||||||
choose() {
|
choose() {
|
||||||
this.$refs.fileInput.click();
|
this.$refs.fileInput.click();
|
||||||
},
|
},
|
||||||
upload() {
|
uploader() {
|
||||||
if (this.customUpload) {
|
if (this.customUpload) {
|
||||||
if (this.fileLimit) {
|
if (this.fileLimit) {
|
||||||
this.uploadedFileCount += this.files.length;
|
this.uploadedFileCount += this.files.length;
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default {
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
upload() {
|
upload() {
|
||||||
this.$refs.fileupload.basicUpload();
|
this.$refs.fileupload.upload();
|
||||||
},
|
},
|
||||||
onUpload() {
|
onUpload() {
|
||||||
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
||||||
|
@ -55,7 +55,7 @@ const toast = useToast();
|
||||||
const fileupload = ref();
|
const fileupload = ref();
|
||||||
|
|
||||||
const upload = () => {
|
const upload = () => {
|
||||||
fileupload.value.basicUpload();
|
fileupload.value.upload();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpload = () => {
|
const onUpload = () => {
|
||||||
|
@ -68,7 +68,7 @@ const onUpload = () => {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
upload() {
|
upload() {
|
||||||
this.$refs.fileupload.basicUpload();
|
this.$refs.fileupload.upload();
|
||||||
},
|
},
|
||||||
onUpload() {
|
onUpload() {
|
||||||
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
||||||
|
|
Loading…
Reference in New Issue