Skip to content

Commit e7b13a3

Browse files
committed
UP
1 parent cd3b80b commit e7b13a3

File tree

7 files changed

+49
-32
lines changed

7 files changed

+49
-32
lines changed

resources/views/livewire/card.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class="kanban-card mb-3 bg-white dark:bg-gray-800 rounded-lg shadow-sm border bo
1414
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400 line-clamp-2">{{ $card['description'] }}</p>
1515
@endif
1616

17-
@if(!empty($config->cardAttributes))
17+
@if(!empty($card['attributes']))
1818
<div class="mt-2 flex flex-wrap gap-2">
19-
@foreach($config->cardAttributes as $attribute => $label)
19+
@foreach($card['attributes'] as $attribute => $label)
2020
@if(isset($card['attributes'][$attribute]) && !empty($card['attributes'][$attribute]['value']))
2121
<x-flowforge::card-badge
2222
:label="$card['attributes'][$attribute]['label']"

resources/views/livewire/column.blade.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['columnId', 'column', 'config'])
1+
@props(['permissions', '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">
@@ -14,18 +14,20 @@ class="ml-2 px-2.5 py-0.5 rounded-full text-xs font-medium kanban-color-{{ $colu
1414
{{ $column['total'] ?? (isset($column['items']) ? count($column['items']) : 0) }}
1515
</div>
1616
</div>
17-
<button
18-
type="button"
19-
wire:click="openCreateForm('{{ $columnId }}')"
20-
x-on:click="$dispatch('open-modal', { id: 'create-card-modal' })"
21-
class="text-gray-400 hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400"
22-
>
23-
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"
24-
xmlns="http://www.w3.org/2000/svg">
25-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
26-
d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
27-
</svg>
28-
</button>
17+
@if($permissions['create'])
18+
<button
19+
type="button"
20+
wire:click="openCreateForm('{{ $columnId }}')"
21+
x-on:click="$dispatch('open-modal', { id: 'create-card-modal' })"
22+
class="text-gray-400 hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400"
23+
>
24+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"
25+
xmlns="http://www.w3.org/2000/svg">
26+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
27+
d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
28+
</svg>
29+
</button>
30+
@endif
2931
</div>
3032

3133
<!-- Column Content -->
@@ -57,22 +59,28 @@ class="p-3 flex-1 overflow-y-auto overflow-x-hidden"
5759
"
5860
class="py-3 text-center"
5961
>
60-
<div wire:loading wire:target="loadMoreItems('{{ $columnId }}')" class="text-xs text-primary-600 dark:text-primary-400">
62+
<div wire:loading wire:target="loadMoreItems('{{ $columnId }}')"
63+
class="text-xs text-primary-600 dark:text-primary-400">
6164
{{ __('Loading more cards...') }}
6265
<div class="mt-1 flex justify-center">
63-
<svg class="animate-spin h-4 w-4 text-primary-600 dark:text-primary-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
64-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
65-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
66+
<svg class="animate-spin h-4 w-4 text-primary-600 dark:text-primary-400"
67+
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
68+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"
69+
stroke-width="4"></circle>
70+
<path class="opacity-75" fill="currentColor"
71+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
6672
</svg>
6773
</div>
6874
</div>
69-
<div wire:loading.remove wire:target="loadMoreItems('{{ $columnId }}')" class="text-xs text-gray-400">
70-
{{ count($column['items']) }} / {{ $column['total'] }} {{ $config->pluralCardLabel ?? 'Records' }}
75+
<div wire:loading.remove wire:target="loadMoreItems('{{ $columnId }}')"
76+
class="text-xs text-gray-400">
77+
{{ count($column['items']) }}
78+
/ {{ $column['total'] }} {{ $config->pluralCardLabel ?? 'Records' }}
7179
</div>
7280
</div>
7381
@endif
7482
@else
75-
<x-flowforge::empty-column
83+
<x-flowforge::empty-column
7684
:columnId="$columnId"
7785
/>
7886
@endif

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class="w-full h-full flex flex-col relative"
2222
:columnId="$columnId"
2323
:column="$column"
2424
:config="$config"
25+
:permissions="$this->permissions"
2526
wire:key="column-{{ $columnId }}"
2627
/>
2728
@endforeach

src/Concerns/CardFormattingTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function formatCardForDisplay(Model $model): array
2222
{
2323
$titleField = $this->config->getTitleField();
2424
$descriptionField = $this->config->getDescriptionField();
25-
$cardAttributes = $this->config->getCardAttributes();
25+
$recordAttributes = $this->config->getRecordAttributes();
2626
$columnField = $this->config->getColumnField();
2727

2828
$card = [
@@ -35,7 +35,7 @@ protected function formatCardForDisplay(Model $model): array
3535
$card['description'] = $model->{$descriptionField};
3636
}
3737

38-
foreach ($cardAttributes as $key => $label) {
38+
foreach ($recordAttributes as $key => $label) {
3939
$field = is_string($key) ? $key : $label;
4040
$card['attributes'][$field] = [
4141
'label' => is_string($key) ? $label : $field,

src/Config/KanbanConfig.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @method self withColumnColors(array $columnColors) Set the color mappings for columns
2222
* @method self withTitleField(string $titleField) Set the field name used for card titles
2323
* @method self withDescriptionField(string|null $descriptionField) Set the field name for card descriptions
24-
* @method self withCardAttributes(array $cardAttributes) Set the additional fields to display on cards
24+
* @method self withRecordAttributes(array $recordAttributes) Set the additional fields to display on cards
2525
* @method self withOrderField(string|null $orderField) Set the field name for maintaining card order
2626
* @method self withCardLabel(string|null $cardLabel) Set the label for individual cards
2727
* @method self withPluralCardLabel(string|null $pluralCardLabel) Set the plural label for collection of cards
@@ -34,7 +34,7 @@ public function __construct(
3434
private array|bool|null $columnColors = null,
3535
private string $titleField = 'title',
3636
private ?string $descriptionField = null,
37-
private array $cardAttributes = [],
37+
private array $recordAttributes = [],
3838
private ?string $orderField = null,
3939
private ?string $cardLabel = null,
4040
private ?string $pluralCardLabel = null,
@@ -97,9 +97,9 @@ public function getDescriptionField(): ?string
9797
*
9898
* @return array<string, string> Map of attribute names to their display labels
9999
*/
100-
public function getCardAttributes(): array
100+
public function getRecordAttributes(): array
101101
{
102-
return $this->cardAttributes;
102+
return $this->recordAttributes;
103103
}
104104

105105
/**
@@ -241,7 +241,7 @@ public function toLivewire(): array
241241
'columnColors' => $this->columnColors,
242242
'titleField' => $this->titleField,
243243
'descriptionField' => $this->descriptionField,
244-
'cardAttributes' => $this->cardAttributes,
244+
'recordAttributes' => $this->recordAttributes,
245245
'orderField' => $this->orderField,
246246
'cardLabel' => $this->cardLabel,
247247
'pluralCardLabel' => $this->pluralCardLabel,
@@ -256,7 +256,7 @@ public static function fromLivewire($value): KanbanConfig
256256
$value['columnColors'],
257257
$value['titleField'],
258258
$value['descriptionField'],
259-
$value['cardAttributes'],
259+
$value['recordAttributes'],
260260
$value['orderField'],
261261
$value['cardLabel'],
262262
$value['pluralCardLabel']

src/Filament/Pages/KanbanBoardPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public function descriptionField(string $field): static
8484
*
8585
* @param array<string, string> $attributes
8686
*/
87-
public function cardAttributes(array $attributes): static
87+
public function recordAttributes(array $attributes): static
8888
{
89-
$this->config = $this->config->withCardAttributes($attributes);
89+
$this->config = $this->config->withRecordAttributes($attributes);
9090

9191
return $this;
9292
}

src/Livewire/KanbanBoard.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Filament\Forms\Form;
1010
use Filament\Notifications\Notification;
1111
use Illuminate\Support\Collection;
12+
use Illuminate\Support\Facades\Gate;
1213
use Illuminate\View\View;
1314
use Livewire\Attributes\Locked;
1415
use Livewire\Attributes\Validate;
@@ -91,6 +92,8 @@ class KanbanBoard extends Component implements HasForms
9192
*/
9293
public int $cardsIncrement;
9394

95+
public array $permissions = [];
96+
9497
/**
9598
* Initialize the Kanban board.
9699
*
@@ -110,6 +113,11 @@ public function mount(
110113
$this->searchable = $searchable;
111114
$this->config = $this->adapter->getConfig();
112115

116+
// Check permissions
117+
$this->permissions = [
118+
'create' => Gate::check('create', $this->adapter->baseQuery->getModel())
119+
];
120+
113121
// Set default limits
114122
$initialCardsCount = $initialCardsCount ?? 5;
115123
$this->cardsIncrement = $cardsIncrement ?? 10;

0 commit comments

Comments
 (0)