Skip to content

Commit 9d968b0

Browse files
committed
added prevention to update or delete a deleted filter
1 parent b81c143 commit 9d968b0

File tree

1 file changed

+21
-7
lines changed
  • app/Livewire/Partials/AdvancedSearch

1 file changed

+21
-7
lines changed

app/Livewire/Partials/AdvancedSearch/Modal.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ public function openPredefinedFiltersModal(
8080
$predefinedFilter = $predefinedFilterService->getFilterWithOptionalPermissionsById(
8181
$predefinedFilterId
8282
);
83+
84+
if ($predefinedFilter === null){
85+
$this->showModal = false;
86+
$this->dispatchNotFoundNotification();
87+
return;
88+
}
89+
8390
$this->name = $predefinedFilter["name"];
8491

8592
if ($predefinedFilter["is_public"] == 1) {
@@ -287,13 +294,9 @@ public function deletePredefinedFiltersModal(
287294

288295
$predefinedFilter = $predefinedFilterService->getFilterWithOptionalPermissionsById($this->filterId);
289296

290-
if (!isset($predefinedFilter)) {
291-
$this->dispatch('showNotificationInFrontend', [
292-
'type' => 'error',
293-
'title' => trans('general.notification_error'),
294-
'message' => trans('admin/predefinedFilters/message.does_not_exist'),
295-
'tag' => 'predefinedFilter',
296-
]);
297+
if ($predefinedFilter === null){
298+
$this->dispatchNotFoundNotification();
299+
return;
297300
}
298301

299302
if (!$predefinedFilter->userHasPermission(auth()->user(), 'delete')) {
@@ -377,4 +380,15 @@ private function checkCreatePermissions(): bool{
377380

378381
return false;
379382
}
383+
384+
private function dispatchNotFoundNotification()
385+
{
386+
$this->dispatch('showNotificationInFrontend', [
387+
'type' => 'error',
388+
'title' => trans('general.notification_error'),
389+
'message' => trans('admin/predefinedFilters/message.does_not_exist'),
390+
'tag' => 'predefinedFilter',
391+
]);
392+
}
393+
380394
}

0 commit comments

Comments
 (0)