Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions resources/lang/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
'label_total_items' => 'Total Items',
'label_cancel_reason' => 'Reason for cancellation',

'label_enable_status_workflow' => 'Enable Status Workflow',
'label_accepted_order_status' => 'Accepted Order Status',
'label_reject_order_status' => 'Rejected Order Status',
'label_rejected_reasons' => 'Rejected Order Reasons',
Expand All @@ -369,6 +370,7 @@
'label_delay_amount' => 'Delay Minutes',
'label_limit_users' => 'Limit workflow to specific users',

'help_enable_status_workflow' => 'Enable or disable the status workflow modal for approving new orders in the admin area',
'help_accepted_order_status' => 'The order status to use when an order is marked as accepted. You can create a new status from the Settings > Statuses page',
'help_reject_order_status' => 'The order status to use when an order is marked as rejected. You can create a new status from the Settings > Statuses page',
'help_limit_users' => 'Selected users will see a popup in the admin area to accept, delay and reject orders. Leave blank to apply to all users.',
Expand Down
9 changes: 9 additions & 0 deletions resources/models/ordersettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
'options' => [\Igniter\Admin\Models\Status::class, 'getDropdownOptionsForOrder'],
'comment' => 'lang:igniter.cart::default.help_canceled_order_status',
],
'enable_status_workflow' => [
'label' => 'lang:igniter.cart::default.orders.label_enable_status_workflow',
'tab' => 'lang:igniter.cart::default.orders.text_tab_approval',
'type' => 'switch',
'default' => true,
'on' => 'lang:igniter::admin.text_yes',
'off' => 'lang:igniter::admin.text_no',
'comment' => 'lang:igniter.cart::default.orders.help_enable_status_workflow',
],
'accepted_order_status' => [
'label' => 'lang:igniter.cart::default.orders.label_accepted_order_status',
'tab' => 'lang:igniter.cart::default.orders.text_tab_approval',
Expand Down
2 changes: 1 addition & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function boot(): void
resolve(ExtendDashboardCharts::class)->registerCharts();

Event::listen('admin.controller.beforeRemap', function($controller): void {
$controller->addJs('igniter.cart::/js/order-workflow.js', 'order-workflow');
$controller->addJs('igniter.cart::/js/status-workflow.js', 'status-workflow');
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/Http/Middleware/InjectStatusWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public function handle($request, Closure $next)

protected function shouldInjectOrderWorkflow(Request $request): bool
{
$enableWorkflow = setting('enable_status_workflow', true);
$limitUsers = setting('limit_users', []);

return $request->isMethod('GET')
return $enableWorkflow
&& $request->isMethod('GET')
&& $request->route()?->getController() instanceof AdminController
&& (!$limitUsers || in_array(AdminAuth::getUser()->getKey(), $limitUsers));
}
Expand Down