Skip to content

Commit 9a4762f

Browse files
committed
Improve card labels
1 parent 9d251f5 commit 9a4762f

File tree

8 files changed

+50
-33
lines changed

8 files changed

+50
-33
lines changed

resources/views/livewire/column.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ class="text-xs text-primary-600 dark:text-primary-400">
7575
<div wire:loading.remove wire:target="loadMoreItems('{{ $columnId }}')"
7676
class="text-xs text-gray-400">
7777
{{ count($column['items']) }}
78-
/ {{ $column['total'] }} {{ $config->pluralCardLabel ?? 'Records' }}
78+
/ {{ $column['total'] }} {{ $config->getPluralCardLabel() }}
7979
</div>
8080
</div>
8181
@endif
8282
@else
8383
<x-flowforge::empty-column
8484
:columnId="$columnId"
85+
:pluralCardLabel="$config->getPluralCardLabel()"
8586
/>
8687
@endif
8788
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
@props(['columnId'])
1+
@props(['pluralCardLabel'])
22

33
<div class="p-3 flex flex-col items-center justify-center h-full min-h-[150px] rounded-lg border-2 border-dashed border-gray-200 dark:border-gray-800">
44
<svg class="w-10 h-10 text-gray-400 dark:text-gray-600 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
55
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
66
</svg>
77
<p class="text-sm text-gray-500 dark:text-gray-400">
8-
{{ __('No records in this column') }}
8+
{{ __('No :cardLabel in this column', ['cardLabel' => strtolower($pluralCardLabel)]) }}
99
</p>
1010
</div>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class="w-full h-full flex flex-col relative"
99
state: {
1010
columns: @js($columns),
1111
columnField: '{{ $config->getColumnField() }}',
12-
cardLabel: '{{ $config->getCardLabel() ?? 'record' }}',
13-
pluralCardLabel: '{{ $config->pluralCardLabel ?? 'Records' }}'
12+
cardLabel: '{{ $config->getSingularCardLabel() }}',
13+
pluralCardLabel: '{{ $config->getPluralCardLabel() }}'
1414
}
1515
})"
1616
>
@@ -29,6 +29,6 @@ class="w-full h-full flex flex-col relative"
2929
</div>
3030
</div>
3131

32-
<x-flowforge::modals.create-record :permissions="$this->permissions" :config="$config" />
33-
<x-flowforge::modals.edit-record :permissions="$this->permissions" :config="$config" />
32+
<x-flowforge::modals.create-record :permissions="$this->permissions" :singularCardLabel="$config->getSingularCardLabel()" />
33+
<x-flowforge::modals.edit-record :permissions="$this->permissions" :singularCardLabel="$config->getSingularCardLabel()" />
3434
</div>

resources/views/livewire/modals/create-record.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@props(['config'])
1+
@props(['singularCardLabel'])
22

33
<x-filament::modal id="create-record-modal"
4-
:heading="__('Create New :cardLabel', ['cardLabel' => $config->getCardLabel() ?? 'Record'])"
5-
:description="__('Add a new :cardLabel to the board', ['cardLabel' => strtolower($config->getCardLabel() ?? 'record')])"
4+
:heading="__('Create New :cardLabel', ['cardLabel' => $singularCardLabel])"
5+
:description="__('Add a new :cardLabel to the board', ['cardLabel' => strtolower($singularCardLabel)])"
66
>
77

88
{{ $this->createRecordForm }}
@@ -19,7 +19,7 @@
1919
<x-filament::button
2020
wire:click="createRecord"
2121
>
22-
{{ __('Create :cardLabel', ['cardLabel' => $config->getCardLabel() ?? 'Record']) }}
22+
{{ __('Create :cardLabel', ['cardLabel' => $singularCardLabel]) }}
2323
</x-filament::button>
2424
</div>
2525
</x-slot>

resources/views/livewire/modals/edit-record.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@props(['config', 'permissions'])
1+
@props(['singularCardLabel', 'permissions'])
22

3-
<x-filament::modal id="edit-record-modal" :heading="__('Edit :cardLabel', ['cardLabel' => $config->getCardLabel() ?? 'Record'])">
3+
<x-filament::modal id="edit-record-modal" :heading="__('Edit :cardLabel', ['cardLabel' => $singularCardLabel])">
44
{{ $this->editRecordForm }}
55

66
<x-slot name="footer">

