Andrew Wallo 10 maanden geleden
bovenliggende
commit
cb3dc6ac9a

+ 112
- 2
app/Filament/Company/Resources/Common/ClientResource.php Bestand weergeven

@@ -4,6 +4,7 @@ namespace App\Filament\Company\Resources\Common;
4 4
 
5 5
 use App\Filament\Company\Resources\Common\ClientResource\Pages;
6 6
 use App\Filament\Forms\Components\CreateCurrencySelect;
7
+use App\Filament\Forms\Components\PhoneBuilder;
7 8
 use App\Models\Common\Client;
8 9
 use Filament\Forms;
9 10
 use Filament\Forms\Form;
@@ -22,7 +23,7 @@ class ClientResource extends Resource
22 23
                 Forms\Components\Section::make('General Information')
23 24
                     ->schema([
24 25
                         Forms\Components\TextInput::make('name')
25
-                            ->label('Client')
26
+                            ->label('Client Name')
26 27
                             ->required()
27 28
                             ->maxLength(255),
28 29
                         CreateCurrencySelect::make('currency_code')
@@ -35,9 +36,115 @@ class ClientResource extends Resource
35 36
                         Forms\Components\Textarea::make('notes')
36 37
                             ->columnSpanFull(),
37 38
                     ])->columns(),
39
+                Forms\Components\Section::make('Primary Contact')
40
+                    ->relationship('primaryContact')
41
+                    ->schema([
42
+                        Forms\Components\Hidden::make('is_primary')
43
+                            ->default(true),
44
+                        Forms\Components\TextInput::make('first_name')
45
+                            ->label('First Name')
46
+                            ->required()
47
+                            ->maxLength(255),
48
+                        Forms\Components\TextInput::make('last_name')
49
+                            ->label('Last Name')
50
+                            ->required()
51
+                            ->maxLength(255),
52
+                        Forms\Components\TextInput::make('email')
53
+                            ->label('Email')
54
+                            ->required()
55
+                            ->email()
56
+                            ->maxLength(255),
57
+                        PhoneBuilder::make('phones')
58
+                            ->hiddenLabel()
59
+                            ->blockLabels(false)
60
+                            ->default([
61
+                                ['type' => 'office'],
62
+                            ])
63
+                            ->blocks([
64
+                                Forms\Components\Builder\Block::make('office')
65
+                                    ->label('Office')
66
+                                    ->schema([
67
+                                        Forms\Components\TextInput::make('number')
68
+                                            ->label('Office')
69
+                                            ->required()
70
+                                            ->maxLength(15),
71
+                                    ])->maxItems(1),
72
+                                Forms\Components\Builder\Block::make('mobile')
73
+                                    ->label('Mobile')
74
+                                    ->schema([
75
+                                        Forms\Components\TextInput::make('number')
76
+                                            ->label('Mobile')
77
+                                            ->required()
78
+                                            ->maxLength(15),
79
+                                    ])->maxItems(1),
80
+                                Forms\Components\Builder\Block::make('toll_free')
81
+                                    ->label('Toll Free')
82
+                                    ->schema([
83
+                                        Forms\Components\TextInput::make('number')
84
+                                            ->label('Toll Free')
85
+                                            ->required()
86
+                                            ->maxLength(15),
87
+                                    ])->maxItems(1),
88
+                                Forms\Components\Builder\Block::make('fax')
89
+                                    ->label('Fax')
90
+                                    ->schema([
91
+                                        Forms\Components\TextInput::make('number')
92
+                                            ->label('Fax')
93
+                                            ->live()
94
+                                            ->maxLength(15),
95
+                                    ])->maxItems(1),
96
+                            ])
97
+                            ->deletable(fn (PhoneBuilder $builder) => $builder->getItemsCount() > 1)
98
+                            ->reorderable(false)
99
+                            ->blockNumbers(false)
100
+                            ->addActionLabel('Add Phone'),
101
+                    ]),
102
+                Forms\Components\Repeater::make('secondaryContacts')
103
+                    ->relationship()
104
+                    ->columnSpanFull()
105
+                    ->hiddenLabel()
106
+                    ->defaultItems(0)
107
+                    ->addActionLabel('Add Contact')
108
+                    ->schema([
109
+                        Forms\Components\TextInput::make('first_name')
110
+                            ->label('First Name')
111
+                            ->required()
112
+                            ->maxLength(255),
113
+                        Forms\Components\TextInput::make('last_name')
114
+                            ->label('Last Name')
115
+                            ->required()
116
+                            ->maxLength(255),
117
+                        Forms\Components\TextInput::make('email')
118
+                            ->label('Email')
119
+                            ->required()
120
+                            ->email()
121
+                            ->maxLength(255),
122
+                        PhoneBuilder::make('phones')
123
+                            ->hiddenLabel()
124
+                            ->blockLabels(false)
125
+                            ->default([
126
+                                ['type' => 'office'],
127
+                            ])
128
+                            ->blocks([
129
+                                Forms\Components\Builder\Block::make('office')
130
+                                    ->label('Office')
131
+                                    ->schema([
132
+                                        Forms\Components\TextInput::make('number')
133
+                                            ->label('Office')
134
+                                            ->required()
135
+                                            ->maxLength(255),
136
+                                    ])->maxItems(1),
137
+                            ])
138
+                            ->addable(false)
139
+                            ->deletable(false)
140
+                            ->reorderable(false)
141
+                            ->blockNumbers(false),
142
+                    ]),
38 143
                 Forms\Components\Section::make('Billing')
