aico-image-editor
Version:
Combine multiple image into and create single combined image
153 lines (146 loc) • 12 kB
HTML
<div x-data="productPicturesSubTab" class="h-100">
<form x-data="dragdrop" enctype="multipart/form-data" x-bind="pictureTrigger" class="h-100">
<div class="h-100">
<div class="block block-transparent h-100 d-flex flex-column">
<div class="block-header pb-0">
<h6 class="block-title" x-text="getTranslatedHTML('media')"></h6>
</div>
<div class="block-content block-content-full d-flex flex-column flex-grow-1 overflow-auto">
<div :class="isUploadBlockVisible ? 'd-lg-none': 'd-block'">
<div class="row g-2 align-items-start mb-3" x-show="$store.canvas.productId || $store.canvas.configuratorId">
<div class="col-12 col-lg">
<div class="position-relative">
<div class="form-group">
<input type="text" class="form-control editor-interface__background__search" :placeholder="getTranslatedHTML('searchPlaceholder')"
x-model="pictureSearch" @keyup="filterPicture()" />
</div>
<span class="position-absolute start-0 top-50 translate-middle-y ms-2 ps-1 text-gray-500">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</span>
</div>
</div>
<div class="col-12">
<button type="button" class="btn btn-primary w-100" @click="showUploadBlock()">
<span x-text="getTranslatedHTML('pictureUploadText')"></span>
</button>
</div>
</div>
<div class="tab-content">
<div class="row gy-3">
<template x-for="mainPicture in mainPictures">
<div class="col-6 mb-2 text-center position-relative editor-interface__hover__remove" :class="mainPicture.hidden ? 'd-none': ''">
<a href="javascript:void(0)" class="position-absolute top-0 end-0 z-index-2 edit_icon me-2 mt-2" x-show="false && mainPicture.cropperData" @click="$store.cropperStore.editExistingImage(mainPicture, 'mainPictures', $store.elements.pictureUploadEL)">
<i class="fa-solid fa-pen-to-square" aria-hidden="true"></i>
</a>
<a href="javascript:void(0)" class="position-absolute top-0 end-0 z-index-2 edit_icon me-2 mt-2" @click="swapWithAIImage(mainPicture)"
x-show="mainPicture.isRemovable && $store.canvas.aiImageSrc"
x-data="tooltip" :title="getTranslatedHTML('swapExistingTitle')">
<i class="fa-solid fa-arrows-rotate"></i>
</a>
<span class="editor-interface__remove cursor-pointer" x-show="mainPicture.isRemovable"
@click="async() => {
await deleteFilesFromServer(mainPicture.id, 'pictures', mainPicture.label);
removePicture(mainPicture);
} ">
<i class="far fa-close" aria-hidden="true"></i></span>
<a class="ratio ratio-1x1 bg-body d-block rounded-4" :class="selectedMainPicture === mainPicture.id ? 'editor-interface__shape__selected': ''" href="javascript:void(0)"
@click="selectMainPicture(mainPicture.id, mainPicture.url)">
<img :id="mainPicture.id" class="img-contain bg-body rounded-4" :src="mainPicture.url" alt="picture"
:class="selectedMainPicture === mainPicture.id ? 'selected': ''" />
</a>
</div>
</template>
<div class="form-check my-3" x-show="subPictures.length">
<input class="form-check-input" type="checkbox" x-model="isSubPicturesVisible" id="show-subpictures" name="show-subpictures" />
<label class="form-check-label" for="show-subpictures" x-text="getTranslatedHTML('subPictureToggleText')"></label>
</div>
<template x-for="subPicture in subPictures">
<template x-if="isSubPicturesVisible">
<div class="col-4 mb-2 text-center position-relative editor-interface__hover__remove" :class="subPicture.hidden ? 'd-none': ''">
<span class="editor-interface__remove cursor-pointer" x-show="subPicture.isRemovable"
@click="async() => {
await deleteFilesFromServer(subPicture.id, 'pictures', subPicture.label);
removePicture(subPicture);
} ">
<i class="far fa-close" aria-hidden="true"></i></span>
<a class="ratio ratio-1x1 bg-body d-block rounded-4" :class="selectedSubPicture === subPicture.id ? 'editor-interface__shape__selected': ''" href="javascript:void(0)"
@click="selectSubPicture(subPicture.id, subPicture.url)">
<img :id="subPicture.id" class="img-contain bg-body rounded-4" :src="subPicture.url" alt="picture"
:class="selectedSubPicture === subPicture.id ? 'selected': ''" />
</a>
</div>
</template>
</template>
</div>
</div>
</div>
<div class="uploadblock innerpopup-block pb-3" :class="isUploadBlockVisible ? 'visibleonmobile': 'd-lg-none'">
<span class="innerpopup-block__drag__handle d-lg-none" @click="hideUploadBlock()">
<a href="javascript:void(0)" class="innerpopup-block__drag__link"></a>
</span>
<template x-if="!sizeValidated || !extensionsValidated">
<div class="alert alert-danger mt-3">
<p class="mb-0" x-show="!sizeValidated" x-text="getTranslatedHTML('fileSizeValidationError', { fileType: 'imgText', fileSize: maxAllowedFileSize + 'MB' })"></p>
<p class="mb-0" x-show="!extensionsValidated" x-text="getTranslatedHTML('fileExtensionValidationError', { fileType: 'picture' })"></p>
</div>
</template>
<div class="droptarget mb-3" :class="dropping ? 'bg-primary-lighter':''"
@dragover.prevent="dragOverHandler($event)"
@dragenter.prevent="dragOverHandler($event)"
@dragleave="dragLeaveHandler()"
@drop.prevent="dropHandler($event,'mainPictures',['jpeg','png','jpg'], $store.elements.pictureUploadEL)">
<div class="position-absolute w-100 h-100 start-0 top-0 d-flex flex-column align-items-center justify-content-center"
@mainPictures-uploaded.window="() => {
tempPictures.push({
name: $event.detail.name,
label: $event.detail.name,
url: $event.detail.url
})
}">
<template x-if="!tempPictures.length">
<div class="text-center p-2 fs-sm">
<span class="mb-1" x-text="getTranslatedHTML('graphicUploadText')"></span>
<p class="mb-0" x-text="getTranslatedHTML('extensionTextDisplay', { fileSize: maxAllowedFileSize + 'MB', extensions: '.png, .jpg, .jpeg' })"></p>
</div>
</template>
<template x-for="tempPicture in tempPictures">
<div class="d-flex align-items-center justify-content-center flex-wrap">
<div class="image-upload-content mx-3">
<img class="img-fluid image-upload-shape" :class="tempPicture.class" :src="tempPicture.url" :alt="tempPicture.name" :id="tempPicture.id"/>
</div>
<div>
<h6 x-text="tempPicture.label" class="mt-1 mb-0 image-upload-name"></h6>
<p class="mb-0" x-text="getTranslatedHTML('fileUploadSucess')"></p>
</div>
</div>
</template>
<input type="file" class="form-control position-absolute w-100 h-100 opacity-0" id="main-image-upload"
@change="() => {
fileUploaded($event,'mainPictures',['jpeg','png','jpg'], $el);
}"
@click="removeTempPictures()"
x-init="$store.elements.pictureUploadEL = $el"
accept=".png,.jpg,.jpeg"/>
</div>
</div>
<div class="d-flex justify-content-between align-items-center">
<div class="d-none d-lg-flex">
<div class="img-avatar img-avatar24 me-2" >
<div class="ratio ratio-1x1">
<a class="rounded-circle text-body d-flex justify-content-center align-items-center" href="javascript:void(0)"
style="padding-top: 2px;">
<i class="fa-solid fa-arrow-left fa-sm"></i></a>
</div>
</div>
<div>
<a href="javascript:void(0)" class="text-body" @click="hideUploadBlock()"
x-text="getTranslatedHTML('backToPictures')"></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>