Andrew Wallo 9 maanden geleden
bovenliggende
commit
b4e1e96613

+ 27
- 0
app/Concerns/HasTabSpecificColumnToggles.php Bestand weergeven

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace App\Concerns;
4
+
5
+trait HasTabSpecificColumnToggles
6
+{
7
+    public function getTableColumnToggleFormStateSessionKey(): string
8
+    {
9
+        $table = class_basename($this::class);
10
+        $tab = $this->activeTab;
11
+
12
+        return "tables.{$table}_{$tab}_toggled_columns";
13
+    }
14
+
15
+    public function updatedActiveTab(): void
16
+    {
17
+        parent::updatedActiveTab();
18
+
19
+        // Load saved state for new tab or fall back to defaults
20
+        $this->toggledTableColumns = session(
21
+            $this->getTableColumnToggleFormStateSessionKey(),
22
+            $this->getDefaultTableColumnToggleState()
23
+        );
24
+
25
+        $this->updatedToggledTableColumns();
26
+    }
27
+}

+ 1
- 1
app/Filament/Company/Resources/Sales/EstimateResource.php Bestand weergeven

@@ -311,7 +311,7 @@ class EstimateResource extends Resource
311 311
                 Tables\Columns\TextColumn::make('total')
312 312
                     ->currencyWithConversion(static fn (Estimate $record) => $record->currency_code)
313 313
                     ->sortable()
314
-                    ->toggleable(),
314
+                    ->alignEnd(),
315 315
             ])
316 316
             ->filters([
317 317
                 Tables\Filters\SelectFilter::make('client')

+ 9
- 4
app/Filament/Company/Resources/Sales/InvoiceResource.php Bestand weergeven

@@ -317,7 +317,8 @@ class InvoiceResource extends Resource
317 317
                 Tables\Columns\TextColumn::make('due_date')
318 318
                     ->label('Due')
319 319
                     ->asRelativeDay()
320
-                    ->sortable(),
320
+                    ->sortable()
321
+                    ->hideOnTabs(['draft']),
321 322
                 Tables\Columns\TextColumn::make('date')
322 323
                     ->date()
323 324
                     ->sortable(),
@@ -334,16 +335,20 @@ class InvoiceResource extends Resource
334 335
                 Tables\Columns\TextColumn::make('total')
335 336
                     ->currencyWithConversion(static fn (Invoice $record) => $record->currency_code)
336 337
                     ->sortable()
337
-                    ->toggleable(),
338
+                    ->toggleable()
339
+                    ->alignEnd(),
338 340
                 Tables\Columns\TextColumn::make('amount_paid')
339 341
                     ->label('Amount Paid')
340 342
                     ->currencyWithConversion(static fn (Invoice $record) => $record->currency_code)
341 343
                     ->sortable()
342
-                    ->toggleable(),
344
+                    ->alignEnd()
345
+                    ->showOnTabs(['unpaid']),
343 346
                 Tables\Columns\TextColumn::make('amount_due')
344 347
                     ->label('Amount Due')
345 348
                     ->currencyWithConversion(static fn (Invoice $record) => $record->currency_code)
346
-                    ->sortable(),
349
+                    ->sortable()
350
+                    ->alignEnd()
351
+                    ->hideOnTabs(['draft']),
347 352
             ])