39 144
                     ->relationship('billingAddress')
40 145
                     ->schema([
146
+                        Forms\Components\Hidden::make('type')
147
+                            ->default('billing'),
41 148
                         Forms\Components\TextInput::make('address_line_1')
42 149
                             ->label('Address Line 1')
43 150
                             ->required()
@@ -65,6 +172,8 @@ class ClientResource extends Resource
65 172
                 Forms\Components\Section::make('Shipping')
66 173
                     ->relationship('shippingAddress')
67 174
                     ->schema([
175
+                        Forms\Components\Hidden::make('type')
176
+                            ->default('shipping'),
68 177
                         Forms\Components\TextInput::make('recipient')
69 178
                             ->label('Recipient')
70 179
                             ->required()
@@ -98,7 +207,8 @@ class ClientResource extends Resource
98 207
                             ->maxLength(255),
99 208
                         Forms\Components\Textarea::make('notes')
100 209
                             ->label('Delivery Instructions')
101
-                            ->maxLength(255),
210
+                            ->maxLength(255)
211
+                            ->columnSpanFull(),
102 212
                     ])->columns(),
103 213
             ]);
104 214
     }

+ 6
- 0
app/Filament/Company/Resources/Common/ClientResource/Pages/CreateClient.php Bestand weergeven

@@ -4,8 +4,14 @@ namespace App\Filament\Company\Resources\Common\ClientResource\Pages;
4 4
 
5 5
 use App\Filament\Company\Resources\Common\ClientResource;
6 6
 use Filament\Resources\Pages\CreateRecord;
7
+use Filament\Support\Enums\MaxWidth;
7 8
 
8 9
 class CreateClient extends CreateRecord
9 10
 {
10 11
     protected static string $resource = ClientResource::class;
12
+
13
+    public function getMaxContentWidth(): MaxWidth | string | null
14
+    {
15
+        return MaxWidth::FiveExtraLarge;
16
+    }
11 17
 }

+ 6
- 0
app/Filament/Company/Resources/Common/ClientResource/Pages/EditClient.php Bestand weergeven

@@ -5,6 +5,7 @@ namespace App\Filament\Company\Resources\Common\ClientResource\Pages;
5 5
 use App\Filament\Company\Resources\Common\ClientResource;
6 6
 use Filament\Actions;
7 7
 use Filament\Resources\Pages\EditRecord;
