Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat-customer-purchases-chart' i…
Browse files Browse the repository at this point in the history
…nto feat-customer-purchases-chart

# Conflicts:
#	Changelog.md
  • Loading branch information
molnarerwin committed Nov 25, 2024
2 parents ec5e31d + b195d47 commit eb5abe2
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
php: ['8.2', '8.3']
laravel: ['10.0', '10.48', '11.0', '11.14']
php: ['8.2', '8.3', '8.4']
laravel: ['10.0', '10.48', '11.0', '11.33']
name: PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }}
steps:
- name: Checkout
Expand Down
8 changes: 6 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## Unreleased
##### 2024-XX-YY
- Added Customer purchases chart to the Customer show page

## 4.4.0
##### 2024-11-23

- Added CRUD for Countries and Provinces
- Added the `globe` icon
- Added the `globe` and `flag` icons
- Added support for setting `empty.html` on the table widget
- Added Customer purchases chart to the Customer show page
- Added PHP 8.4 support

## 4.3.0
##### 2024-10-29
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ext-json": "*",
"konekt/concord": "^1.15",
"konekt/customer": "^3.0",
"konekt/address": "^3.0",
"konekt/address": "^3.4",
"konekt/user": "^3.0",
"konekt/acl": "^2.0",
"konekt/menu": "^1.9",
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Now you should see this:
+----+---------------------+------+----------+------------------+-----------------+
| # | Name | Kind | Version | Id | Namespace |
+----+---------------------+------+----------+------------------+-----------------+
| 1. | Konekt AppShell Box | Box | 4.3.0 | konekt.app_shell | Konekt\AppShell |
| 1. | Konekt AppShell Box | Box | 4.4.0 | konekt.app_shell | Konekt\AppShell |
+----+---------------------+------+----------+------------------+-----------------+
```

Expand Down
1 change: 1 addition & 0 deletions docs/widgets-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[
'empty' => [
'text' => __('This is a text that gets shown if the dataset for the table is empty')
'html' => '<a href="#">This is a string that gets rendered as-is without escaping</a>'
]
]
```
3 changes: 3 additions & 0 deletions src/Contracts/Requests/CreateProvince.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

interface CreateProvince extends BaseRequest
{
public function wantsToSeed(): bool;

public function getSeederId(): ?string;
}
13 changes: 12 additions & 1 deletion src/Http/Controllers/CountryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Konekt\Address\Contracts\Country;
use Konekt\Address\Models\CountryProxy;
use Konekt\Address\Seeds\Countries;
use Konekt\Address\Seeds\ProvinceSeeders;
use Konekt\AppShell\Contracts\Requests\CreateCountry;
use Konekt\AppShell\Contracts\Requests\UpdateCountry;

Expand Down Expand Up @@ -59,7 +60,17 @@ public function store(CreateCountry $request): RedirectResponse

public function show(Country $country): View
{
return view('appshell::country.show', ['country' => $country]);
$availableProvinceSeeders = [];
if ($country->provinces->isEmpty()) {
foreach (ProvinceSeeders::availableSeedersOfCountry($country->id) as $id => $class) {
$availableProvinceSeeders[$id] = $class::getName();
}
}

return view('appshell::country.show', [
'country' => $country,
'availableProvinceSeeders' => $availableProvinceSeeders,
]);
}

public function edit(Country $country): View
Expand Down
38 changes: 27 additions & 11 deletions src/Http/Controllers/ProvinceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
use Illuminate\Http\RedirectResponse;
use Konekt\Address\Contracts\Country;
use Konekt\Address\Contracts\Province;
use Konekt\Address\Contracts\ProvinceSeeder;
use Konekt\Address\Models\ProvinceProxy;
use Konekt\Address\Models\ProvinceTypeProxy;
use Konekt\Address\Seeds\ProvinceSeeders;
use Konekt\AppShell\Contracts\Requests\CreateProvince;
use Konekt\AppShell\Contracts\Requests\UpdateProvince;

