Pridan fotoeditor
This commit is contained in:
+20
-5
@@ -1,6 +1,7 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {DELETE_PHOTO, EDIT_PHOTO, ROTATE_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
|
||||
import {ADJUST_PHOTO, CHANGE_PHOTO_ORIENTATION, DELETE_PHOTO, EDIT_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
|
||||
import {PHOTO_DETAIL} from "src/graphql/queries/photo";
|
||||
|
||||
export const usePhotosStore = defineStore('Photos', {
|
||||
state: () => ({
|
||||
@@ -8,6 +9,11 @@ export const usePhotosStore = defineStore('Photos', {
|
||||
}),
|
||||
|
||||
actions: {
|
||||
fetchDetail(id) {
|
||||
return apolloWrapper.query(PHOTO_DETAIL, {id}).then(({data}) => {
|
||||
return data.photo;
|
||||
});
|
||||
},
|
||||
upload(flightId, formData) {
|
||||
if (!flightId) {
|
||||
console.error("No flightId specified for photo upload! Aborting");
|
||||
@@ -35,16 +41,25 @@ export const usePhotosStore = defineStore('Photos', {
|
||||
return data.editPhoto;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
rotate(id, angle) {
|
||||
|
||||
changeOrientation(id, direction) {
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(ROTATE_PHOTO, {id, angle}).then(({data}) => {
|
||||
return data.rotatePhoto;
|
||||
return apolloWrapper.mutate(CHANGE_PHOTO_ORIENTATION, {id, direction}).then(({data}) => {
|
||||
return data.changeOrientation;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
|
||||
adjust(id, adjustment) {
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(ADJUST_PHOTO, {id, adjustment}).then(({data}) => {
|
||||
return data.adjustPhoto;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
delete(photoId) {
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(DELETE_PHOTO, {id: photoId}).then(({data}) => {
|
||||
return data.deletePhoto;
|
||||
});
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user