267 lines
9.6 KiB
Vue
267 lines
9.6 KiB
Vue
<script setup lang="ts">
|
|
import { Head, useForm, Link as InertiaLink } from '@inertiajs/vue3';
|
|
import { route } from 'ziggy-js';
|
|
import { defineProps } from 'vue';
|
|
|
|
defineOptions({
|
|
layout: (props: any) => ({
|
|
breadcrumbs: [
|
|
{
|
|
title: 'Dynamics',
|
|
href: route('dynamics.index'),
|
|
},
|
|
{
|
|
title: props.dynamic.name,
|
|
href: route('dynamics.show', props.dynamic.id),
|
|
},
|
|
{
|
|
title: props.ledger.name,
|
|
href: route('dynamics.ledgers.show', [props.dynamic.id, props.ledger.id]),
|
|
},
|
|
{
|
|
title: 'Predefined Mutations',
|
|
href: route('dynamics.ledgers.predefined-mutations.index', [props.dynamic.id, props.ledger.id]),
|
|
},
|
|
],
|
|
}),
|
|
});
|
|
|
|
const props = defineProps<{
|
|
dynamic: {
|
|
id: number;
|
|
name: string;
|
|
};
|
|
ledger: {
|
|
id: number;
|
|
name: string;
|
|
};
|
|
predefined_mutations: Array<{
|
|
id: number;
|
|
name: string;
|
|
description: string;
|
|
amount: number;
|
|
uuid: string;
|
|
}>;
|
|
}>();
|
|
|
|
const form = useForm({
|
|
name: '',
|
|
description: '',
|
|
amount: 0,
|
|
});
|
|
|
|
function submit() {
|
|
form.post(route('dynamics.ledgers.predefined-mutations.store', [props.dynamic.id, props.ledger.id]), {
|
|
onSuccess: () => form.reset(),
|
|
});
|
|
}
|
|
|
|
function destroy(uuid: string) {
|
|
if (confirm('Are you sure you want to delete this predefined mutation?')) {
|
|
const deleteForm = useForm({});
|
|
deleteForm.delete(route('dynamics.ledgers.predefined-mutations.destroy', [props.dynamic.id, props.ledger.id, uuid]));
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Head title="Predefined Mutations" />
|
|
|
|
<div class="c-predefined-mutations">
|
|
<div class="c-predefined-mutations__container">
|
|
<div class="c-predefined-mutations__card">
|
|
<div class="c-predefined-mutations__body">
|
|
<h3 class="c-predefined-mutations__title">
|
|
Predefined Mutations for {{ ledger.name }}
|
|
</h3>
|
|
|
|
<div class="c-predefined-mutations__list">
|
|
<div
|
|
v-for="mutation in predefined_mutations"
|
|
:key="mutation.id"
|
|
class="c-predefined-mutations__item"
|
|
>
|
|
<div class="c-predefined-mutations__item-details">
|
|
<h4 class="c-predefined-mutations__item-name">
|
|
{{ mutation.name }}
|
|
</h4>
|
|
<p class="c-predefined-mutations__item-description">
|
|
{{ mutation.description }}
|
|
</p>
|
|
</div>
|
|
<div class="flex items-center gap-6">
|
|
<div class="c-predefined-mutations__item-amount">
|
|
{{ mutation.amount }}
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<InertiaLink
|
|
:href="route('dynamics.ledgers.predefined-mutations.edit', [dynamic.id, ledger.id, mutation.uuid])"
|
|
class="c-predefined-mutations__edit-btn"
|
|
>
|
|
Edit
|
|
</InertiaLink>
|
|
<button
|
|
@click="destroy(mutation.uuid)"
|
|
class="c-predefined-mutations__delete-btn"
|
|
>
|
|
Delete
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="c-predefined-mutations__card mt-8">
|
|
<div class="c-predefined-mutations__body">
|
|
<h3 class="c-predefined-mutations__title">
|
|
Create New Predefined Mutation
|
|
</h3>
|
|
|
|
<form
|
|
@submit.prevent="submit"
|
|
class="c-predefined-mutations__form"
|
|
>
|
|
<div class="c-predefined-mutations__field">
|
|
<label
|
|
for="name"
|
|
class="c-predefined-mutations__label"
|
|
>Name</label
|
|
>
|
|
<input
|
|
v-model="form.name"
|
|
id="name"
|
|
type="text"
|
|
class="c-predefined-mutations__input"
|
|
/>
|
|
</div>
|
|
|
|
<div class="c-predefined-mutations__field">
|
|
<label
|
|
for="description"
|
|
class="c-predefined-mutations__label"
|
|
>Description</label
|
|
>
|
|
<textarea
|
|
v-model="form.description"
|
|
id="description"
|
|
rows="4"
|
|
class="c-predefined-mutations__textarea"
|
|
></textarea>
|
|
</div>
|
|
|
|
<div class="c-predefined-mutations__field">
|
|
<label
|
|
for="amount"
|
|
class="c-predefined-mutations__label"
|
|
>Amount</label
|
|
>
|
|
<input
|
|
v-model="form.amount"
|
|
id="amount"
|
|
type="number"
|
|
class="c-predefined-mutations__input"
|
|
/>
|
|
</div>
|
|
|
|
<div class="c-predefined-mutations__actions">
|
|
<button
|
|
type="submit"
|
|
:disabled="form.processing"
|
|
class="c-predefined-mutations__submit-btn"
|
|
>
|
|
Create
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
@reference "../../../../css/app.css";
|
|
|
|
.c-predefined-mutations {
|
|
@apply py-12;
|
|
}
|
|
|
|
.c-predefined-mutations__container {
|
|
@apply mx-auto max-w-7xl sm:px-6 lg:px-8;
|
|
}
|
|
|
|
.c-predefined-mutations__card {
|
|
@apply overflow-hidden bg-white shadow-sm sm:rounded-lg dark:bg-gray-800;
|
|
}
|
|
|
|
.c-predefined-mutations__body {
|
|
@apply p-6 text-gray-900 dark:text-gray-100;
|
|
}
|
|
|
|
.c-predefined-mutations__title {
|
|
@apply text-lg font-medium;
|
|
}
|
|
|
|
.c-predefined-mutations__list {
|
|
@apply mt-6 space-y-4;
|
|
}
|
|
|
|
.c-predefined-mutations__item {
|
|
@apply flex items-center justify-between rounded-lg border p-4 dark:border-gray-700;
|
|
}
|
|
|
|
.c-predefined-mutations__item-details {
|
|
@apply flex-1;
|
|
}
|
|
|
|
.c-predefined-mutations__item-name {
|
|
@apply font-semibold;
|
|
}
|
|
|
|
.c-predefined-mutations__item-description {
|
|
@apply text-sm text-gray-600 dark:text-gray-400;
|
|
}
|
|
|
|
.c-predefined-mutations__item-amount {
|
|
@apply text-lg font-semibold;
|
|
}
|
|
|
|
.c-predefined-mutations__edit-btn {
|
|
@apply inline-flex cursor-pointer items-center rounded border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-semibold text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600;
|
|
}
|
|
|
|
.c-predefined-mutations__delete-btn {
|
|
@apply inline-flex cursor-pointer items-center rounded border border-transparent bg-red-600 px-2.5 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-red-500 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2;
|
|
}
|
|
|
|
.c-predefined-mutations__form {
|
|
@apply mt-6 space-y-6;
|
|
}
|
|
|
|
.c-predefined-mutations__field {
|
|
@apply block;
|
|
}
|
|
|
|
.c-predefined-mutations__label {
|
|
@apply block text-sm font-medium text-gray-700 dark:text-gray-300;
|
|
}
|
|
|
|
.c-predefined-mutations__input {
|
|
@apply mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
|
|
}
|
|
|
|
.c-predefined-mutations__textarea {
|
|
@apply mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600;
|
|
}
|
|
|
|
.c-predefined-mutations__actions {
|
|
@apply flex items-center gap-4;
|
|
}
|
|
|
|
.c-predefined-mutations__submit-btn {
|
|
@apply inline-flex items-center rounded-md border border-transparent bg-gray-800 px-4 py-2 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out hover:bg-gray-700 focus:bg-gray-700 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-none active:bg-gray-900 dark:bg-gray-200 dark:text-gray-800 dark:hover:bg-white dark:focus:bg-white dark:focus:ring-offset-gray-800 dark:active:bg-gray-300;
|
|
}
|
|
</style>
|