8
+use Filament\Support\Enums\MaxWidth;
8 9
 
9 10
 class EditClient extends EditRecord
10 11
 {
@@ -16,4 +17,9 @@ class EditClient extends EditRecord
16 17
             Actions\DeleteAction::make(),
17 18
         ];
18 19
     }
20
+
21
+    public function getMaxContentWidth(): MaxWidth | string | null
22
+    {
23
+        return MaxWidth::FiveExtraLarge;
24
+    }
19 25
 }

+ 10
- 0
app/Filament/Forms/Components/PhoneBuilder.php Bestand weergeven

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+namespace App\Filament\Forms\Components;
4
+
5
+use Filament\Forms\Components\Builder;
6
+
7
+class PhoneBuilder extends Builder
8
+{
9
+    protected string $view = 'filament.forms.components.phone-builder';
10
+}

+ 12
- 0
app/Models/Common/Client.php Bestand weergeven

@@ -36,6 +36,18 @@ class Client extends Model
36 36
         return $this->morphMany(Contact::class, 'contactable');
37 37
     }
38 38
 
39
+    public function primaryContact(): MorphOne
40
+    {
41
+        return $this->morphOne(Contact::class, 'contactable')
42
+            ->where('is_primary', true);
43
+    }
44
+
45
+    public function secondaryContacts(): MorphMany
46
+    {
47
+        return $this->morphMany(Contact::class, 'contactable')
48
+            ->where('is_primary', false);
49
+    }
50
+
39 51
     public function currency(): BelongsTo
40 52
     {
41 53
         return $this->belongsTo(Currency::class, 'currency_code', 'code');

+ 1
- 0
app/Models/Common/Contact.php Bestand weergeven

@@ -33,6 +33,7 @@ class Contact extends Model
33 33
 
34 34
     protected $casts = [
35 35
         'type' => ContactType::class,
36
+        'phones' => 'array',
36 37
     ];
37 38
 
38 39
     public function contactable(): MorphTo

+ 11
- 0
app/Models/Company.php Bestand weergeven

@@ -6,6 +6,7 @@ use App\Enums\Setting\DocumentType;
6 6
 use App\Models\Accounting\AccountSubtype;
7 7
 use App\Models\Banking\BankAccount;
8 8
 use App\Models\Banking\ConnectedBankAccount;
9
+use App\Models\Common\Client;
9 10
 use App\Models\Common\Contact;
10 11
 use App\Models\Common\Offering;
11 12
 use App\Models\Core\Department;
@@ -73,6 +74,11 @@ class Company extends FilamentCompaniesCompany implements HasAvatar
73 74
         return $this->hasMany(Accounting\Account::class, 'company_id');
74 75
     }
75 76
 
77
+    public function addresses(): HasMany
78
+    {
79
+        return $this->hasMany(Common\Address::class, 'company_id');
80
+    }
81
+
76 82
     public function adjustments(): HasMany
77 83
     {
78 84
         return $this->hasMany(Accounting\Adjustment::class, 'company_id');
@@ -94,6 +100,11 @@ class Company extends FilamentCompaniesCompany implements HasAvatar
94 100
 
95 101
     }
96 102
 
103
+    public function clients(): HasMany
104
+    {
105
+        return $this->hasMany(Client::class, 'company_id');
106
+    }
107
+
97 108
     public function contacts(): HasMany
98 109
     {
99 110
         return $this->hasMany(Contact::class, 'company_id');

+ 36
- 36
composer.lock Bestand weergeven

@@ -497,16 +497,16 @@
497 497
         },
