Skip to content

Commit b57c19e

Browse files
committed
wip: no-items component update and modal component creation
1 parent 961fac6 commit b57c19e

File tree

6 files changed

+63
-18
lines changed

6 files changed

+63
-18
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "javaabu/forms",
3+
"version": "v1.99.0",
34
"description": "Laravel Blade components for form elements",
45
"homepage": "https://github.com/Javaabu/forms",
56
"license": "MIT",

config/config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
'frameworks' => [
3030
'bootstrap-5' => [
31-
'icon-prefix' => 'fa',
31+
'icon-prefix' => 'fa-regular',
3232
'date-icon' => 'fa-calendar',
3333
'datetime-icon' => 'fa-calendar',
3434
'time-icon' => 'fa-clock',
@@ -43,6 +43,7 @@
4343
'inline-entry-label-class' => 'col-sm-6 col-md-4',
4444
'inline-entry-class' => 'col-sm-6 col-md-8',
4545
'search-icon' => 'fa-search',
46+
'no-items-icon' => 'fa-file',
4647
],
4748

4849
'material-admin-26' => [

resources/views/bootstrap-5/no-items.blade.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
<div class="col-md-6">
44
<div class="card">
55
<div class="card-body text-center">
6-
<i class="{{ $icon ?? 'zmdi zmdi-file' }} main-icon mb-4"></i>
6+
<i class="{{ $icon }} main-icon mb-4"></i>
77
<p class="lead mb-4">
8-
{{ __('It\'s a bit lonely here.') }}<br/>
9-
{{ __('Let\'s create some new :model_type.', ['model_type' => $modelType ?? __('items') ]) }}
8+
@if($title){{ $title }} <br/> @endif
9+
{{ $message }}
1010
</p>
11-
@can('create', $model)
11+
@if($showCreate)
1212
@if($slot->isNotEmpty())
1313
{{ $slot }}
1414
@else
15-
<a href="{{ $createAction ?? '#' }}" class="btn btn-lg btn-primary btn-icon-text btn-raised">
16-
<i class="zmdi zmdi-plus"></i> {{ __('Create New') }}
15+
<a href="{{ $createAction }}" class="btn btn-lg btn-primary btn-icon-text btn-raised">
16+
<i class="fal fa-plus me-2"></i> {{ __('Create New') }}
1717
</a>
1818
@endif
19-
@endcan
19+
@endif
2020
</div>
2121
</div>
2222
</div>

src/Views/Components/Modal.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Javaabu\Forms\Views\Components;
4+
5+
class Modal extends Component
6+
{
7+
protected string $view = 'modal';
8+
9+
public string $title;
10+
11+
/**
12+
* Create a new component instance.
13+
*
14+
* @return void
15+
*/
16+
public function __construct(
17+
string $title = '',
18+
string $framework = ''
19+
) {
20+
parent::__construct($framework);
21+
22+
$this->title = $title;
23+
}
24+
}

src/Views/Components/NoItems.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,46 @@ class NoItems extends Component
66
{
77
protected string $view = 'no-items';
88

9-
public string|object $model;
9+
public null|string|object $model;
1010
public string $createAction;
11-
public string $modelType;
11+
public ?string $modelType = null;
1212
public string $icon;
13+
public bool $showCreate;
14+
public string $title;
15+
public string $message;
1316

1417
/**
1518
* Create a new component instance.
1619
*
1720
* @return void
1821
*/
1922
public function __construct(
20-
string|object $model,
21-
string $createAction,
22-
string $modelType,
23-
string $icon,
24-
string $framework = '',
25-
) {
23+
string $createAction = '#',
24+
null|string|object $model = null,
25+
string $icon = '',
26+
?string $modelType = null,
27+
?bool $showCreate = null,
28+
?string $title = null,
29+
?string $message = null,
30+
string $framework = '',
31+
)
32+
{
2633
parent::__construct($framework);
2734

2835
$this->model = $model;
2936
$this->createAction = $createAction;
3037
$this->modelType = $modelType;
31-
$this->icon = $icon;
38+
39+
$this->icon = $icon ?: $this->getFrameworkIcon($this->frameworkConfig('no-items-icon'));
40+
$this->showCreate = is_null($showCreate)
41+
? ($this->model && auth()->user() ? auth()->user()->can('create', $this->model) : false)
42+
: $showCreate;
43+
44+
$this->title = is_null($title)
45+
? __('It\'s a bit lonely here.')
46+
: $title;
47+
$this->message = is_null($message)
48+
? __('Let\'s create some new :model_type.', ['model_type' => $this->modelType ?? __('items')])
49+
: $message;
3250
}
3351
}

tests/Feature/NoItemsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ public function it_can_generated_bulk_actions_for_material_admin_26()
2323
/** @test */
2424
public function it_can_generated_bulk_actions_for_bootstrap_5()
2525
{
26+
$this->withoutExceptionHandling();
2627
$this->setFrameworkBootstrap5();
2728
$this->registerTestRoute('no-items');
2829

2930
$this->visit('/no-items')
3031
->see('Let\'s create some new activities')
31-
->seeElement('.zmdi.zmdi-file');
32+
->seeElement('.fa-regular.fa-file');
3233
}
3334
}

0 commit comments

Comments
 (0)