src/Config/KanbanConfig.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,23 @@ public function getOrderField(): ?string
111111
}
112112

113113
/**
114-
* Get the label for individual cards.
114+
* Get the singular card label.
115115
*
116-
* @return string|null The singular card label, or null to use default
116+
* @return string
117117
*/
118-
public function getCardLabel(): ?string
118+
public function getSingularCardLabel(): string
119119
{
120-
return $this->cardLabel;
120+
return Str::singular($this->cardLabel ?? 'Record');
121121
}
122122

123123
/**
124-
* Get the plural label for collection of cards.
124+
* Get the plural card label.
125125
*
126-
* @return string|null The plural card label, or null to use default
126+
* @return string
127127
*/
128-
public function getPluralCardLabel(): ?string
128+
public function getPluralCardLabel(): string
129129
{
130-
return $this->pluralCardLabel;
130+
return $this->pluralCardLabel ?? Str::plural($this->getSingularCardLabel());
131131
}
132132

133133
/**

src/Filament/Pages/KanbanBoardPage.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Relaticle\Flowforge\Filament\Pages;
66

77
use Filament\Pages\Page;
8+
use Illuminate\Support\Str;
89
use Relaticle\Flowforge\Adapters\DefaultKanbanAdapter;
910
use Relaticle\Flowforge\Config\KanbanConfig;
1011
use Relaticle\Flowforge\Contracts\KanbanAdapterInterface;
@@ -26,11 +27,6 @@ public function __construct()
2627
$this->config = new KanbanConfig;
2728
}
2829

29-
public function updating()
30-
{
31-
info('update');
32-
}
33-
3430
/**
3531
* Set the field that stores the column value.
3632
*
@@ -129,6 +125,26 @@ public function cardLabel(string $label): static
129125
{
130126
$this->config = $this->config->withCardLabel($label);
131127

128+
// Auto-set the plural form if not already set
129+
if ($this->config->getPluralCardLabel() === null) {
130+
$this->config = $this->config->withPluralCardLabel(
131+
(string) Str::of($label)->plural()
132+
);
133+
}
134+
135+
return $this;
136+
}
137+
138+
/**
139+
* Set the plural label for multiple cards.
140+
*
141+
* @param string $label
142+
* @return KanbanBoardPage
143+
*/
144+
public function pluralCardLabel(string $label): static
145+
{
146+
$this->config = $this->config->withPluralCardLabel($label);
147+
132148
return $this;
133149
}
134150

src/Livewire/KanbanBoard.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,12 @@ public function createRecord(): void
405405
]);
406406

407407
Notification::make()
408-
->title('Card created')
408+
->title(__(':Record created successfully', ['record' => $this->config->getSingularCardLabel()]))
409409
->success()
410410
->send();
411411
} else {
412412
Notification::make()
413-
->title('Failed to create card')
413+
->title('Failed to create record')
414414
->danger()
415415
->send();
416416
}
@@ -439,7 +439,7 @@ public function updateRecord(): void
439439

440440
if (! $record) {
441441
Notification::make()
442-
->title('Card not found')
442+
->title(__(':Record not found', ['record' => $this->config->getSingularCardLabel()]))
443443
->danger()
444444
->send();
445445

@@ -457,12 +457,12 @@ public function updateRecord(): void
457457
]);
458458

459459
Notification::make()
460-
->title('Card updated')
460+
->title(__(':Record updated successfully', ['record' => $this->config->getSingularCardLabel()]))
461461
->success()
462462
->send();
463463
} else {
464464
Notification::make()
465-
->title('Failed to update card')
465+
->title(__(':Record update failed', ['record' => $this->config->getSingularCardLabel()]))
466466
->danger()
467467
->send();
468468
}
@@ -499,7 +499,7 @@ public function deleteRecord(): void
499499
{
500500
if (! $this->permissions['canDelete']) {
501501
Notification::make()
502-
->title('You do not have permission to delete records')
502+
->title(__('You do not have permission to delete :records', ['records' => $this->config->getPluralCardLabel()]))
503503
->danger()
504504
->send();
505505

@@ -527,7 +527,7 @@ public function deleteRecord(): void
527527
]);
528528

529529
Notification::make()
530-
->title('Record deleted')
530+
->title(__(':Record deleted successfully', ['record' => $this->config->getSingularCardLabel()]))
531531
->success()
532532
->send();
533533
} else {

0 commit comments

Comments
 (0)