498 498
         {
499 499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.328.2",
500
+            "version": "3.329.0",
501 501
             "source": {
502 502
                 "type": "git",
503 503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "63a6366a8011dffec3d1ef838c97ca6b6ddb17a2"
504
+                "reference": "37249799204e04cf3686d2b361cfd417d3dab123"
505 505
             },
506 506
             "dist": {
507 507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/63a6366a8011dffec3d1ef838c97ca6b6ddb17a2",
509
-                "reference": "63a6366a8011dffec3d1ef838c97ca6b6ddb17a2",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/37249799204e04cf3686d2b361cfd417d3dab123",
509
+                "reference": "37249799204e04cf3686d2b361cfd417d3dab123",
510 510
                 "shasum": ""
511 511
             },
512 512
             "require": {
@@ -536,7 +536,7 @@
536 536
                 "paragonie/random_compat": ">= 2",
537 537
                 "phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5",
538 538
                 "psr/cache": "^1.0",
539
-                "psr/simple-cache": "^1.0",
539
+                "psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
540 540
                 "sebastian/comparator": "^1.2.3 || ^4.0",
541 541
                 "yoast/phpunit-polyfills": "^1.0"
542 542
             },
@@ -589,9 +589,9 @@
589 589
             "support": {
590 590
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
591 591
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
592
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.328.2"
592
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.329.0"
593 593
             },
594
-            "time": "2024-11-19T20:28:51+00:00"
594
+            "time": "2024-11-21T19:16:09+00:00"
595 595
         },
596 596
         {
597 597
             "name": "aws/aws-sdk-php-laravel",
@@ -4973,31 +4973,31 @@
4973 4973
         },
4974 4974
         {
4975 4975
             "name": "nunomaduro/termwind",
4976
-            "version": "v2.2.0",
4976
+            "version": "v2.3.0",
4977 4977
             "source": {
4978 4978
                 "type": "git",
4979 4979
                 "url": "https://github.com/nunomaduro/termwind.git",
4980
-                "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3"
4980
+                "reference": "52915afe6a1044e8b9cee1bcff836fb63acf9cda"
4981 4981
             },
4982 4982
             "dist": {
4983 4983
                 "type": "zip",
4984
-                "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/42c84e4e8090766bbd6445d06cd6e57650626ea3",
4985
-                "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3",
4984
+                "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/52915afe6a1044e8b9cee1bcff836fb63acf9cda",
4985
+                "reference": "52915afe6a1044e8b9cee1bcff836fb63acf9cda",
4986 4986
                 "shasum": ""
4987 4987
             },
4988 4988
             "require": {
4989 4989
                 "ext-mbstring": "*",
4990 4990
                 "php": "^8.2",
4991
-                "symfony/console": "^7.1.5"
4991
+                "symfony/console": "^7.1.8"
4992 4992
             },
4993 4993
             "require-dev": {
4994
-                "illuminate/console": "^11.28.0",
4995
-                "laravel/pint": "^1.18.1",
4994
+                "illuminate/console": "^11.33.2",
4995
+                "laravel/pint": "^1.18.2",
4996 4996
                 "mockery/mockery": "^1.6.12",
4997 4997
                 "pestphp/pest": "^2.36.0",
4998
-                "phpstan/phpstan": "^1.12.6",
4998
+                "phpstan/phpstan": "^1.12.11",
4999 4999
                 "phpstan/phpstan-strict-rules": "^1.6.1",
5000
-                "symfony/var-dumper": "^7.1.5",
5000
+                "symfony/var-dumper": "^7.1.8",
5001 5001
                 "thecodingmachine/phpstan-strict-rules": "^1.0.0"
5002 5002
             },
5003 5003
             "type": "library",
@@ -5040,7 +5040,7 @@
5040 5040
             ],
5041 5041
             "support": {
5042 5042
                 "issues": "https://github.com/nunomaduro/termwind/issues",
5043
-                "source": "https://github.com/nunomaduro/termwind/tree/v2.2.0"
5043
+                "source": "https://github.com/nunomaduro/termwind/tree/v2.3.0"
5044 5044
             },
5045 5045
             "funding": [
5046 5046
                 {
@@ -5056,7 +5056,7 @@
5056 5056
                     "type": "github"
5057 5057
                 }
5058 5058
             ],
5059
-            "time": "2024-10-15T16:15:16+00:00"
5059
+            "time": "2024-11-21T10:39:51+00:00"
5060 5060
         },