348 353
             ->filters([
349 354
                 Tables\Filters\SelectFilter::make('client')

+ 2
- 0
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ListInvoices.php Bestand weergeven

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\InvoiceResource\Pages;
4 4
 
5
+use App\Concerns\HasTabSpecificColumnToggles;
5 6
 use App\Enums\Accounting\InvoiceStatus;
6 7
 use App\Filament\Company\Resources\Sales\InvoiceResource;
7 8
 use App\Filament\Company\Resources\Sales\InvoiceResource\Widgets;
@@ -23,6 +24,7 @@ use Livewire\Attributes\Url;
23 24
 class ListInvoices extends ListRecords
24 25
 {
25 26
     use ExposesTableToWidgets;
27
+    use HasTabSpecificColumnToggles;
26 28
 
27 29
     protected static string $resource = InvoiceResource::class;
28 30
 

+ 14
- 3
app/Filament/Company/Resources/Sales/RecurringInvoiceResource.php Bestand weergeven

@@ -291,20 +291,31 @@ class RecurringInvoiceResource extends Resource
291 291
                     ->description(function (RecurringInvoice $record) {
292 292
                         return $record->getTimelineDescription();
293 293
                     }),
294
+                Tables\Columns\TextColumn::make('created_at')
295
+                    ->label('Created')
296
+                    ->date()
297
+                    ->sortable()
298
+                    ->showOnTabs(['draft']),
299
+                Tables\Columns\TextColumn::make('start_date')
300
+                    ->label('First Invoice')
301
+                    ->date()
302
+                    ->sortable()
303
+                    ->showOnTabs(['draft']),
294 304
                 Tables\Columns\TextColumn::make('last_date')
295 305
                     ->label('Last Invoice')
296 306
                     ->date()
297 307
                     ->sortable()
298
-                    ->searchable(),
308
+                    ->hideOnTabs(['draft']),
299 309
                 Tables\Columns\TextColumn::make('next_date')
300 310
                     ->label('Next Invoice')
301 311
                     ->date()
302 312
                     ->sortable()
303
-                    ->searchable(),
313
+                    ->hideOnTabs(['draft']),
304 314
                 Tables\Columns\TextColumn::make('total')
305 315
                     ->currencyWithConversion(static fn (RecurringInvoice $record) => $record->currency_code)
306 316
                     ->sortable()
307
-                    ->toggleable(),
317
+                    ->toggleable()
318
+                    ->alignEnd(),
308 319
             ])
309 320
             ->filters([
310 321
                 Tables\Filters\SelectFilter::make('client')

+ 3
- 0
app/Filament/Company/Resources/Sales/RecurringInvoiceResource/Pages/ListRecurringInvoices.php Bestand weergeven

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\RecurringInvoiceResource\Pages;
4 4
 
5
+use App\Concerns\HasTabSpecificColumnToggles;
5 6
 use App\Enums\Accounting\RecurringInvoiceStatus;
6 7
 use App\Filament\Company\Resources\Sales\RecurringInvoiceResource;
7 8
 use Filament\Actions;
@@ -12,6 +13,8 @@ use Illuminate\Database\Eloquent\Builder;
12 13
 
13 14
 class ListRecurringInvoices extends ListRecords
14 15
 {
16
+    use HasTabSpecificColumnToggles;
17
+
15 18
     protected static string $resource = RecurringInvoiceResource::class;
16 19
 
17 20
     protected function getHeaderActions(): array

+ 14
- 6
app/Models/Accounting/RecurringInvoice.php Bestand weergeven

@@ -200,8 +200,12 @@ class RecurringInvoice extends Document
200 200
         return $this->start_date?->gte(today()) ?? false;
201 201
     }
202 202
 
203
-    public function getScheduleDescription(): string
203
+    public function getScheduleDescription(): ?string
204 204
     {
205
+        if (! $this->hasSchedule()) {
206
+            return null;
207
+        }
208
+
205 209
         $frequency = $this->frequency;
206 210
 
207 211
         return match (true) {
@@ -215,7 +219,7 @@ class RecurringInvoice extends Document
215 219
 
216 220
             $frequency->isCustom() => $this->getCustomScheduleDescription(),
217 221
 
218
-            default => 'Not Configured',
222
+            default => null,
219 223
         };
220 224
     }
221 225
 
@@ -238,10 +242,10 @@ class RecurringInvoice extends Document
238 242
         return "Repeat every {$interval}{$dayDescription}";
239 243
     }
240 244
 
241
-    public function getEndDescription(): string
245
+    public function getEndDescription(): ?string
242 246
     {
243 247
         if (! $this->end_type) {
244
-            return 'Not configured';
248
+            return null;
245 249
         }
246 250
 
247 251
         return match (true) {
@@ -251,12 +255,16 @@ class RecurringInvoice extends Document
251 255
 
252 256
             $this->end_type->isOn() && $this->end_date => 'On ' . $this->end_date->toDefaultDateFormat(),
253 257
 
254
-            default => 'Not configured'
258
+            default => null,
255 259
         };
256 260
     }
257 261
 
258
-    public function getTimelineDescription(): string
262
+    public function getTimelineDescription(): ?string
259 263
     {
264
+        if (! $this->hasSchedule()) {
265
+            return null;
266
+        }
267
+
260 268
         $parts = [];
261 269
 
262 270
         if ($this->start_date) {

+ 4
- 0
app/Providers/FilamentCompaniesServiceProvider.php Bestand weergeven

@@ -276,6 +276,10 @@ class FilamentCompaniesServiceProvider extends PanelProvider
276 276
                 ->filtersFormWidth(MaxWidth::Small)
277 277
                 ->filtersTriggerAction(fn (Tables\Actions\Action $action) => $action->slideOver());
278 278
         }, isImportant: true);
279
+
280
+        Tables\Columns\TextColumn::configureUsing(function (Tables\Columns\TextColumn $column): void {
281
+            $column->placeholder('–');
282
+        });
279 283
     }
280 284
 
281 285
     /**

+ 17
- 0
app/Providers/MacroServiceProvider.php Bestand weergeven

@@ -19,6 +19,7 @@ use Filament\Forms\Components\Field;
19 19
 use Filament\Forms\Components\TextInput;
20 20
 use Filament\Infolists\Components\TextEntry;
21 21
 use Filament\Tables\Columns\TextColumn;
22
+use Filament\Tables\Contracts\HasTable;
22 23
 use Illuminate\Support\Carbon;
23 24
 use Illuminate\Support\ServiceProvider;
24 25
 
@@ -113,6 +114,22 @@ class MacroServiceProvider extends ServiceProvider
113 114
                 });
114 115
         });
115 116
 
117
+        TextColumn::macro('hideOnTabs', function (array $tabs): static {
118
+            $this->toggleable(isToggledHiddenByDefault: function (HasTable $livewire) use ($tabs) {
119
+                return in_array($livewire->activeTab, $tabs);
120
+            });
121
+
122
+            return $this;
123
+        });
124
+
125
+        TextColumn::macro('showOnTabs', function (array $tabs): static {
126
+            $this->toggleable(isToggledHiddenByDefault: function (HasTable $livewire) use ($tabs) {
127
+                return ! in_array($livewire->activeTab, $tabs);
128
+            });
129
+
130
+            return $this;
131
+        });
132
+
116 133
         TextColumn::macro('defaultDateFormat', function (): static {
117 134
             $localization = Localization::firstOrFail();
118 135
 

+ 9
- 0
resources/css/filament/company/theme.css Bestand weergeven

@@ -18,6 +18,15 @@
18 18
     display: inline-flex;
19 19
 }
20 20
 
21
+/* End Alignment sortable column enhancement */
22
+.fi-ta-header-cell:has(button.justify-end > svg.fi-ta-header-cell-sort-icon) {
23
+    padding-right: 0.25rem;
24
+}
25
+
26
+.fi-ta-cell:has(.fi-ta-col-wrp > .justify-end) {
27
+    padding-right: 1rem;
28
+}
29
+
21 30
 :not(.dark) .fi-body {
22 31
     position: relative;
23 32
     background-color: #E8E9EB;

Laden…
Annuleren
Opslaan