From 5957a2504427aaed482fa83b9f6f6e46fec3b901 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 19 Nov 2022 12:02:13 +1100 Subject: [PATCH] Enabled address undelete and purge, now showing systems deleted messages --- app/Http/Controllers/SystemController.php | 40 +++++++++++++++++++ app/Models/System.php | 1 + public/css/fixes.css | 5 +++ resources/views/system/addedit.blade.php | 17 +++++--- ...delete.blade.php => modal_purge.blade.php} | 16 ++++---- routes/web.php | 4 ++ 6 files changed, 69 insertions(+), 14 deletions(-) rename resources/views/widgets/{modal_delete.blade.php => modal_purge.blade.php} (56%) diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 2ece69a..132b8a3 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -517,6 +517,46 @@ class SystemController extends Controller return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id)); } + /** + * Recover a deleted address + * + * @param int $id + * @return \Illuminate\Http\RedirectResponse + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function rec_address(int $id) + { + $o = Address::onlyTrashed()->findOrFail($id); + + // @todo This should be admin of the zone + $this->authorize('admin',$o); + session()->flash('accordion','address'); + + $o->restore(); + + return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id)); + } + + /** + * Recover a deleted address + * + * @param int $id + * @return \Illuminate\Http\RedirectResponse + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function pur_address(int $id) + { + $o = Address::onlyTrashed()->findOrFail($id); + + // @todo This should be admin of the zone + $this->authorize('admin',$o); + session()->flash('accordion','address'); + + $o->forceDelete(); + + return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id)); + } + /** * register system */ diff --git a/app/Models/System.php b/app/Models/System.php index f27d163..1d21cee 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -35,6 +35,7 @@ class System extends Model public function addresses() { return $this->hasMany(Address::class) + ->withTrashed() ->FTNorder(); } diff --git a/public/css/fixes.css b/public/css/fixes.css index 7bb1cca..544d054 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -57,4 +57,9 @@ ol { /* Fix markdown parser that renders
  • */ #content ul:not(.pagination) li p { margin-left: -1ch; +} + +.trashed { + text-decoration: line-through; + color: #3f6982; } \ No newline at end of file diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 5fdb39d..b603c5a 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -107,19 +107,24 @@ @foreach ($o->addresses->sortBy(function($item) { return sprintf('%04x%04x%04x%04x%04x',$item->zone->zone_id,$item->region_id,$item->host_id,$item->node_id,$item->point_id); }) as $oo) - {{ $oo->ftn }} + trashed()) class="trashed" @endif>{{ $oo->ftn }} {{ $oo->active ? 'YES' : 'NO' }} {{ $oo->role_name }} @can('admin',$oo) - {{-- @if (! $oo->role & (Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC)) @endif --}} - - + @if($oo->trashed()) + + + @else + + + + @endif @endcan @@ -183,7 +188,7 @@ {{-- --}} - + @endforeach @@ -380,7 +385,7 @@ @endif - @include('widgets.modal_delete') + @include('widgets.modal_purge') @endsection @section('page-scripts') diff --git a/resources/views/widgets/modal_delete.blade.php b/resources/views/widgets/modal_purge.blade.php similarity index 56% rename from resources/views/widgets/modal_delete.blade.php rename to resources/views/widgets/modal_purge.blade.php index 3c537be..66acc8c 100644 --- a/resources/views/widgets/modal_delete.blade.php +++ b/resources/views/widgets/modal_purge.blade.php @@ -1,16 +1,16 @@ -