shift-build-2464
Nadim Salloum 2021-06-03 22:39:18 +03:00
parent bddb7b9fe5
commit ef36a3df5e
26 changed files with 686 additions and 499 deletions

View File

@ -85,7 +85,7 @@ class CarController extends Controller
'country' => $contact->country, 'country' => $contact->country,
'company' => $contact->company, 'company' => $contact->company,
'email' => $contact->email, 'email' => $contact->email,
'link' => route('contacts.edit', $contact), 'link' => route('contacts.show', $contact),
], ],
'link' => route('contracts.show', $contract), 'link' => route('contracts.show', $contract),
]; ];

View File

@ -2,9 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Car;
use Inertia\Inertia; use Inertia\Inertia;
use App\Models\Contact; use App\Models\Contact;
use App\Models\Car; use App\Models\Contract;
use App\Enums\InsuranceType; use App\Enums\InsuranceType;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
@ -12,11 +13,6 @@ use Illuminate\Support\Facades\Redirect;
class ContactController extends Controller class ContactController extends Controller
{ {
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request) public function index(Request $request)
{ {
return $this->renderContactsList($request, Contact::query(), 'Contacts/Index'); return $this->renderContactsList($request, Contact::query(), 'Contacts/Index');
@ -54,7 +50,7 @@ class ContactController extends Controller
'email' => $contact->email, 'email' => $contact->email,
'address' => $contact->address, 'address' => $contact->address,
'fullCity' => $contact->fullCity, 'fullCity' => $contact->fullCity,
'link' => route('contacts.edit', $contact), 'link' => route('contacts.show', $contact),
'deleted_at' => $contact->deleted_at, 'deleted_at' => $contact->deleted_at,
]), ]),
]); ]);
@ -85,22 +81,11 @@ class ContactController extends Controller
return 'name'; return 'name';
} }
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create() public function create()
{ {
return Inertia::render('Contacts/Create'); return Inertia::render('Contacts/Create');
} }
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request) public function store(Request $request)
{ {
$contact = Contact::create( $contact = Contact::create(
@ -118,15 +103,9 @@ class ContactController extends Controller
]) ])
); );
return Redirect::route('contacts.edit', $contact); return Redirect::route('contacts.show', $contact);
} }
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Contact $contact
* @return \Illuminate\Http\Response
*/
public function edit(Contact $contact) public function edit(Contact $contact)
{ {
return Inertia::render('Contacts/Edit', [ return Inertia::render('Contacts/Edit', [
@ -144,36 +123,68 @@ class ContactController extends Controller
'city' => $contact->city, 'city' => $contact->city,
'country' => $contact->country, 'country' => $contact->country,
'deleted_at' => $contact->deleted_at, 'deleted_at' => $contact->deleted_at,
'bought_cars' => $contact->buyContracts()
->with('car')
->paginate(10)
->through(fn ($contract) => [
'date' => $contract->date,
'price' => $contract->price,
'name' => $contract->car->name,
'link' => route('cars.edit', $contract->car),
'insurance_type' => InsuranceType::fromValue((int)$contract->insurance_type)->key,
]),
'sold_cars' => $contact->sellContracts()
->with('car')
->paginate(10)
->through(fn ($contract) => [
'date' => $contract->date,
'price' => $contract->price,
'name' => $contract->car->name,
'link' => route('cars.edit', $contract->car),
]),
] ]
]); ]);
} }
/** public function show(Contact $contact)
* Update the specified resource in storage. {
* return Inertia::render('Contacts/Show', [
* @param \Illuminate\Http\Request $request 'contact' => [
* @param \App\Models\Contact $contact 'id' => $contact->id,
* @return \Illuminate\Http\Response 'firstname' => $contact->firstname,
*/ 'lastname' => $contact->lastname,
'company' => $contact->company,
'title' => $contact->title,
'email' => $contact->email,
'notes' => $contact->notes,
'phone' => $contact->phone,
'address' => $contact->address,
'zip' => $contact->zip,
'city' => $contact->city,
'country' => $contact->country,
'deleted_at' => $contact->deleted_at,
'buy_contracts' => $contact->buyContracts()
->with('car')
->paginate(50)
->through(fn ($contract) => $this->getContractFields($contract)),
'sell_contracts' => $contact->sellContracts()
->with('car')
->paginate(50)
->through(fn ($contract) => $this->getContractFields($contract)),
]
]);
}
private function getContractFields(?Contract $contract) {
if (!$contract) {
return null;
}
$car = $contract->car;
return [
'id' => $contract->id,
'date' => $contract->date_formatted,
'price' => $contract->price->format(),
'type' => $contract->type,
'is_sell_contract' => $contract->isSellContract(),
'insurance_type' => $contract->insurance_type ? InsuranceType::fromValue((int)$contract->insurance_type)->key : null,
'car' => [
'id' => $car->id,
'stammnummer' => $car->stammnummer,
'vin' => $car->vin,
'name' => $car->name,
'initial_date' => $car->initial_date_formatted,
'colour' => $car->colour,
'last_check_date' => $car->last_check_date_formatted,
'kilometers' => $car->kilometers,
'known_damage' => $car->known_damage,
'notes' => $car->notes,
'link' => route('cars.show', $car),
],
'link' => route('contracts.show', $contract),
];
}
public function update(Request $request, Contact $contact) public function update(Request $request, Contact $contact)
{ {
$contact->update( $contact->update(
@ -191,15 +202,9 @@ class ContactController extends Controller
]) ])
); );
return Redirect::back()->with('success', 'Kontakt geändert.'); return Redirect::route('contacts.show', $contact)->with('success', 'Kontakt geändert.');
} }
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Contact $contact
* @return \Illuminate\Http\Response
*/
public function destroy(Contact $contact) public function destroy(Contact $contact)
{ {
$contact->delete(); $contact->delete();

View File

@ -185,7 +185,7 @@ class ContractController extends Controller
'country' => $contract->contact->country, 'country' => $contract->contact->country,
'company' => $contract->contact->company, 'company' => $contract->contact->company,
'email' => $contract->contact->email, 'email' => $contract->contact->email,
'link' => route('contacts.edit', $contract->contact), 'link' => route('contacts.show', $contract->contact),
], ],
'car' => [ 'car' => [
'id' => $contract->car->id, 'id' => $contract->car->id,

741
public/js/app.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,42 +4,40 @@
{{ car.name }} {{ car.name }}
</div> </div>
<div class="grid grid-cols-4 gap-2 w-full"> <div class="grid grid-cols-4 gap-2 w-full">
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.stammnummer" class="col-span-1 xs:col-span-2">
Stammnummer Stammnummer
</div> </div>
<div class="col-span-3 xs:col-span-2"> <div v-if="!hideEmpty || car.stammnummer" class="col-span-3 xs:col-span-2">
{{ car.stammnummer ? car.stammnummer : '-' }} {{ car.stammnummer ? car.stammnummer : '-' }}
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.vin" class="col-span-1 xs:col-span-2">
Chassisnummer Chassisnummer
</div> </div>
<div class="col-span-3 xs:col-span-2"> <div v-if="!hideEmpty || car.vin" class="col-span-3 xs:col-span-2">
{{ car.vin ? car.vin : '-'}} {{ car.vin ? car.vin : '-'}}
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.colour" class="col-span-1 xs:col-span-2">
Farbe Farbe
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.colour" class="col-span-1 xs:col-span-2">
{{ car.colour ? car.colour : '-' }} {{ car.colour ? car.colour : '-' }}
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.kilometers" class="col-span-1 xs:col-span-2">
Kilometerstand Kilometerstand
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.kilometers" class="col-span-1 xs:col-span-2">
{{ car.kilometers ? car.kilometers + ' KM' : '-' }} {{ car.kilometers ? car.kilometers + ' KM' : '-' }}
</div> </div>
<div v-if="!hideEmpty || car.initial_date" class="col-span-1 xs:col-span-2">
<div class="col-span-1 xs:col-span-2">
Erstzulassung Erstzulassung
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.initial_date" class="col-span-1 xs:col-span-2">
{{ car.initial_date ? car.initial_date : '-' }} {{ car.initial_date ? car.initial_date : '-' }}
</div> </div>
<div v-if="!hideEmpty || car.last_check_date" class="col-span-1 xs:col-span-2">
<div class="col-span-1 xs:col-span-2">
Letzte Prüfung Letzte Prüfung
</div> </div>
<div class="col-span-1 xs:col-span-2"> <div v-if="!hideEmpty || car.last_check_date" class="col-span-1 xs:col-span-2">
{{ car.last_check_date ? car.last_check_date : '-' }} {{ car.last_check_date ? car.last_check_date : '-' }}
</div> </div>
</div> </div>
@ -65,6 +63,7 @@
export default ({ export default ({
props: { props: {
car: Object, car: Object,
hideEmpty: String,
}, },
}) })
</script> </script>

View File

@ -7,7 +7,7 @@
</div> </div>
<div v-if="contract.car" class="col-span-6 xs:col-span-12"> <div v-if="contract.car" class="col-span-6 xs:col-span-12">
<h3 class="mb-3">Auto</h3> <h3 class="mb-3">Auto</h3>
<car-card :car="contract.car" /> <car-card hide-empty="true" :car="contract.car" />
</div> </div>
<div class="col-span-6 xs:col-span-12 h-full relative"> <div class="col-span-6 xs:col-span-12 h-full relative">
<h3>Vertragsinformationen</h3> <h3>Vertragsinformationen</h3>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="sticky top-0 z-40"> <div class="sticky top-0 z-40">
<div class="w-full h-20 px-6 bg-white-100 border-b flex items-center justify-between"> <div class="w-full h-20 px-6 bg-white border-b flex items-center justify-between">
<!-- left navbar --> <!-- left navbar -->
<div class="flex"> <div class="flex">
@ -79,7 +79,10 @@ export default {
methods: { methods: {
toggleSidebar() { toggleSidebar() {
this.$store.dispatch('toggleSidebar') this.$store.dispatch('toggleSidebar')
} },
logout() {
this.$inertia.post(route('logout'));
},
} }
} }
</script> </script>

View File

@ -3,7 +3,7 @@
<template #header> <template #header>
<slot name="header"></slot> <slot name="header"></slot>
</template> </template>
<div class="py-6 grid grid-cols-12 gap-12 max-w-7xl sm:px-6 lg:px-8"> <div class="grid grid-cols-12 gap-12 w-full mb-10">
<div class="col-span-6 xs:col-span-12"> <div class="col-span-6 xs:col-span-12">
<slot name="info"></slot> <slot name="info"></slot>
</div> </div>
@ -13,7 +13,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="py-6 grid grid-cols-12 gap-8 w-full"> <div class="grid grid-cols-12 gap-12 w-full">
<slot name="more"></slot> <slot name="more"></slot>
</div> </div>
</layout> </layout>

View File

@ -1,7 +1,7 @@
<template> <template>
<!-- give the sidebar z-50 class so its higher than the navbar if you want to see the logo --> <!-- give the sidebar z-50 class so its higher than the navbar if you want to see the logo -->
<!-- you will need to add a little "X" button next to the logo in order to close it though --> <!-- you will need to add a little "X" button next to the logo in order to close it though -->
<div class="w-1/2 md:w-1/3 lg:w-64 fixed md:top-0 md:left-0 h-screen lg:block bg-white-100 border-r z-30" :class="sideBarOpen ? '' : 'hidden'" id="main-nav"> <div class="w-1/2 md:w-1/3 lg:w-64 fixed md:top-0 md:left-0 h-screen lg:block bg-white border-r z-30" :class="sideBarOpen ? '' : 'hidden'" id="main-nav">
<div class="w-full h-20 border-b flex px-4 items-center mb-8"> <div class="w-full h-20 border-b flex px-4 items-center mb-8">
<p class="font-semibold text-2xl text-blue-400 pl-4">Your SwissCar</p> <p class="font-semibold text-2xl text-blue-400 pl-4">Your SwissCar</p>

View File

@ -2,13 +2,13 @@
<div class="leading-normal tracking-normal" id="main-body"> <div class="leading-normal tracking-normal" id="main-body">
<div class="flex flex-wrap"> <div class="flex flex-wrap">
<Sidebar /> <Sidebar />
<div class="w-full bg-white-100 pl-0 lg:pl-64 min-h-screen" :class="sideBarOpen ? 'overlay' : ''" id="main-content"> <div class="w-full bg-gray-100 pl-0 lg:pl-64 min-h-screen" :class="sideBarOpen ? 'overlay' : ''" id="main-content">
<Navbar> <Navbar>
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> <h2 class="font-semibold text-xl text-gray-800 leading-tight">
<slot name="header"></slot> <slot name="header"></slot>
</h2> </h2>
</Navbar> </Navbar>
<div class="p-6 bg-gray-100 mb-20"> <div class="p-12 bg-gray-100 mb-20">
<main> <main>
<slot></slot> <slot></slot>
</main> </main>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="max-w-7xl py-10 sm:px-6 lg:px-8"> <div class="max-w-7xl">
<jet-form-section @submitted="submitForm"> <jet-form-section @submitted="submitForm">
<template #title> <template #title>
<slot name="title"></slot> <slot name="title"></slot>

View File

@ -6,10 +6,8 @@
Alle Autos Alle Autos
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>

View File

@ -10,7 +10,7 @@
<car-card :car="car" /> <car-card :car="car" />
</template> </template>
<template #actions> <template #actions>
<edit-button v-if="!car.deleted_at" :href="route('cars.destroy', car.id)" /> <edit-button v-if="!car.deleted_at" :href="route('cars.edit', car.id)" />
<delete-button v-if="!car.deleted_at" :href="route('cars.destroy', car.id)" /> <delete-button v-if="!car.deleted_at" :href="route('cars.destroy', car.id)" />
<restore-button v-if="car.deleted_at" :href="route('cars.restore', car.id)" /> <restore-button v-if="car.deleted_at" :href="route('cars.restore', car.id)" />
<div v-if="car.deleted_at"> <div v-if="car.deleted_at">
@ -18,7 +18,7 @@
</div> </div>
</template> </template>
<template #more> <template #more>
<div class="sm:px-6 lg:px-8 col-span-6 xs:col-span-12"> <div class="col-span-6 xs:col-span-12">
<div class="whitespace-nowrap"> <div class="whitespace-nowrap">
<h1 class="font-bold text-3xl">{{ car.buy_contracts.total > 1 ? car.buy_contracts.total + ' Ankaufsverträge' : 'Ankaufsvertrag' }}</h1> <h1 class="font-bold text-3xl">{{ car.buy_contracts.total > 1 ? car.buy_contracts.total + ' Ankaufsverträge' : 'Ankaufsvertrag' }}</h1>
</div> </div>
@ -32,7 +32,7 @@
</inertia-link> </inertia-link>
</div> </div>
</div> </div>
<div class="sm:px-6 lg:px-8 col-span-6 xs:col-span-12"> <div class="col-span-6 xs:col-span-12">
<div class="whitespace-nowrap"> <div class="whitespace-nowrap">
<h1 class="font-bold text-3xl">{{ car.sell_contracts.total > 1 ? car.sell_contracts.total + ' Verkaufsverträge' : 'Verkaufsvertrag' }}</h1> <h1 class="font-bold text-3xl">{{ car.sell_contracts.total > 1 ? car.sell_contracts.total + ' Verkaufsverträge' : 'Verkaufsvertrag' }}</h1>
</div> </div>
@ -53,7 +53,6 @@
<script> <script>
import ShowPage from '@/Components/ShowPage.vue' import ShowPage from '@/Components/ShowPage.vue'
import BreadCrumb from '@/Components/BreadCrumb.vue' import BreadCrumb from '@/Components/BreadCrumb.vue'
import SimpleTable from '@/Components/SimpleTable.vue'
import CarCard from '@/Components/CarCard.vue' import CarCard from '@/Components/CarCard.vue'
import BuyContractCard from '@/Components/BuyContractCard.vue' import BuyContractCard from '@/Components/BuyContractCard.vue'
import SellContractCard from '@/Components/SellContractCard.vue' import SellContractCard from '@/Components/SellContractCard.vue'
@ -65,7 +64,6 @@ export default {
components: { components: {
ShowPage, ShowPage,
BreadCrumb, BreadCrumb,
SimpleTable,
CarCard, CarCard,
BuyContractCard, BuyContractCard,
SellContractCard, SellContractCard,
@ -79,17 +77,6 @@ export default {
data() { data() {
return { return {
currentRoute: 'cars.show', currentRoute: 'cars.show',
buyContractsColumns: [
{key: 'contact', value: 'Verkäufer'},
{key: 'date', value: 'Kaufdatum'},
{key: 'price', value: 'Kaufpreis'},
],
sellContractsColumns: [
{key: 'contact', value: 'Käufer'},
{key: 'date', value: 'Verkaufsdatum'},
{key: 'price', value: 'Verkaufspreis'},
{key: 'insurance_type', value: 'Versicherungstyp'},
],
} }
}, },
} }

View File

@ -6,10 +6,8 @@
Verkaufte Autos Verkaufte Autos
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>

View File

@ -6,10 +6,8 @@
Meine Autos Meine Autos
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="cars.total + ' Autos'" :data="cars" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>

View File

@ -6,10 +6,8 @@
Käufer Käufer
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto sm:px-6 lg:px-8">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="contacts.total + ' Käufer'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="contacts.total + ' Käufer'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>
@ -38,7 +36,6 @@ export default {
{key: 'company', value: 'Firma', sortable: true}, {key: 'company', value: 'Firma', sortable: true},
{key: 'address', value: 'Adresse', sortable: true}, {key: 'address', value: 'Adresse', sortable: true},
{key: 'fullCity', value: 'Ort', sortable: true}, {key: 'fullCity', value: 'Ort', sortable: true},
{key: 'email', value: 'E-Mail', sortable: true},
{key: 'phone', value: 'Telefon'}, {key: 'phone', value: 'Telefon'},
], ],
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="max-w-7xl py-10 sm:px-6 lg:px-8"> <div class="max-w-7xl">
<jet-form-section @submitted="submitForm"> <jet-form-section @submitted="submitForm">
<template #title> <template #title>
<slot name="title"></slot> <slot name="title"></slot>
@ -100,6 +100,7 @@ import JetInput from '@/Jetstream/Input.vue'
import JetActionMessage from '@/Jetstream/ActionMessage' import JetActionMessage from '@/Jetstream/ActionMessage'
import JetInputError from '@/Jetstream/InputError' import JetInputError from '@/Jetstream/InputError'
import JetFormSection from '@/Jetstream/FormSection' import JetFormSection from '@/Jetstream/FormSection'
import { useForm } from '@inertiajs/inertia-vue3'
export default { export default {
components: { components: {
@ -110,35 +111,18 @@ export default {
JetInputError, JetInputError,
JetActionMessage, JetActionMessage,
}, },
props: { props: {
form: Object, data: Object,
meta: Object, meta: Object,
}, },
data() {
computed: { return {
contact: function () { form: useForm(this.meta.form_name, this.data),
return { }
id: this.form.id,
firstname: this.form.firstname,
lastname: this.form.lastname,
company: this.form.company,
email: this.form.email,
phone: this.form.phone,
address: this.form.address,
zip: this.form.zip,
city: this.form.city,
country: this.form.country,
notes: this.form.notes,
}
},
}, },
methods: { methods: {
submitForm() { submitForm() {
this.form.post(route(this.meta.link, this.contact), { this.form.submit(this.meta.method, this.meta.route);
preserveScroll: true,
});
}, },
}, },
} }

View File

@ -8,7 +8,7 @@
</template> </template>
<div> <div>
<contact-form :form="form" :meta="meta"> <contact-form :data="data" :meta="meta">
<template #title>Neuen Kontakt erfassen</template> <template #title>Neuen Kontakt erfassen</template>
<template #description>Anschliessend können mit dem neuen Kontakt Verträge abgeschlossen werden.</template> <template #description>Anschliessend können mit dem neuen Kontakt Verträge abgeschlossen werden.</template>
</contact-form> </contact-form>
@ -30,12 +30,13 @@ export default {
data() { data() {
return { return {
meta: { meta: {
link: 'contacts.store', form_name: 'CreateContact',
route: this.route('contacts.store'),
method: 'post',
button_text: 'Kontakt speichern', button_text: 'Kontakt speichern',
on_success: 'Kontakt gespeichert', on_success: 'Kontakt gespeichert',
}, },
form: this.$inertia.form({ data: {
_method: 'POST',
id: null, id: null,
firstname: null, firstname: null,
lastname: null, lastname: null,
@ -47,7 +48,7 @@ export default {
city: null, city: null,
country: null, country: null,
notes: null, notes: null,
}), },
} }
}, },
} }

View File

@ -8,39 +8,26 @@
</template> </template>
<div> <div>
<contact-form :form="form" :meta="meta"> <contact-form :data="data" :meta="meta">
<template #title>Kontaktinformationen</template> <template #title>Kontaktinformationen</template>
<template #description> <template #description>
Kontaktinformationen anschauen &amp; anpassen. Kontaktinformationen anschauen &amp; anpassen.
<contact-card :contact="computedContact" />
</template> </template>
</contact-form> </contact-form>
</div> </div>
<div class="py-12">
<div class="max-w-7xl sm:px-6 lg:px-8">
<simple-table :title="'An ' + title + ' verkaufte Autos'" :data="contact.bought_cars" :columns="boughtCarColumns" />
</div>
<div class="max-w-7xl pt-6 sm:px-6 lg:px-8">
<simple-table :title="'Von ' + title + ' gekaufte Autos'" :data="contact.sold_cars" :columns="soldCarColumns" />
</div>
</div>
</layout> </layout>
</template> </template>
<script> <script>
import Layout from '@/Layouts/Layout' import Layout from '@/Layouts/Layout'
import BreadCrumb from '@/Components/BreadCrumb.vue' import BreadCrumb from '@/Components/BreadCrumb.vue'
import ContactCard from '@/Components/ContactCard.vue'
import SimpleTable from '@/Components/SimpleTable.vue'
import ContactForm from './Components/ContactForm.vue' import ContactForm from './Components/ContactForm.vue'
export default { export default {
components: { components: {
Layout, Layout,
BreadCrumb, BreadCrumb,
SimpleTable,
ContactForm, ContactForm,
ContactCard,
}, },
props: { props: {
@ -49,12 +36,13 @@ export default {
data() { data() {
return { return {
meta: { meta: {
link: 'contacts.update', form_name: 'EditContact' + this.contact.id,
route: this.route('contacts.update', this.contact.id),
method: 'put',
button_text: 'Änderungen speichern', button_text: 'Änderungen speichern',
on_success: 'Änderungen gespeichert', on_success: 'Änderungen gespeichert',
}, },
form: this.$inertia.form({ data: {
_method: 'PUT',
id: this.contact.id, id: this.contact.id,
firstname: this.contact.firstname, firstname: this.contact.firstname,
lastname: this.contact.lastname, lastname: this.contact.lastname,
@ -66,41 +54,17 @@ export default {
city: this.contact.city, city: this.contact.city,
country: this.contact.country, country: this.contact.country,
notes: this.contact.notes, notes: this.contact.notes,
}), },
boughtCarColumns: [
{key: 'name', value: 'Auto'},
{key: 'date', value: 'Verkaufsdatum'},
{key: 'price', value: 'Verkaufspreis'},
{key: 'insurance_type', value: 'Versicherungstyp'},
],
soldCarColumns: [
{key: 'name', value: 'Auto'},
{key: 'date', value: 'Kaufdatum'},
{key: 'price', value: 'Kaufpreis'},
]
} }
}, },
computed: { computed: {
title: function () { title: function () {
if (this.form.company) { if (this.data.company) {
return this.form.company; return this.data.company;
} }
return this.form.lastname + ' ' + this.form.firstname; return this.data.lastname + ' ' + this.data.firstname;
}, },
computedContact: function () {
return {
firstname: this.form.firstname,
lastname: this.form.lastname,
company: this.form.company,
email: this.form.email,
phone: this.form.phone,
address: this.form.address,
zip: this.form.zip,
city: this.form.city,
country: this.form.country,
}
}
}, },
} }
</script> </script>

View File

@ -6,10 +6,8 @@
Alle Kontakte Alle Kontakte
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="contacts.total + ' Kontakte'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="contacts.total + ' Kontakte'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>
@ -38,7 +36,6 @@ export default {
{key: 'company', value: 'Firma', sortable: true}, {key: 'company', value: 'Firma', sortable: true},
{key: 'address', value: 'Adresse', sortable: true}, {key: 'address', value: 'Adresse', sortable: true},
{key: 'fullCity', value: 'Ort', sortable: true}, {key: 'fullCity', value: 'Ort', sortable: true},
{key: 'email', value: 'E-Mail', sortable: true},
{key: 'phone', value: 'Telefon'}, {key: 'phone', value: 'Telefon'},
], ],
} }

View File

@ -6,10 +6,8 @@
Käufer Käufer
</h2> </h2>
</template> </template>
<div class="py-12"> <div class="w-full mx-auto">
<div class="w-full mx-auto sm:px-6 lg:px-8"> <simple-table :title="contacts.total + ' Verkäufer'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
<simple-table :title="contacts.total + ' Verkäufer'" :data="contacts" :columns="columns" :defaultSort="sort" :filters="filters" :currentRoute="currentRoute" />
</div>
</div> </div>
</layout> </layout>
</template> </template>
@ -38,7 +36,6 @@ export default {
{key: 'company', value: 'Firma', sortable: true}, {key: 'company', value: 'Firma', sortable: true},
{key: 'address', value: 'Adresse', sortable: true}, {key: 'address', value: 'Adresse', sortable: true},
{key: 'fullCity', value: 'Ort', sortable: true}, {key: 'fullCity', value: 'Ort', sortable: true},
{key: 'email', value: 'E-Mail', sortable: true},
{key: 'phone', value: 'Telefon'}, {key: 'phone', value: 'Telefon'},
], ],
} }

View File

@ -0,0 +1,96 @@
<template>
<show-page>
<template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
<bread-crumb text="Kontakte" :href="route('contacts')" />
{{ title }}
</h2>
</template>
<template #info>
<contact-card :contact="contact" />
</template>
<template #actions>
<edit-button v-if="!contact.deleted_at" :href="route('contacts.edit', contact.id)" />
<delete-button v-if="!contact.deleted_at" :href="route('contacts.destroy', contact.id)" />
<restore-button v-if="contact.deleted_at" :href="route('contacts.restore', contact.id)" />
<div v-if="contact.deleted_at">
gelöscht: {{ contact.deleted_at }}
</div>
</template>
<template #more>
<div class="col-span-10 xs:col-span-12">
<div class="whitespace-nowrap">
<h1 class="font-bold text-3xl">{{ contact.buy_contracts.total > 1 ? contact.buy_contracts.total + ' Ankaufsverträge' : 'Ankaufsvertrag' }}</h1>
</div>
<div v-for="contract in contact.buy_contracts.data" :key="contract.id">
<buy-contract-card :contract="contract"/>
</div>
<div v-if="!contact.deleted_at">
<inertia-link :href="route('contracts.create_from_contact', contact.id)" class="w-full py-6 mt-12 inline-flex items-center px-4 bg-green-800 border border-transparent rounded-md font-semibold justify-center text-md text-white uppercase tracking-widest hover:bg-green-700 focus:outline-none focus:border-green-900 focus:ring focus:ring-green-300 disabled:opacity-25 transition" >
<unicon fill="white" class="mr-1" height="22" width="22" name="plus-circle"></unicon>
Neuer Ankaufsvertrag
</inertia-link>
</div>
</div>
<div class="col-span-10 xs:col-span-12">
<div class="whitespace-nowrap">
<h1 class="font-bold text-3xl">{{ contact.sell_contracts.total > 1 ? contact.sell_contracts.total + ' Verkaufsverträge' : 'Verkaufsvertrag' }}</h1>
</div>
<div v-for="contract in contact.sell_contracts.data" :key="contract.id">
<sell-contract-card :contract="contract"/>
</div>
<div v-if="!contact.deleted_at">
<inertia-link :href="route('contracts.create_from_contact', contact.id)" class="py-6 w-full mt-12 inline-flex items-center px-4 bg-green-800 border border-transparent rounded-md font-semibold justify-center text-md text-white uppercase tracking-widest hover:bg-green-700 focus:outline-none focus:border-green-900 focus:ring focus:ring-green-300 disabled:opacity-25 transition" >
<unicon fill="white" class="mr-1" height="22" width="22" name="plus-circle"></unicon>
Neuer Verkaufssvertrag
</inertia-link>
</div>
</div>
</template>
</show-page>
</template>
<script>
import ShowPage from '@/Components/ShowPage.vue'
import BreadCrumb from '@/Components/BreadCrumb.vue'
import ContactCard from '@/Components/ContactCard.vue'
import BuyContractCard from '@/Components/BuyContractCard.vue'
import SellContractCard from '@/Components/SellContractCard.vue'
import EditButton from '@/Components/Buttons/EditButton.vue'
import DeleteButton from '@/Components/Buttons/DeleteButton.vue'
import RestoreButton from '@/Components/Buttons/RestoreButton.vue'
export default {
components: {
ShowPage,
BreadCrumb,
ContactCard,
BuyContractCard,
SellContractCard,
EditButton,
DeleteButton,
RestoreButton,
},
props: {
contact: Object,
},
data() {
return {
currentRoute: 'contacts.show',
}
},
computed: {
title: function () {
if (this.contact.company) {
return this.contact.company;
}
return this.contact.lastname + ' ' + this.contact.firstname;
},
},
}
</script>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="max-w-7xl py-10 sm:px-6 lg:px-8"> <div class="max-w-7xl">
<jet-form-section @submitted="submitForm"> <jet-form-section @submitted="submitForm">
<template #title> <template #title>
<slot name="title"></slot> <slot name="title"></slot>

View File

@ -7,7 +7,7 @@
</h2> </h2>
</template> </template>
<div> <div>
<jet-form-section class="max-w-7xl pb-5 sm:px-6 lg:px-8"> <jet-form-section class="max-w-7xl">
<template #title> <template #title>
Auto Auto
</template> </template>

View File

@ -33,7 +33,7 @@
</div> </div>
</template> </template>
<template #actions> <template #actions>
<edit-button :href="route('contracts.edit', contract.id)" /> <edit-button v-if="!contract.deleted_at" :href="route('contracts.edit', contract.id)" />
<print-button class="mb-3" :href="route('contracts.print', contract.id)" /> <print-button class="mb-3" :href="route('contracts.print', contract.id)" />
<delete-button v-if="!contract.deleted_at" :href="route('contracts.destroy', contract.id)" /> <delete-button v-if="!contract.deleted_at" :href="route('contracts.destroy', contract.id)" />
<restore-button v-if="contract.deleted_at" :href="route('contracts.restore', contract.id)" /> <restore-button v-if="contract.deleted_at" :href="route('contracts.restore', contract.id)" />
@ -42,11 +42,11 @@
</div> </div>
</template> </template>
<template #more> <template #more>
<div class="sm:px-6 lg:px-8 col-span-6 xs:col-span-12"> <div class="col-span-6 xs:col-span-12">
<h3 class="mb-3">Auto</h3> <h3 class="mb-3">Auto</h3>
<car-card :car="contract.car" /> <car-card :car="contract.car" />
</div> </div>
<div class="sm:px-6 lg:px-8 col-span-4 xs:col-span-12"> <div class="col-span-5 xs:col-span-12">
<h3 class="mb-3">{{ contactTitle }}</h3> <h3 class="mb-3">{{ contactTitle }}</h3>
<contact-card :contact="contract.contact" /> <contact-card :contact="contract.contact" />
</div> </div>

View File

@ -53,10 +53,14 @@ Route::post('contacts', [ContactController::class, 'store'])
->name('contacts.store') ->name('contacts.store')
->middleware(['auth:sanctum', 'verified']); ->middleware(['auth:sanctum', 'verified']);
Route::get('contacts/{contact}', [ContactController::class, 'edit']) Route::get('contacts/{contact}/edit', [ContactController::class, 'edit'])
->name('contacts.edit') ->name('contacts.edit')
->middleware(['auth:sanctum', 'verified']); ->middleware(['auth:sanctum', 'verified']);
Route::get('contacts/{contact}', [ContactController::class, 'show'])
->name('contacts.show')
->middleware(['auth:sanctum', 'verified']);
Route::put('contacts/{contact}', [ContactController::class, 'update']) Route::put('contacts/{contact}', [ContactController::class, 'update'])
->name('contacts.update') ->name('contacts.update')
->middleware(['auth:sanctum', 'verified']); ->middleware(['auth:sanctum', 'verified']);
@ -133,6 +137,10 @@ Route::get('contracts/create/car/{car}', [ContractController::class, 'createFrom
->name('contracts.create_from_car') ->name('contracts.create_from_car')
->middleware(['auth:sanctum', 'verified']); ->middleware(['auth:sanctum', 'verified']);
Route::get('contracts/create/contact/{contact}', [ContractController::class, 'createFromContact'])
->name('contracts.create_from_contact')
->middleware(['auth:sanctum', 'verified']);
Route::post('contracts', [ContractController::class, 'store']) Route::post('contracts', [ContractController::class, 'store'])
->name('contracts.store') ->name('contracts.store')
->middleware(['auth:sanctum', 'verified']); ->middleware(['auth:sanctum', 'verified']);