5061 5061
         {
5062 5062
             "name": "openspout/openspout",
@@ -9100,16 +9100,16 @@
9100 9100
         },
9101 9101
         {
9102 9102
             "name": "voku/portable-ascii",
9103
-            "version": "2.0.1",
9103
+            "version": "2.0.3",
9104 9104
             "source": {
9105 9105
                 "type": "git",
9106 9106
                 "url": "https://github.com/voku/portable-ascii.git",
9107
-                "reference": "b56450eed252f6801410d810c8e1727224ae0743"
9107
+                "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d"
9108 9108
             },
9109 9109
             "dist": {
9110 9110
                 "type": "zip",
9111
-                "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b56450eed252f6801410d810c8e1727224ae0743",
9112
-                "reference": "b56450eed252f6801410d810c8e1727224ae0743",
9111
+                "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b1d923f88091c6bf09699efcd7c8a1b1bfd7351d",
9112
+                "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d",
9113 9113
                 "shasum": ""
9114 9114
             },
9115 9115
             "require": {
@@ -9134,7 +9134,7 @@
9134 9134
             "authors": [
9135 9135
                 {
9136 9136
                     "name": "Lars Moelleken",
9137
-                    "homepage": "http://www.moelleken.org/"
9137
+                    "homepage": "https://www.moelleken.org/"
9138 9138
                 }
9139 9139
             ],
9140 9140
             "description": "Portable ASCII library - performance optimized (ascii) string functions for php.",
@@ -9146,7 +9146,7 @@
9146 9146
             ],
9147 9147
             "support": {
9148 9148
                 "issues": "https://github.com/voku/portable-ascii/issues",
9149
-                "source": "https://github.com/voku/portable-ascii/tree/2.0.1"
9149
+                "source": "https://github.com/voku/portable-ascii/tree/2.0.3"
9150 9150
             },
9151 9151
             "funding": [
9152 9152
                 {
@@ -9170,7 +9170,7 @@
9170 9170
                     "type": "tidelift"
9171 9171
                 }
9172 9172
             ],
9173
-            "time": "2022-03-08T17:03:00+00:00"
9173
+            "time": "2024-11-21T01:49:47+00:00"
9174 9174
         },
9175 9175
         {
9176 9176
             "name": "webmozart/assert",
@@ -9327,16 +9327,16 @@
9327 9327
         },
9328 9328
         {
9329 9329
             "name": "fakerphp/faker",
9330
-            "version": "v1.24.0",
9330
+            "version": "v1.24.1",
9331 9331
             "source": {
9332 9332
                 "type": "git",
9333 9333
                 "url": "https://github.com/FakerPHP/Faker.git",
9334
-                "reference": "a136842a532bac9ecd8a1c723852b09915d7db50"
9334
+                "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5"
9335 9335
             },
9336 9336
             "dist": {
9337 9337
                 "type": "zip",
9338
-                "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/a136842a532bac9ecd8a1c723852b09915d7db50",
9339
-                "reference": "a136842a532bac9ecd8a1c723852b09915d7db50",
9338
+                "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5",
9339
+                "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5",
9340 9340
                 "shasum": ""
9341 9341
             },
9342 9342
             "require": {
@@ -9384,9 +9384,9 @@
9384 9384
             ],
9385 9385
             "support": {
9386 9386
                 "issues": "https://github.com/FakerPHP/Faker/issues",
9387
-                "source": "https://github.com/FakerPHP/Faker/tree/v1.24.0"
9387
+                "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1"
9388 9388
             },
9389
-            "time": "2024-11-07T15:11:20+00:00"
9389
+            "time": "2024-11-21T13:46:39+00:00"
9390 9390
         },
9391 9391
         {
9392 9392
             "name": "fidry/cpu-core-counter",
@@ -9632,16 +9632,16 @@
9632 9632
         },
