ngx-wapp-components 3.2.28-alpha.4 → 3.2.28-alpha.5
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.
|
@@ -6865,6 +6865,7 @@ class WImageFileUploaderComponent {
|
|
|
6865
6865
|
this.isProcessingExternalQueue = false;
|
|
6866
6866
|
this.externalImageQueue = [];
|
|
6867
6867
|
this.externalOpenedCropDialogs = 0;
|
|
6868
|
+
this.openedCropperImageNames = new Set();
|
|
6868
6869
|
this.carouselImagesResponsiveOptions = [
|
|
6869
6870
|
{
|
|
6870
6871
|
breakpoint: '1024px',
|
|
@@ -7029,15 +7030,17 @@ class WImageFileUploaderComponent {
|
|
|
7029
7030
|
}, this.timelife);
|
|
7030
7031
|
}
|
|
7031
7032
|
if (this.allowMultipleImages == true) {
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
if (
|
|
7036
|
-
|
|
7033
|
+
const selectedNamesInBatch = new Set();
|
|
7034
|
+
event.currentFiles.forEach((file) => {
|
|
7035
|
+
const normalizedName = this.sanitizeFileName(file.name);
|
|
7036
|
+
if (selectedNamesInBatch.has(normalizedName)) {
|
|
7037
|
+
return;
|
|
7037
7038
|
}
|
|
7038
|
-
|
|
7039
|
-
|
|
7039
|
+
if (this.isImageNameAlreadyQueuedOrUploaded(file.name)) {
|
|
7040
|
+
return;
|
|
7040
7041
|
}
|
|
7042
|
+
selectedNamesInBatch.add(normalizedName);
|
|
7043
|
+
this.openModalCropper(file, event.originalEvent);
|
|
7041
7044
|
});
|
|
7042
7045
|
if (this.imageUploadConfig.allowAuto == false) {
|
|
7043
7046
|
this.fileUpload.files = [];
|
|
@@ -7121,6 +7124,11 @@ class WImageFileUploaderComponent {
|
|
|
7121
7124
|
});
|
|
7122
7125
|
}
|
|
7123
7126
|
openModalCropper(fileBlob, event, fromExternal = false) {
|
|
7127
|
+
const fileName = this.extractImageName(fileBlob);
|
|
7128
|
+
const normalizedFileName = fileName ? this.sanitizeFileName(fileName) : '';
|
|
7129
|
+
if (normalizedFileName) {
|
|
7130
|
+
this.openedCropperImageNames.add(normalizedFileName);
|
|
7131
|
+
}
|
|
7124
7132
|
const ref = this.dialogService.open(WImageCropperComponent, {
|
|
7125
7133
|
header: this.imageUploadConfig.croppedDialogTranslations?.modal.header,
|
|
7126
7134
|
width: '70rem',
|
|
@@ -7165,6 +7173,9 @@ class WImageFileUploaderComponent {
|
|
|
7165
7173
|
}
|
|
7166
7174
|
}
|
|
7167
7175
|
}
|
|
7176
|
+
if (normalizedFileName) {
|
|
7177
|
+
this.openedCropperImageNames.delete(normalizedFileName);
|
|
7178
|
+
}
|
|
7168
7179
|
if (fromExternal) {
|
|
7169
7180
|
this.externalOpenedCropDialogs = Math.max(0, this.externalOpenedCropDialogs - 1);
|
|
7170
7181
|
if (this.externalImageQueue.length > 0) {
|
|
@@ -7196,7 +7207,22 @@ class WImageFileUploaderComponent {
|
|
|
7196
7207
|
if (!this.allowMultipleImages && queue.length > 1) {
|
|
7197
7208
|
queue.splice(1);
|
|
7198
7209
|
}
|
|
7199
|
-
|
|
7210
|
+
const namesInCurrentBatch = new Set();
|
|
7211
|
+
const filesToProcess = queue.filter(file => {
|
|
7212
|
+
const normalizedName = this.sanitizeFileName(file.name);
|
|
7213
|
+
if (namesInCurrentBatch.has(normalizedName)) {
|
|
7214
|
+
return false;
|
|
7215
|
+
}
|
|
7216
|
+
if (this.isImageNameAlreadyQueuedOrUploaded(file.name)) {
|
|
7217
|
+
return false;
|
|
7218
|
+
}
|
|
7219
|
+
namesInCurrentBatch.add(normalizedName);
|
|
7220
|
+
return true;
|
|
7221
|
+
});
|
|
7222
|
+
if (filesToProcess.length === 0) {
|
|
7223
|
+
return;
|
|
7224
|
+
}
|
|
7225
|
+
this.externalImageQueue.push(...filesToProcess);
|
|
7200
7226
|
if (!this.isProcessingExternalQueue) {
|
|
7201
7227
|
this.processNextExternalImage();
|
|
7202
7228
|
}
|
|
@@ -7211,6 +7237,44 @@ class WImageFileUploaderComponent {
|
|
|
7211
7237
|
this.externalOpenedCropDialogs++;
|
|
7212
7238
|
this.openModalCropper(file, undefined, true);
|
|
7213
7239
|
}
|
|
7240
|
+
isImageNameAlreadyQueuedOrUploaded(fileName) {
|
|
7241
|
+
const normalizedName = this.sanitizeFileName(fileName);
|
|
7242
|
+
if (this.openedCropperImageNames.has(normalizedName)) {
|
|
7243
|
+
return true;
|
|
7244
|
+
}
|
|
7245
|
+
const existsInUploaded = this.imagesAlreadyUploaded?.some((image) => {
|
|
7246
|
+
const imageName = this.extractImageName(image);
|
|
7247
|
+
return imageName ? this.sanitizeFileName(imageName) === normalizedName : false;
|
|
7248
|
+
});
|
|
7249
|
+
if (existsInUploaded) {
|
|
7250
|
+
return true;
|
|
7251
|
+
}
|
|
7252
|
+
const existsInCropper = this.cropperImages?.some((image) => {
|
|
7253
|
+
const imageName = this.extractImageName(image);
|
|
7254
|
+
return imageName ? this.sanitizeFileName(imageName) === normalizedName : false;
|
|
7255
|
+
});
|
|
7256
|
+
if (existsInCropper) {
|
|
7257
|
+
return true;
|
|
7258
|
+
}
|
|
7259
|
+
return this.externalImageQueue?.some((queuedFile) => this.sanitizeFileName(queuedFile.name) === normalizedName) ?? false;
|
|
7260
|
+
}
|
|
7261
|
+
extractImageName(image) {
|
|
7262
|
+
if (!image) {
|
|
7263
|
+
return '';
|
|
7264
|
+
}
|
|
7265
|
+
if (typeof image.name === 'string' && image.name.length > 0) {
|
|
7266
|
+
return image.name;
|
|
7267
|
+
}
|
|
7268
|
+
if (typeof image.fileBase64 === 'string' && image.fileBase64.length > 0) {
|
|
7269
|
+
const lastSegment = image.fileBase64.split('/').pop();
|
|
7270
|
+
return lastSegment ?? '';
|
|
7271
|
+
}
|
|
7272
|
+
if (typeof image === 'string' && image.length > 0) {
|
|
7273
|
+
const lastSegment = image.split('/').pop();
|
|
7274
|
+
return lastSegment ?? '';
|
|
7275
|
+
}
|
|
7276
|
+
return '';
|
|
7277
|
+
}
|
|
7214
7278
|
mapToObjectB64(images) {
|
|
7215
7279
|
if (Array.isArray(images) == false) {
|
|
7216
7280
|
return [{
|