Expand All @@ -30,17 +32,31 @@ public function create(Country $country): View
public function store(Country $country, CreateProvince $request): RedirectResponse
{
try {
$province = ProvinceProxy::create(
array_merge(
$request->validated(),
['country_id' => $country->id]
)
);

flash()->success(__(':name has been added to :country', [
'name' => $province->name,
'country' => $country->name
]));
if ($request->wantsToSeed()) {
if ($country->provinces->isNotEmpty()) {
flash()->error(__('Can not generate the data, because the list of provinces is not empty'));

return redirect()->back()->withInput();
}

/** @var ProvinceSeeder $seeder */
$seeder = ProvinceSeeders::make($request->getSeederId());
$seeder->run();

flash()->success(__(':name have been successfully created', ['name' => $seeder::getName()]));
} else {
$province = ProvinceProxy::create(
array_merge(
$request->validated(),
['country_id' => $country->id]
)
);

flash()->success(__(':name has been added to :country', [
'name' => $province->name,
'country' => $country->name
]));
}
} catch (\Exception $e) {
flash()->error(__('Error: :msg', ['msg' => $e->getMessage()]));

Expand Down
18 changes: 15 additions & 3 deletions src/Http/Requests/CreateProvince.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Konekt\Address\Models\ProvinceTypeProxy;
use Konekt\Address\Seeds\ProvinceSeeders;
use Konekt\AppShell\Contracts\Requests\CreateProvince as CreateProvinceContract;

class CreateProvince extends FormRequest implements CreateProvinceContract
Expand All @@ -16,17 +17,17 @@ public function rules(): array
$country = $this->route('country');

return [
'name' => 'required|string|max:255',
'name' => 'required_without:seed|string|max:255',
'code' => [
'required',
'required_without:seed',
'string',
'max:16',
'uppercase',
Rule::unique('provinces')->where(function ($query) use ($country) {
return $query->where('country_id', $country->id);
}),
],
'type' => ['required', 'string', 'max:255', Rule::in(ProvinceTypeProxy::values())],
'type' => ['required_without:seed', 'string', 'max:255', Rule::in(ProvinceTypeProxy::values())],
'parent_id' => [
'sometimes',
'nullable',
Expand All @@ -35,9 +36,20 @@ public function rules(): array
return $query->where('country_id', $country->id);
}),
],
'seed' => ['sometimes', 'string', Rule::in(ProvinceSeeders::ids())]
];
}

public function wantsToSeed(): bool
{
return $this->has('seed');
}

public function getSeederId(): ?string
{
return $this->input('seed');
}

public function attributes(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions src/Icons/AppShellIcons.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ final class AppShellIcons
public const FILE = 'file';
public const COMMENT = 'comment';
public const GLOBE = 'globe';
public const FLAG = 'flag';
}
1 change: 1 addition & 0 deletions src/Icons/FontAwesome6IconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class FontAwesome6IconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'comment',
AppShellIcons::GLOBE => 'earth-africa',
AppShellIcons::FLAG => 'flag',
];

public static function getName(): string
Expand Down
1 change: 1 addition & 0 deletions src/Icons/FontAwesome6ProIconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class FontAwesome6ProIconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'comment-lines',
AppShellIcons::GLOBE => 'earth-africa',
AppShellIcons::FLAG => 'flag-swallowtail',
];

public function __construct()
Expand Down
1 change: 1 addition & 0 deletions src/Icons/FontAwesomeIconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class FontAwesomeIconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'comment-dots',
AppShellIcons::GLOBE => 'globe-africa',
AppShellIcons::FLAG => 'flag',
];

public static function getName(): string
Expand Down
1 change: 1 addition & 0 deletions src/Icons/LineIconsTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LineIconsTheme implements IconTheme
AppShellIcons::FILE => 'empty-file',
AppShellIcons::COMMENT => 'comments-alt-2',
AppShellIcons::GLOBE => 'world',
AppShellIcons::FLAG => 'flag-alt',
];

