Skip to content

Commit b88cadf

Browse files
committed
Refactor Kanban board: remove unneded permissions
1 parent 13a8842 commit b88cadf

File tree

5 files changed

+2
-83
lines changed

5 files changed

+2
-83
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ Flowforge offers several powerful features out of the box:
117117
- **Customizable Cards**: Display additional model attributes on cards
118118
- **Search Functionality**: Built-in search across specified model fields
119119
- **Integration Support**: Works with other packages like custom fields systems
120-
- **Permissions**: Respects Laravel Gate permissions for CRUD operations
121120

122121
## 🏗️ Model Preparation
123122

resources/views/livewire/column.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['permissions', 'columnId', 'column', 'config'])
1+
@props(['columnId', 'column', 'config'])
22

33
<div
44
class="kanban-column w-[300px] min-w-[300px] flex-shrink-0 border border-kanban-column-border dark:border-gray-700 shadow-kanban-column dark:shadow-md rounded-xl flex flex-col max-h-full overflow-hidden">

resources/views/livewire/kanban-board.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class="w-full h-full flex flex-col relative"
2525
:columnId="$columnId"
2626
:column="$column"
2727
:config="$config"
28-
:permissions="$this->permissions"
2928
wire:key="column-{{ $columnId }}"
3029
/>
3130
@endforeach

src/Contracts/KanbanAdapterInterface.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,6 @@ public function getItemsForColumn(string | int $columnId, int $limit = 10): Coll
4949
*/
5050
public function getColumnItemsCount(string | int $columnId): int;
5151

52-
/**
53-
* Create a new record with the given attributes.
54-
*
55-
* @param Form $form
56-
* @param mixed $currentColumn
57-
* @return Model|null
58-
*/
59-
public function createRecord(Form $form, mixed $currentColumn): ?Model;
60-
61-
/**
62-
* Update an existing record with the given attributes.
63-
*
64-
* @param Model $record The record to update
65-
* @param Form $form
66-
* @return bool
67-
*/
68-
public function updateRecord(Model $record, Form $form): bool;
69-
70-
/**
71-
* Delete an existing record.
72-
*
73-
* @param Model $record The record to delete
74-
*/
75-
public function deleteRecord(Model $record): bool;
76-
7752
/**
7853
* Update the order of records in a column.
7954
*

src/Livewire/KanbanBoard.php

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class KanbanBoard extends Component implements HasForms, HasActions
8989
*/
9090
public int $cardsIncrement;
9191

92-
public array $permissions = [];
93-
9492
/**
9593
* Initialize the Kanban board.
9694
*
@@ -110,12 +108,6 @@ public function mount(
110108
$this->searchable = $searchable;
111109
$this->config = $this->adapter->getConfig();
112110

113-
// Check permissions
114-
$this->permissions = [
115-
'canCreate' => Gate::check('create', $this->adapter->baseQuery->getModel()),
116-
'canDelete' => Gate::check('delete', $this->adapter->baseQuery->getModel()),
117-
];
118-
119111
// Set default limits
120112
$initialCardsCount = $initialCardsCount ?? 50;
121113
$this->cardsIncrement = $cardsIncrement ?? 10;
@@ -243,7 +235,7 @@ public function editAction(): ?Action
243235
})
244236
->after(function (Action $action, array $arguments) {
245237
$this->refreshBoard();
246-
238+
247239
$this->dispatch('kanban-record-updated', [
248240
'record' => $this->adapter->getModelById($arguments['record'])
249241
]);
@@ -349,52 +341,6 @@ public function updateRecordsOrderAndColumn(int|string $columnId, array $cardIds
349341
return $success;
350342
}
351343

352-
/**
353-
* Delete a card.
354-
*/
355-
public function deleteRecord(): void
356-
{
357-
if (!$this->permissions['canDelete']) {
358-
Notification::make()
359-
->title(__('You do not have permission to delete :records', ['records' => $this->config->getPluralCardLabel()]))
360-
->danger()
361-
->send();
362-
363-
return;
364-
}
365-
366-
$record = $this->adapter->getModelById($this->currentRecord);
367-
368-
if (!$record) {
369-
Notification::make()
370-
->title('Record not found')
371-
->danger()
372-
->send();
373-
374-
return;
375-
}
376-
377-
$success = $this->adapter->deleteRecord($record);
378-
379-
if ($success) {
380-
$this->refreshBoard();
381-
382-
$this->dispatch('kanban-record-deleted', [
383-
'record' => $record,
384-
]);
385-
386-
Notification::make()
387-
->title(__(':Record deleted successfully', ['record' => $this->config->getSingularCardLabel()]))
388-
->success()
389-
->send();
390-
} else {
391-
Notification::make()
392-
->title('Failed to delete record')
393-
->danger()
394-
->send();
395-
}
396-
}
397-
398344
/**
399345
* Render the component.
400346
*/

0 commit comments

Comments
 (0)