You've already forked gun-manager-frontend
REALLY FUCKING FIXED
This commit is contained in:
@@ -62,22 +62,24 @@
|
|||||||
<Textarea v-model="gun.notes"/>
|
<Textarea v-model="gun.notes"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full mt-5">
|
<div class="w-full mt-5" v-if="gun.id">
|
||||||
<div class="flex gap-2" style="flex-direction: column">
|
<div class="flex gap-2" style="flex-direction: column">
|
||||||
<label for="value_amount">Photos</label>
|
<label for="value_amount">Photos</label>
|
||||||
<FileUpload
|
<FileUpload
|
||||||
:showUploadButton="gun.id === false"
|
|
||||||
:showCancelButton="false"
|
:showCancelButton="false"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
:multiple="gun.id === null"
|
multiple
|
||||||
|
:url="`${url}/gun/photo/${gun.id}`"
|
||||||
|
@upload="$emit('upload')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full mt-5">
|
<div class="w-full mt-5">
|
||||||
<Button @click="$emit('save')" class="p-button-success" icon="fa-sharp fa-light fa-floppy-disk" label="Save"/>
|
<Button :loading="loading" @click="$emit('save')" class="p-button-success" icon="fa-sharp fa-light fa-floppy-disk" label="Save"/>
|
||||||
<router-link to="/guns">
|
<router-link to="/guns">
|
||||||
<Button class="p-button-warning ml-3" icon="fa-sharp fa-light fa-times" label="Cancel"/>
|
<Button class="p-button-warning ml-3" icon="fa-sharp fa-light fa-times" label="Cancel"/>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<Button @click="deleteGun" v-if="gun.id" class="p-button-danger ml-3" icon="fa-sharp fa-light fa-trash" label="Delete"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -85,13 +87,33 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from "vue";
|
import {defineComponent} from "vue"
|
||||||
|
import axios from "axios"
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: () => {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
gun: {
|
gun: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
url() {
|
||||||
|
return import.meta.env.VITE_API
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
deleteGun() {
|
||||||
|
axios.delete(`${import.meta.env.VITE_API}/gun/${this.gun.id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.$router.push('/guns')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="md:w-2/3">
|
<div class="md:w-2/3">
|
||||||
<GunForm @save="save" :gun="gun" />
|
<GunForm :loading="loading" @save="save" :gun="gun" :photos="photos" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -11,6 +11,8 @@ import {Response} from "../types/Response";
|
|||||||
import GunForm from "../components/GunForm.vue";
|
import GunForm from "../components/GunForm.vue";
|
||||||
|
|
||||||
interface Data {
|
interface Data {
|
||||||
|
loading: boolean
|
||||||
|
photos: Array<File>
|
||||||
gun: {
|
gun: {
|
||||||
make: string
|
make: string
|
||||||
model: string
|
model: string
|
||||||
@@ -25,6 +27,7 @@ interface Data {
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {GunForm},
|
components: {GunForm},
|
||||||
data: (): Data => ({
|
data: (): Data => ({
|
||||||
|
loading: false,
|
||||||
gun: {
|
gun: {
|
||||||
make: "",
|
make: "",
|
||||||
model: "",
|
model: "",
|
||||||
@@ -33,12 +36,14 @@ export default defineComponent({
|
|||||||
value_amount: 0,
|
value_amount: 0,
|
||||||
date_purchased: "",
|
date_purchased: "",
|
||||||
notes: ""
|
notes: ""
|
||||||
}
|
},
|
||||||
|
photos: []
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
save() {
|
save() {
|
||||||
|
this.loading = true
|
||||||
axios.post(import.meta.env.VITE_API + '/gun', this.gun).then((r: Response<{ id: number }>) => {
|
axios.post(import.meta.env.VITE_API + '/gun', this.gun).then((r: Response<{ id: number }>) => {
|
||||||
this.$router.push('/gun/' + r.data.payload.id)
|
this.$router.push(`/edit/${r.data.payload.id}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full flex flex-row flex-wrap justify-around">
|
<div class="w-full flex flex-row flex-wrap justify-around">
|
||||||
<div class="w-full lg:w-1/2 m-5">
|
<div class="w-full lg:w-1/2 m-5">
|
||||||
<GunForm @save="save" :gun="gun"/>
|
<GunForm @upload="getGun" v-if="gun" @save="save" :gun="gun"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-10 w-full lg:w-1/2 m-5">
|
<div class="mt-10 w-full lg:w-1/2 m-5">
|
||||||
<Card>
|
<Card>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
{{ photo.file_name }}
|
{{ photo.file_name }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div @click="deletePhoto(photo.id)">
|
||||||
<i style="color: red;" class="fa-regular fa-2x fa-trash"></i>
|
<i style="color: red;" class="fa-regular fa-2x fa-trash"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,6 +51,12 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
deletePhoto(id: number) {
|
||||||
|
axios.delete(import.meta.env.VITE_API + `/gun/photo/${id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.getGun()
|
||||||
|
})
|
||||||
|
},
|
||||||
getGun() {
|
getGun() {
|
||||||
axios.get(import.meta.env.VITE_API + `/gun/${this.$route.params.id}`)
|
axios.get(import.meta.env.VITE_API + `/gun/${this.$route.params.id}`)
|
||||||
.then((r: Response<Guns>) => {
|
.then((r: Response<Guns>) => {
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
.p-button {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user