From 9fd41dd69ef347c7b5e6b60668b51026a85692d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Tue, 28 Nov 2023 10:36:59 +0100 Subject: [PATCH] refactor relation table --- resources/views/resources/index.blade.php | 2 +- resources/views/resources/relation.blade.php | 27 ++++- resources/views/table/body.blade.php | 110 ++++++++++++++++++ resources/views/table/table.blade.php | 111 +------------------ 4 files changed, 138 insertions(+), 112 deletions(-) create mode 100644 resources/views/table/body.blade.php diff --git a/resources/views/resources/index.blade.php b/resources/views/resources/index.blade.php index c438ce68..69101599 100644 --- a/resources/views/resources/index.blade.php +++ b/resources/views/resources/index.blade.php @@ -8,7 +8,7 @@ @can('create', $model) - {{ __('Add :model', ['model' => $modelName]) }} + {{ __('Add :resource', ['resource' => $modelName]) }} @endcan @endsection diff --git a/resources/views/resources/relation.blade.php b/resources/views/resources/relation.blade.php index 7372df7d..3b52f632 100644 --- a/resources/views/resources/relation.blade.php +++ b/resources/views/resources/relation.blade.php @@ -1,3 +1,28 @@ - @include('root::table.table') +
+
+

+ {{ $title }} +

+
+ @can('create', $model) + + + {{ __('Add :resource', ['resource' => $modelName]) }} + + @endcan + @include('root::table.filters') +
+
+ @include('root::table.body') +
+ + {{-- Script --}} + @pushOnce('scripts') + {{ + Vite::withEntryPoints('resources/js/table.js') + ->useBuildDirectory('vendor/root/build') + ->useHotFile(public_path('vendor/root/hot')) + }} + @endpushOnce
diff --git a/resources/views/table/body.blade.php b/resources/views/table/body.blade.php new file mode 100644 index 00000000..eaaee96d --- /dev/null +++ b/resources/views/table/body.blade.php @@ -0,0 +1,110 @@ +
+
+ @includeWhen(! empty($actions), 'root::table.actions') + @if($data->isNotEmpty()) +
+ + + + @if(! empty($actions)) + + @endif + @foreach($data[0]['fields'] as $column) + @include('root::table.column', $column) + @endforeach + + + + + @foreach($data as $row) + + @if(! empty($actions)) + + @endif + @foreach($row['fields'] as $cell) + @include('root::table.cell', $cell) + @endforeach + + + @endforeach + +
+ {{ __('Select') }} + + + {{ __('Actions') }} +
+ + +
+ @can('view', $row['model']) + + + + @endcan + @can('update', $row['model']) + + + + @endcan + @can('delete', $row['model']) +
+ @csrf + @method('DELETE') + +
+ @endcan +
+
+
+ + @else + + {{ __('No results found.') }} + + @endif +
+
diff --git a/resources/views/table/table.blade.php b/resources/views/table/table.blade.php index 6a82332f..d41eca50 100644 --- a/resources/views/table/table.blade.php +++ b/resources/views/table/table.blade.php @@ -5,116 +5,7 @@ @include('root::table.filters') -
-
- @includeWhen(! empty($actions), 'root::table.actions') - @if($data->isNotEmpty()) -
- - - - @if(! empty($actions)) - - @endif - @foreach($data[0]['fields'] as $column) - @include('root::table.column', $column) - @endforeach - - - - - @foreach($data as $row) - - @if(! empty($actions)) - - @endif - @foreach($row['fields'] as $cell) - @include('root::table.cell', $cell) - @endforeach - - - @endforeach - -
- {{ __('Select') }} - - - {{ __('Actions') }} -
- - -
- @can('view', $row['model']) - - - - @endcan - @can('update', $row['model']) - - - - @endcan - @can('delete', $row['model']) -
- @csrf - @method('DELETE') - -
- @endcan -
-
-
- - @else - - {{ __('No results found.') }} - - @endif -
-
+ @include('root::table.body') {{-- Script --}}