Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
inikoo committed Jan 23, 2025
2 parents a2dd007 + 297c430 commit 19ef596
Show file tree
Hide file tree
Showing 22 changed files with 701 additions and 103 deletions.
32 changes: 18 additions & 14 deletions app/Actions/Accounting/Invoice/UI/ShowInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ public function htmlResponse(Invoice $invoice, ActionRequest $request): Response
]
];
}
$actions = [];
if (!app()->environment('production')) {
$actions = [
[
'type' => 'button',
'style' => 'create',
'label' => __('create refund'),
'route' => [
'method' => 'post',
'name' => 'grp.models.refund.create',
'parameters' => [
'invoice' => $invoice->id
]
],
]
];
}

return Inertia::render(
'Org/Accounting/Invoice',
Expand All @@ -150,20 +167,7 @@ public function htmlResponse(Invoice $invoice, ActionRequest $request): Response
'icon' => ['fal', 'fa-file-invoice-dollar'],
'title' => $invoice->reference
],
'actions' => [
[
'type' => 'button',
'style' => 'create',
'label' => __('create refund'),
'route' => [
'method' => 'post',
'name' => 'grp.models.refund.create',
'parameters' => [
'invoice' => $invoice->id
]
],
]
]
'actions' => $actions
],
'tabs' => [
'current' => $this->tab,
Expand Down
20 changes: 20 additions & 0 deletions app/Actions/Comms/OrgPostRoom/UI/IndexOrgPostRooms.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use App\InertiaTable\InertiaTable;
use App\Models\Catalogue\Shop;
use App\Models\Comms\OrgPostRoom;
use App\Models\Fulfilment\Fulfilment;
use App\Models\SysAdmin\Organisation;
use App\Services\QueryBuilder;
use Closure;
Expand All @@ -31,6 +32,11 @@ class IndexOrgPostRooms extends OrgAction
{
use WithCommsSubNavigation;

/**
* @var \App\Models\Fulfilment\Fulfilment
*/
private Fulfilment|Shop $parent;

public function handle(Organisation $organisation, $prefix = null): LengthAwarePaginator
{
$globalSearch = AllowedFilter::callback('global', function ($query, $value) {
Expand Down Expand Up @@ -117,6 +123,10 @@ public function jsonResponse(LengthAwarePaginator $orgPostRooms): AnonymousResou

public function authorize(ActionRequest $request): bool
{
if ($this->parent instanceof Fulfilment) {
return $this->canEdit = $request->user()->hasPermissionTo("fulfilment-shop.{$this->fulfilment->id}.edit");
}

return $request->user()->hasAnyPermission([
'shop-admin.'.$this->shop->id,
'marketing.'.$this->shop->id.'.view',
Expand Down Expand Up @@ -183,10 +193,20 @@ public function htmlResponse(LengthAwarePaginator $orgPostRooms, ActionRequest $

public function inShop(Organisation $organisation, Shop $shop, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $shop;

$this->initialisationFromShop($shop, $request);
return $this->handle($organisation);
}

public function inFulfilment(Organisation $organisation, Fulfilment $fulfilment, ActionRequest $request): LengthAwarePaginator
{
$this->parent = $fulfilment;
$this->initialisationFromFulfilment($fulfilment, $request);

return $this->handle($organisation);
}

public function getBreadcrumbs(string $routeName, array $routeParameters, string $suffix = null): array
{
$headCrumb = function (array $routeParameters = []) {
Expand Down
8 changes: 8 additions & 0 deletions app/Actions/Comms/OrgPostRoom/UI/ShowOrgPostRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Http\Resources\Mail\OutboxesResource;
use App\Models\Catalogue\Shop;
use App\Models\Comms\OrgPostRoom;
use App\Models\Fulfilment\Fulfilment;
use App\Models\SysAdmin\Organisation;
use Inertia\Inertia;
use Inertia\Response;
Expand Down Expand Up @@ -51,6 +52,13 @@ public function inShop(Organisation $organisation, Shop $shop, OrgPostRoom $orgP
return $this->handle($orgPostRoom);
}

public function inFulfilment(Organisation $organisation, Fulfilment $fulfilment, OrgPostRoom $orgPostRoom, ActionRequest $request): OrgPostRoom
{
$this->initialisationFromFulfilment($fulfilment, $request)->withTab(OrgPostRoomsTabsEnum::values());

return $this->handle($orgPostRoom);
}

public function htmlResponse(OrgPostRoom $orgPostRoom, ActionRequest $request): Response
{

Expand Down
49 changes: 47 additions & 2 deletions app/Actions/Comms/Traits/WithCommsSubNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ trait WithCommsSubNavigation
protected function getCommsNavigation(Organisation $organisation, Shop|Fulfilment $parent): array
{
if ($parent instanceof Shop) {
$shop = $parent;
return $this->getNavigationRouteShops($organisation, $parent);
} else {
$shop = $parent->shop;
return $this->getNavigationRouteFulfilments($organisation, $parent);
}
}

protected function getNavigationRouteShops(Organisation $organisation, Shop $shop): array
{
return [

[
Expand Down Expand Up @@ -62,4 +65,46 @@ protected function getCommsNavigation(Organisation $organisation, Shop|Fulfilmen

];
}

protected function getNavigationRouteFulfilments(Organisation $organisation, Fulfilment $fulfilment): array
{
return [

[
"isAnchor" => true,
"label" => __("Comms Dashboard"),
"route" => [
"name" => "grp.org.fulfilments.show.operations.comms.dashboard",
"parameters" => [$fulfilment->organisation->slug, $fulfilment->slug],
],
"leftIcon" => [
"icon" => ["fal", "fa-chart-network"],
"tooltip" => __("Tree view of the webpages"),
],
],
[
"label" => __("Post Rooms"),
"route" => [
"name" => "grp.org.fulfilments.show.operations.comms.post-rooms.index",
"parameters" => [$organisation->slug, $fulfilment->slug],
],
"leftIcon" => [
"icon" => ["fal", "fa-inbox-out"],
"tooltip" => __("Post Rooms"),
],
],
[
"label" => __("Outboxes"),
"route" => [
"name" => "grp.org.fulfilments.show.operations.comms.outboxes",
"parameters" => [$fulfilment->organisation->slug, $fulfilment->slug],
],
"leftIcon" => [
"icon" => ["fal", "fa-inbox-out"],
"tooltip" => __("Outboxes"),
],
],

];
}
}
4 changes: 2 additions & 2 deletions app/Actions/Comms/UI/ShowCommsDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public function getBreadcrumbs(string $routeName, array $routeParameters): array
]
]
),
'grp.org.fulfilments.show.comms.dashboard' =>
'grp.org.fulfilments.show.comms.dashboard', 'grp.org.fulfilments.show.operations.comms.dashboard' =>
array_merge(
ShowFulfilment::make()->getBreadcrumbs($routeParameters),
[
[
'type' => 'simple',
'simple' => [
'route' => [
'name' => 'grp.org.fulfilments.show.comms.dashboard',
'name' => 'grp.org.fulfilments.show.operations.comms.dashboard',
'parameters' => $routeParameters
],
'label' => __('Comms')
Expand Down
5 changes: 5 additions & 0 deletions app/Actions/Fulfilment/Fulfilment/UI/EditFulfilment.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function htmlResponse(Fulfilment $fulfilment, ActionRequest $request): Re
"label" => __("Logo"),
"value" => $fulfilment->shop->imageSources(320, 320)
],
// "image_id" => [
// "type" => "image_crop_square",
// "label" => __("favicon"),
// "value" => $fulfilment->shop->imageSources(32, 32)
// ],
]
],
[
Expand Down
3 changes: 3 additions & 0 deletions app/Actions/Fulfilment/Pallet/ImportPalletReturnItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function handle(PalletReturn $palletReturn, $file): Upload
$file,
[
'model' => 'PalletReturnItem',
'parent_type' => class_basename($palletReturn),
'parent_id' => $palletReturn->id,
'customer_id' => $palletReturn->fulfilmentCustomer->customer_id,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function asController(Organisation $organisation, PalletDelivery $palletD
public function action(PalletDelivery $palletDelivery, $modelData): PalletDelivery
{
$this->action = true;
$this->palletDelivery = $palletDelivery;
$this->initialisationFromFulfilment($palletDelivery->fulfilment, $modelData);

return $this->handle($palletDelivery, $this->validatedData);
Expand Down
1 change: 1 addition & 0 deletions app/Actions/Fulfilment/PalletReturn/UpdatePalletReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function asController(Organisation $organisation, PalletReturn $palletRet
public function action(PalletReturn $palletReturn, $modelData): PalletReturn
{
$this->action = true;
$this->palletReturn = $palletReturn;
$this->initialisationFromFulfilment($palletReturn->fulfilment, $modelData);

return $this->handle($palletReturn, $this->validatedData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function asController(PalletDelivery $palletDelivery, ActionRequest $requ
public function action(PalletDelivery $palletDelivery, $modelData): PalletDelivery
{
$this->action = true;
$this->palletDelivery = $palletDelivery;
$this->initialisationFulfilmentActions($palletDelivery->fulfilmentCustomer, $modelData);

return $this->handle($palletDelivery, $this->validatedData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function handle(PalletReturn $palletReturn, $file): Upload
$file,
[
'model' => 'PalletReturnItem',
'parent_type' => class_basename($palletReturn),
'parent_id' => $palletReturn->id,
'customer_id' => $palletReturn->fulfilmentCustomer->customer_id,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function asController(Organisation $organisation, PalletReturn $palletRet
public function action(PalletReturn $palletReturn, array $modelData): PalletReturn
{
$this->action = true;
$this->palletReturn = $palletReturn;
$this->initialisationFulfilmentActions($palletReturn->fulfilmentCustomer, $modelData);
return $this->handle($palletReturn, $modelData);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/UI/Grp/Layout/GetFulfilmentNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function handle(Fulfilment $fulfilment, User $user): array
[
"tooltip" => __("Comms"),
"icon" => ["fal", "fa-satellite-dish"],
"root" => "grp.org.fulfilments.show.v.dashboard",
"root" => "grp.org.fulfilments.show.operations.comms.dashboard",
"route" => [
"name" => "grp.org.fulfilments.show.v.dashboard",
"name" => "grp.org.fulfilments.show.operations.comms.dashboard",
"parameters" => [$fulfilment->organisation->slug, $fulfilment->slug]
],
],
Expand Down
24 changes: 23 additions & 1 deletion app/Http/Middleware/HandleRetinaInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Support\Facades\Session;
use Inertia\Middleware;
use Tightenco\Ziggy\Ziggy;
use Illuminate\Support\Arr;

class HandleRetinaInertiaRequests extends Middleware
{
Expand All @@ -39,6 +40,22 @@ public function share(Request $request): array
};
}

$website = $request->get('website');
$firstLoadOnlyProps['environment'] = app()->environment();
$firstLoadOnlyProps['ziggy'] = function () use ($request) {
return array_merge((new Ziggy())->toArray(), [
'location' => $request->url()
]);
};
// dd($webUser->customer->favourites->count());

$headerLayout = Arr::get($website->published_layout, 'header');
$isHeaderActive = Arr::get($headerLayout, 'status');

$footerLayout = Arr::get($website->published_layout, 'footer');
$isFooterActive = Arr::get($footerLayout, 'status');


return array_merge(
$firstLoadOnlyProps,
[
Expand All @@ -52,7 +69,12 @@ public function share(Request $request): array
'ziggy' => [
'location' => $request->url(),
],
'iris' => WebsiteIrisResource::make($request->get('website'))->getArray()
'iris' => [
'header' => array_merge($isHeaderActive == 'active' ? Arr::get($website->published_layout, 'header') : []),
'footer' => array_merge( $isFooterActive == 'active' ? Arr::get($website->published_layout, 'footer') : []),
'menu' => Arr::get($website->published_layout, 'menu'),
"website" =>WebsiteIrisResource::make($request->get('website'))->getArray()
]

],
parent::share($request),
Expand Down
Loading

0 comments on commit 19ef596

Please sign in to comment.