public static function getName(): string
Expand Down
1 change: 1 addition & 0 deletions src/Icons/LucideIconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LucideIconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'message-square-text',
AppShellIcons::GLOBE => 'globe',
AppShellIcons::FLAG => 'flag',
];

public static function getName(): string
Expand Down
1 change: 1 addition & 0 deletions src/Icons/TablerIconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class TablerIconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'message',
AppShellIcons::GLOBE => 'world',
AppShellIcons::FLAG => 'flag-3',
];

public static function getName(): string
Expand Down
1 change: 1 addition & 0 deletions src/Icons/ZmdiIconTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ZmdiIconTheme implements IconTheme
AppShellIcons::FILE => 'file',
AppShellIcons::COMMENT => 'comment',
AppShellIcons::GLOBE => 'globe',
AppShellIcons::FLAG => 'flag',
];

public static function getName(): string
Expand Down
2 changes: 1 addition & 1 deletion src/resources/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

return [
'name' => 'AppShell',
'version' => '4.3.0'
'version' => '4.4.0'
];
12 changes: 1 addition & 11 deletions src/resources/views/country/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
@push('page-actions')
@if($countries->isEmpty())
{!! Form::open(['route' => ['appshell.country.store', ['seed' => 1]], 'class' => 'd-inline']) !!}
<x-appshell::button variant="outline-secondary" size="sm" route="appshell.country.create" icon="download"
onclick="submitSeedCountriesRequest()">
<x-appshell::button variant="outline-secondary" size="sm" route="appshell.country.create" icon="download">
{{ __('Generate all countries') }}
</x-appshell::button>
{!! Form::close() !!}
Expand All @@ -25,12 +24,3 @@
</x-appshell::card>

@stop

@push('scripts')
<script>
function submitSeedCountriesRequest() {
}
</script>
@endpush
5 changes: 4 additions & 1 deletion src/resources/views/country/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

<x-appshell::card>
<x-slot:title>{{ __('Provinces') }}</x-slot:title>
@include('appshell::province._index', ['provinces' => $country->provinces])
@include('appshell::province._index', [
'provinces' => $country->provinces,
'availableProvinceSeeders' => $availableProvinceSeeders,
])
</x-appshell::card>

@stop
29 changes: 15 additions & 14 deletions src/resources/views/province/_index.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
@foreach($provinces as $province)
@can('edit provinces')
<a href="{{ route('appshell.province.show', [$country, $province]) }}">
<button class="btn btn-sm btn-secondary" type="button" title="{{ $province->type->label() }}">
{{ $province->name }}
</button>
</a>
@else
<button class="btn btn-sm dropdown-toggle btn-secondary" type="button" title="{{ $province->type->label() }}">
{{ $province->name }}
</button>
@endcan
<x-appshell::button variant="secondary" size="sm" :title="$province->type->label()" class="mb-2"
:href="auth()->user()->can('view provinces') ? route('appshell.province.show', [$country, $province]) : '#'"
>
{{ $province->name }}
</x-appshell::button>
@endforeach

@can('create provinces')
<a href="{{ route('appshell.province.create', $country) }}" class="btn btn-sm btn-success" title="{{ __('Add province') }}">
{!! icon('+') !!}
</a>
@foreach($availableProvinceSeeders as $id => $name)
{!! Form::open(['route' => ['appshell.province.store', [$country, 'seed' => $id]], 'class' => 'd-inline']) !!}
<x-appshell::button variant="outline-secondary" size="sm" route="appshell.country.create" icon="download" class="mb-2">
{{ __('Generate :seeder_name', ['seeder_name' => $name]) }}
</x-appshell::button>
{!! Form::close() !!}
@endforeach

<x-appshell::button :href="route('appshell.province.create', $country)" :title="__('Add province')"
variant="success" size="sm" icon="+" class="mb-2"></x-appshell::button>
@endcan
Loading

0 comments on commit eb5abe2

Please sign in to comment.