9633 9633
         {
9634 9634
             "name": "laravel/pint",
9635
-            "version": "v1.18.1",
9635
+            "version": "v1.18.2",
9636 9636
             "source": {
9637 9637
                 "type": "git",
9638 9638
                 "url": "https://github.com/laravel/pint.git",
9639
-                "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9"
9639
+                "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64"
9640 9640
             },
9641 9641
             "dist": {
9642 9642
                 "type": "zip",
9643
-                "url": "https://api.github.com/repos/laravel/pint/zipball/35c00c05ec43e6b46d295efc0f4386ceb30d50d9",
9644
-                "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9",
9643
+                "url": "https://api.github.com/repos/laravel/pint/zipball/f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64",
9644
+                "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64",
9645 9645
                 "shasum": ""
9646 9646
             },
9647 9647
             "require": {
@@ -9694,7 +9694,7 @@
9694 9694
                 "issues": "https://github.com/laravel/pint/issues",
9695 9695
                 "source": "https://github.com/laravel/pint"
9696 9696
             },
9697
-            "time": "2024-09-24T17:22:50+00:00"
9697
+            "time": "2024-11-20T09:33:46+00:00"
9698 9698
         },
9699 9699
         {
9700 9700
             "name": "laravel/sail",

+ 6
- 6
package-lock.json Bestand weergeven

@@ -1026,9 +1026,9 @@
1026 1026
             }
1027 1027
         },
