Commit the working vertical slices for inventory image processing and the Sale workflow, including Sale history, audited voiding, multi-item persistence, admin UI, migrations, documentation, and tests.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
retryImageProcessing,
|
||||
setPrimaryImage,
|
||||
updateImageAltText,
|
||||
uploadAdminImage,
|
||||
} from '@/services/admin-image-service.js';
|
||||
|
||||
function csrfToken() {
|
||||
@@ -35,12 +36,30 @@ export function useAdminImages(inventoryItemId) {
|
||||
finally { isSaving.value = false; }
|
||||
}
|
||||
|
||||
async function upload(file) {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
const image = new Image();
|
||||
image.src = objectUrl;
|
||||
try {
|
||||
await image.decode();
|
||||
await apply((token) => uploadAdminImage(inventoryItemId, file, {
|
||||
width: image.naturalWidth,
|
||||
height: image.naturalHeight,
|
||||
altText: file.name,
|
||||
isPrimary: images.value.length === 0,
|
||||
}, token));
|
||||
} finally {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
images,
|
||||
isLoading,
|
||||
isSaving,
|
||||
error,
|
||||
load,
|
||||
upload,
|
||||
reorder: (imageId, sortOrder) => apply((token) => reorderImage(imageId, sortOrder, token)),
|
||||
setPrimary: (imageId) => apply((token) => setPrimaryImage(imageId, token)),
|
||||
updateAltText: (imageId, altText) => apply((token) => updateImageAltText(imageId, altText, token)),
|
||||
|
||||
Reference in New Issue
Block a user