fix(uploader): upload to temp bucket and fix initialFiles reactivity to prevent file vanishing
deploy-chabokan / deploy (push) Canceled after 0s
deploy-chabokan / deploy (push) Canceled after 0s
This commit is contained in:
@@ -862,7 +862,7 @@ const saveProperty = async () => {
|
||||
<i class="pi pi-file-pdf text-xl"></i>
|
||||
<span>اسناد و مدارک تصویری / پیدیاف ملک</span>
|
||||
</div>
|
||||
<ImageUploader v-model="documentUrlsWithData" bucketName="documents" :maxFiles="10" />
|
||||
<ImageUploader v-model="documentUrlsWithData" bucketName="temp" :maxFiles="10" />
|
||||
<div v-if="documentUrlsWithData && documentUrlsWithData.length > 0" class="pt-2">
|
||||
<label class="block text-xs font-semibold text-surface-600 dark:text-surface-400 mb-2">فایلها و اسناد بارگذاریشده ({{ documentUrlsWithData.length }} مورد)</label>
|
||||
<ImageGallery v-model="documentUrlsWithData" galleryId="propertyDocumentsGallery" />
|
||||
@@ -904,7 +904,7 @@ const saveProperty = async () => {
|
||||
<i class="pi pi-image text-xl"></i>
|
||||
<span>تصاویر ملک</span>
|
||||
</div>
|
||||
<ImageUploader v-model="mainImageUrlsWithData" bucketName="properties" :maxFiles="10" />
|
||||
<ImageUploader v-model="mainImageUrlsWithData" bucketName="temp" :maxFiles="10" />
|
||||
<div v-if="mainImageUrlsWithData && mainImageUrlsWithData.length > 0" class="pt-2">
|
||||
<label class="block text-xs font-semibold text-surface-600 dark:text-surface-400 mb-2">گالری تصاویر ({{ mainImageUrlsWithData.length }} مورد)</label>
|
||||
<ImageGallery v-model="mainImageUrlsWithData" galleryId="propertyMainImagesGallery" />
|
||||
|
||||
@@ -54,7 +54,7 @@ import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
|
||||
const props = defineProps({
|
||||
bucketName: {
|
||||
type: String,
|
||||
default: 'properties'
|
||||
default: 'temp'
|
||||
},
|
||||
uploadEndpoint: {
|
||||
type: String,
|
||||
@@ -115,7 +115,7 @@ const authHeaders = computed(() => {
|
||||
const resolvedUploadUrl = computed(() => {
|
||||
let endpoint = props.uploadUrl || props.uploadEndpoint;
|
||||
if (!endpoint || endpoint === '/api/files/admin/upload-file') {
|
||||
endpoint = `/api/files/bucket/upload-single-filepond/${props.bucketName}`;
|
||||
endpoint = `/api/files/bucket/upload-single-filepond/${props.bucketName || 'temp'}`;
|
||||
}
|
||||
if (endpoint.startsWith('http://') || endpoint.startsWith('https://')) {
|
||||
return endpoint;
|
||||
@@ -127,7 +127,7 @@ const resolvedUploadUrl = computed(() => {
|
||||
const resolvedDeleteUrl = computed(() => {
|
||||
let endpoint = props.deleteUrl || props.deleteEndpoint;
|
||||
if (!endpoint) {
|
||||
endpoint = `/api/files/bucket/delete-file/${props.bucketName}`;
|
||||
endpoint = `/api/files/bucket/delete-file/${props.bucketName || 'temp'}`;
|
||||
}
|
||||
if (endpoint.startsWith('http://') || endpoint.startsWith('https://')) {
|
||||
return endpoint;
|
||||
@@ -136,21 +136,32 @@ const resolvedDeleteUrl = computed(() => {
|
||||
return `${API_URL}${cleanEndpoint}`;
|
||||
});
|
||||
|
||||
const initialFiles = computed(() => {
|
||||
if (!Array.isArray(props.modelValue)) return [];
|
||||
return props.modelValue
|
||||
.map((item) => {
|
||||
const url = typeof item === 'string' ? item : item.url || item.source || '';
|
||||
if (!url) return null;
|
||||
return {
|
||||
source: url,
|
||||
options: {
|
||||
type: 'local'
|
||||
}
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
});
|
||||
const initialFiles = ref([]);
|
||||
let isInitialLoaded = false;
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
// Only populate initialFiles on first load with existing items (e.g. edit mode)
|
||||
// to avoid resetting active FilePond state during live uploads
|
||||
if (!isInitialLoaded && Array.isArray(val) && val.length > 0) {
|
||||
isInitialLoaded = true;
|
||||
initialFiles.value = val
|
||||
.map((item) => {
|
||||
const url = typeof item === 'string' ? item : item.url || item.source || '';
|
||||
if (!url) return null;
|
||||
return {
|
||||
source: url,
|
||||
options: {
|
||||
type: 'local'
|
||||
}
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// Handle server responses for file processing
|
||||
function handleProcessResponse(response) {
|
||||
|
||||
Reference in New Issue
Block a user