1028 1028
         "node_modules/caniuse-lite": {
1029
-            "version": "1.0.30001680",
1030
-            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz",
1031
-            "integrity": "sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==",
1029
+            "version": "1.0.30001683",
1030
+            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001683.tgz",
1031
+            "integrity": "sha512-iqmNnThZ0n70mNwvxpEC2nBJ037ZHZUoBI5Gorh1Mw6IlEAZujEoU1tXA628iZfzm7R9FvFzxbfdgml82a3k8Q==",
1032 1032
             "dev": true,
1033 1033
             "funding": [
1034 1034
                 {
@@ -1187,9 +1187,9 @@
1187 1187
             "license": "MIT"
1188 1188
         },
1189 1189
         "node_modules/electron-to-chromium": {
1190
-            "version": "1.5.63",
1191
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.63.tgz",
1192
-            "integrity": "sha512-ddeXKuY9BHo/mw145axlyWjlJ1UBt4WK3AlvkT7W2AbqfRQoacVoRUCF6wL3uIx/8wT9oLKXzI+rFqHHscByaA==",
1190
+            "version": "1.5.64",
1191
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.64.tgz",
1192
+            "integrity": "sha512-IXEuxU+5ClW2IGEYFC2T7szbyVgehupCWQe5GNh+H065CD6U6IFN0s4KeAMFGNmQolRU4IV7zGBWSYMmZ8uuqQ==",
1193 1193
             "dev": true,
1194 1194
             "license": "ISC"
1195 1195
         },

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

@@ -8,6 +8,10 @@
8 8
     @apply hidden;
9 9
 }
10 10
 
11
+.fi-fo-repeater-item {
12
+    @apply divide-y divide-gray-200 rounded-xl bg-white dark:bg-gray-900;
13
+}
14
+
11 15
 .fi-fo-field-wrp.report-hidden-label {
12 16
     @apply lg:mt-8;
13 17
 }

+ 185
- 0
resources/views/filament/forms/components/phone-builder.blade.php Bestand weergeven

@@ -0,0 +1,185 @@
1
+@php
2
+    use Filament\Forms\Components\Actions\Action;
3
+    use Filament\Support\Enums\Alignment;
4
+
5
+    $containers = $getChildComponentContainers();
6
+    $blockPickerBlocks = $getBlockPickerBlocks();
7
+    $blockPickerColumns = $getBlockPickerColumns();
8
+    $blockPickerWidth = $getBlockPickerWidth();
9
+    $hasBlockPreviews = $hasBlockPreviews();
10
+    $hasInteractiveBlockPreviews = $hasInteractiveBlockPreviews();
11
+
12
+    $addAction = $getAction($getAddActionName());
13
+    $addBetweenAction = $getAction($getAddBetweenActionName());
14
+    $cloneAction = $getAction($getCloneActionName());
15
+    $collapseAllAction = $getAction($getCollapseAllActionName());
16
+    $editAction = $getAction($getEditActionName());
17
+    $expandAllAction = $getAction($getExpandAllActionName());
18
+    $deleteAction = $getAction($getDeleteActionName());
19
+    $moveDownAction = $getAction($getMoveDownActionName());
20
+    $moveUpAction = $getAction($getMoveUpActionName());
21
+    $reorderAction = $getAction($getReorderActionName());
22
+    $extraItemActions = $getExtraItemActions();
23
+
24
+    $isAddable = $isAddable();
25
+    $isCloneable = $isCloneable();
26
+    $isCollapsible = $isCollapsible();
27
+    $isDeletable = $isDeletable();
28
+    $isReorderableWithButtons = $isReorderableWithButtons();
29
+    $isReorderableWithDragAndDrop = $isReorderableWithDragAndDrop();
30
+
31
+    $collapseAllActionIsVisible = $isCollapsible && $collapseAllAction->isVisible();
32
+    $expandAllActionIsVisible = $isCollapsible && $expandAllAction->isVisible();
33
+
34
+    $statePath = $getStatePath();
35
+@endphp
36
+
37
+<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
38
+    <div
39
+        x-data="{}"
40
+        {{
41
+            $attributes
42
+                ->merge($getExtraAttributes(), escape: false)
43
+                ->class(['fi-fo-builder grid gap-y-4'])
44
+        }}
45
+    >
46
+        @if ($collapseAllActionIsVisible || $expandAllActionIsVisible)
47
+            <div
48
+                @class([
49
+                    'flex gap-x-3',
50
+                    'hidden' => count($containers) < 2,
51
+                ])
52
+            >
53
+                @if ($collapseAllActionIsVisible)
54
+                    <span
55
+                        x-on:click="$dispatch('builder-collapse', '{{ $statePath }}')"
56
+                    >
57
+                        {{ $collapseAllAction }}
58
+                    </span>
59
+                @endif
60
+
61
+                @if ($expandAllActionIsVisible)
62
+                    <span
63
+                        x-on:click="$dispatch('builder-expand', '{{ $statePath }}')"
64
+                    >
65
+                        {{ $expandAllAction }}
66
+                    </span>
67
+                @endif
68
+            </div>
69
+        @endif
70
+
71
+        @if (count($containers))
72
+            <ul
73
+                x-sortable
74
+                data-sortable-animation-duration="{{ $getReorderAnimationDuration() }}"
75
+                wire:end.stop="{{ 'mountFormComponentAction(\'' . $statePath . '\', \'reorder\', { items: $event.target.sortable.toArray() })' }}"
76
+                class="space-y-6"
77
+            >
78
+                @php
79
+                    $hasBlockLabels = $hasBlockLabels();
80
+                    $hasBlockIcons = $hasBlockIcons();
81
+                    $hasBlockNumbers = $hasBlockNumbers();
82
+                @endphp
83
+
84
+                @foreach ($containers as $uuid => $item)
85
+                    @php
86
+                        $visibleExtraItemActions = array_filter(
87
+                            $extraItemActions,
88
+                            fn (Action $action): bool => $action(['item' => $uuid])->isVisible(),
89
+                        );
90
+                        $cloneAction = $cloneAction(['item' => $uuid]);
91
+                        $cloneActionIsVisible = $isCloneable && $cloneAction->isVisible();
92
+                        $deleteAction = $deleteAction(['item' => $uuid]);
93
+                        $deleteActionIsVisible = $isDeletable && $deleteAction->isVisible();
94
+                        $editAction = $editAction(['item' => $uuid]);
95
+                        $editActionIsVisible = $hasBlockPreviews && $editAction->isVisible();
96
+                        $moveDownAction = $moveDownAction(['item' => $uuid])->disabled($loop->last);
97
+                        $moveDownActionIsVisible = $isReorderableWithButtons && $moveDownAction->isVisible();
98
+                        $moveUpAction = $moveUpAction(['item' => $uuid])->disabled($loop->first);
99
+                        $moveUpActionIsVisible = $isReorderableWithButtons && $moveUpAction->isVisible();
100
+                        $reorderActionIsVisible = $isReorderableWithDragAndDrop && $reorderAction->isVisible();
101
+                    @endphp
102
+
103
+                    <li
104
+                        wire:key="{{ $this->getId() }}.{{ $item->getStatePath() }}.{{ $field::class }}.item"
105
+                        x-sortable-item="{{ $uuid }}"
106
+                        class="flex items-center gap-x-4"
107
+                    >
108
+                        <!-- Input Field -->
109
+                        <div class="w-full">
110
+                            {{ $item }}
111
+                        </div>
112
+
113
+                        <!-- Delete Action -->
114
+                        @if ($deleteActionIsVisible)
115
+                            <div class="mt-6">
116
+                                {{ $deleteAction }}
117
+                            </div>
118
+                        @endif
119
+                    </li>
120
+
121
+
122
+                    @if (! $loop->last)
123
+                        @if ($isAddable && $addBetweenAction(['afterItem' => $uuid])->isVisible())
124
+                            <li class="relative -top-2 !mt-0 h-0">
125
+                                <div
126
+                                    class="flex w-full justify-center opacity-0 transition duration-75 hover:opacity-100"
127
+                                >
128
+                                    <div
129
+                                        class="fi-fo-builder-block-picker-ctn rounded-lg bg-white dark:bg-gray-900"
130
+                                    >
131
+                                        <x-filament-forms::builder.block-picker
132
+                                            :action="$addBetweenAction"
133
+                                            :after-item="$uuid"
134
+                                            :columns="$blockPickerColumns"
135
+                                            :blocks="$blockPickerBlocks"
136
+                                            :state-path="$statePath"
137
+                                            :width="$blockPickerWidth"
138
+                                        >
139
+                                            <x-slot name="trigger">
140
+                                                {{ $addBetweenAction(['afterItem' => $uuid]) }}
141
+                                            </x-slot>
142
+                                        </x-filament-forms::builder.block-picker>
143
+                                    </div>
144
+                                </div>
145
+                            </li>
146
+                        @elseif (filled($labelBetweenItems = $getLabelBetweenItems()))
147
+                            <li
148
+                                class="relative border-t border-gray-200 dark:border-white/10"
149
+                            >
150
+                                <span
151
+                                    class="absolute -top-3 left-3 px-1 text-sm font-medium"
152
+                                >
153
+                                    {{ $labelBetweenItems }}
154
+                                </span>
155
+                            </li>
156
+                        @endif
157
+                    @endif
158
+                @endforeach
159
+            </ul>
160
+        @endif
161
+
162
+        @if ($isAddable && $addAction->isVisible())
163
+            <x-filament-forms::builder.block-picker
164
+                :action="$addAction"
165
+                :blocks="$blockPickerBlocks"
166
+                :columns="$blockPickerColumns"
167
+                :state-path="$statePath"
168
+                :width="$blockPickerWidth"
169
+                @class([
170
+                    'flex',
171
+                    match ($getAddActionAlignment()) {
172
+                        Alignment::Start, Alignment::Left => 'justify-start',
173
+                        Alignment::Center, null => 'justify-center',
174
+                        Alignment::End, Alignment::Right => 'justify-end',
175
+                        default => $alignment,
176
+                    },
177
+                ])
178
+            >
179
+                <x-slot name="trigger">
180
+                    {{ $addAction }}
181
+                </x-slot>
182
+            </x-filament-forms::builder.block-picker>
183
+        @endif
184
+    </div>
185
+</x-dynamic-component>

Laden…
Annuleren
Opslaan