move to custom x-form component and fix htmlspecialentities issue

This commit is contained in:
hackerESQ
2024-09-18 19:51:05 -05:00
parent 835c2115f2
commit 5bb601f869
4 changed files with 52 additions and 35 deletions
+12 -2
View File
@@ -23,10 +23,20 @@
<div @click="open = false" class="fixed inset-0 bg-black opacity-50"></div> <div @click="open = false" class="fixed inset-0 bg-black opacity-50"></div>
<x-card <x-card
:title="$title"
:subtitle="$subtitle"
{{ $attributes->merge(['class' => 'min-h-screen w-11/12 lg:w-1/3 rounded-none px-8 transition']) }} {{ $attributes->merge(['class' => 'min-h-screen w-11/12 lg:w-1/3 rounded-none px-8 transition']) }}
> >
@if($title)
<x-slot:title>
{!! strip_tags($title) !!}
</x-slot:title>
@endif
@if($subtitle)
<x-slot:subtitle>
{!! strip_tags($subtitle) !!}
</x-slot:subtitle>
@endif
@if ($showClose) @if ($showClose)
<x-button icon="o-x-mark" class="btn-ghost btn-circle btn-sm absolute top-4 right-4 " @click="open = false" /> <x-button icon="o-x-mark" class="btn-ghost btn-circle btn-sm absolute top-4 right-4 " @click="open = false" />
@@ -0,0 +1,21 @@
@props([
'noSeparator' => false,
])
<form
{{ $attributes->whereDoesntStartWith('class') }}
{{ $attributes->class(['grid grid-flow-row auto-rows-min gap-3']) }}
>
{{ $slot }}
@if ($actions)
@if(!$noSeparator)
<hr class="my-3" />
@endif
<div class="flex justify-between gap-3">
{{ $actions}}
</div>
@endif
</form>
@@ -47,20 +47,6 @@ new class extends Component {
public function save() public function save()
{ {
// // get stats
// $key = 'portfolio-metrics-' . $portfolio->id;
// $metrics = cache()->remember($key, 60, function () use ($portfolio) {
// return Holding::where(['portfolio_id' => $portfolio->id])
// ->withPortfolioMetrics()
// ->first();
// });
// return view('pages.portfolios.show', [
// 'portfolio' => $portfolio,
// 'metrics' => $metrics
// ]);
$portfolio = (new Portfolio())->fill($this->validate()); $portfolio = (new Portfolio())->fill($this->validate());
// $portfolio->owner_id = auth()->user()->id; // $portfolio->owner_id = auth()->user()->id;
$portfolio->save(); $portfolio->save();
@@ -78,7 +64,7 @@ new class extends Component {
}; ?> }; ?>
<div class="grid lg:grid-cols-4 gap-10"> <div class="grid lg:grid-cols-4 gap-10">
<x-form wire:submit="{{ $portfolio ? 'update' : 'save' }}" class="col-span-3"> <x-ib-form wire:submit="{{ $portfolio ? 'update' : 'save' }}" class="col-span-3">
<x-input label="{{ __('Title') }}" wire:model="title" required /> <x-input label="{{ __('Title') }}" wire:model="title" required />
<x-textarea label="{{ __('Notes') }}" wire:model="notes" rows="5" /> <x-textarea label="{{ __('Notes') }}" wire:model="notes" rows="5" />
@@ -92,10 +78,10 @@ new class extends Component {
<x-slot:actions> <x-slot:actions>
@if ($portfolio) @if ($portfolio)
<x-button <x-button
class="ms-3 btn btn-ghost text-error"
wire:click="$toggle('confirmingPortfolioDeletion')" wire:click="$toggle('confirmingPortfolioDeletion')"
wire:loading.attr="disabled" wire:loading.attr="disabled"
label="{{ __('Delete') }}" icon="o-trash"
class="btn btn-ghost btn-circle text-error"
title="{{ __('Delete Portfolio') }}" title="{{ __('Delete Portfolio') }}"
/> />
@endif @endif
@@ -105,7 +91,7 @@ new class extends Component {
@endif @endif
<x-button label="{{ $portfolio ? 'Update' : 'Create' }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" /> <x-button label="{{ $portfolio ? 'Update' : 'Create' }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" />
</x-slot:actions> </x-slot:actions>
</x-form> </x-ib-form>
<x-confirmation-modal wire:model.live="confirmingPortfolioDeletion"> <x-confirmation-modal wire:model.live="confirmingPortfolioDeletion">
<x-slot name="title"> <x-slot name="title">
@@ -105,7 +105,7 @@ new class extends Component {
}; ?> }; ?>
<div class="" x-data="{ transaction_type: @entangle('transaction_type') }"> <div class="" x-data="{ transaction_type: @entangle('transaction_type') }">
<x-form wire:submit="{{ $transaction ? 'update' : 'save' }}" class=""> <x-ib-form wire:submit="{{ $transaction ? 'update' : 'save' }}" class="">
@if(empty($portfolio)) @if(empty($portfolio))
@@ -156,10 +156,10 @@ new class extends Component {
<x-slot:actions> <x-slot:actions>
@if ($transaction) @if ($transaction)
<x-button <x-button
class="ms-3 btn btn-ghost text-error"
wire:click="$toggle('confirmingTransactionDeletion')" wire:click="$toggle('confirmingTransactionDeletion')"
wire:loading.attr="disabled" wire:loading.attr="disabled"
label="{{ __('Delete') }}" icon="o-trash"
class="btn btn-ghost btn-circle text-error"
title="{{ __('Delete Transaction') }}" title="{{ __('Delete Transaction') }}"
/> />
@endif @endif
@@ -172,7 +172,7 @@ new class extends Component {
spinner="{{ $transaction ? 'update' : 'save' }}" spinner="{{ $transaction ? 'update' : 'save' }}"
/> />
</x-slot:actions> </x-slot:actions>
</x-form> </x-ib-form>
<x-confirmation-modal wire:model.live="confirmingTransactionDeletion"> <x-confirmation-modal wire:model.live="confirmingTransactionDeletion">
<x-slot name="title"> <x-slot name="title">