From a40743e3bacfe718285bc377cb5edb7d9ed31412 Mon Sep 17 00:00:00 2001 From: suraj kashyap Date: Mon, 22 Jul 2024 18:58:00 +0530 Subject: [PATCH 1/5] workflow create page is done. --- .../DataGrids/Setting/WorkflowDataGrid.php | 50 +- .../Setting/WorkflowController.php | 33 +- packages/Webkul/Admin/src/Http/routes.php | 16 +- .../src/Providers/AdminServiceProvider.php | 2 +- .../Admin/src/Resources/lang/en/app.php | 166 +- .../settings/workflows/edit-old.blade.php | 763 ++++++++ .../views/settings/workflows/edit.blade.php | 1698 ++++++++++------- .../views/settings/workflows/index.blade.php | 52 +- .../Admin/src/Routes/settings-routes.php | 18 + packages/Webkul/Admin/src/Routes/web.php | 1 - 10 files changed, 1939 insertions(+), 860 deletions(-) create mode 100644 packages/Webkul/Admin/src/Resources/views/settings/workflows/edit-old.blade.php diff --git a/packages/Webkul/Admin/src/DataGrids/Setting/WorkflowDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Setting/WorkflowDataGrid.php index 51bdd0d8c..03ebe033d 100644 --- a/packages/Webkul/Admin/src/DataGrids/Setting/WorkflowDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/Setting/WorkflowDataGrid.php @@ -2,17 +2,16 @@ namespace Webkul\Admin\DataGrids\Setting; +use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; -use Webkul\UI\DataGrid\DataGrid; +use Webkul\DataGrid\DataGrid; class WorkflowDataGrid extends DataGrid { /** * Prepare query builder. - * - * @return void */ - public function prepareQueryBuilder() + public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('workflows') ->addSelect( @@ -22,51 +21,52 @@ public function prepareQueryBuilder() $this->addFilter('id', 'workflows.id'); - $this->setQueryBuilder($queryBuilder); + return $queryBuilder; } /** - * Add columns. - * - * @return void + * Prepare Columns. */ - public function addColumns() + public function prepareColumns(): void { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'string', + 'searchable' => true, + 'filterable' => true, + 'sortable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', + 'searchable' => true, + 'filterable' => true, + 'sortable' => true, ]); } /** * Prepare actions. - * - * @return void */ - public function prepareActions() + public function prepareActions(): void { $this->addAction([ + 'index' => 'edit', + 'icon' => 'icon-edit', 'title' => trans('ui::app.datagrid.edit'), 'method' => 'GET', - 'route' => 'admin.settings.workflows.edit', - 'icon' => 'pencil-icon', + 'url' => fn ($row) => route('admin.settings.workflows.edit', $row->id), ]); $this->addAction([ + 'index' => 'delete', + 'icon' => 'icon-delete', 'title' => trans('ui::app.datagrid.delete'), 'method' => 'DELETE', - 'route' => 'admin.settings.workflows.delete', - 'confirm_text' => trans('ui::app.datagrid.mass-action.delete', ['resource' => 'type']), - 'icon' => 'trash-icon', + 'url' => fn ($row) => route('admin.settings.workflows.delete', $row->id), ]); } } diff --git a/packages/Webkul/Admin/src/Http/Controllers/Setting/WorkflowController.php b/packages/Webkul/Admin/src/Http/Controllers/Setting/WorkflowController.php index eb6f9dd73..b49e2b300 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Setting/WorkflowController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Setting/WorkflowController.php @@ -2,7 +2,11 @@ namespace Webkul\Admin\Http\Controllers\Setting; +use Illuminate\Http\JsonResponse; +use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Event; +use Illuminate\View\View; +use Webkul\Admin\DataGrids\Setting\WorkflowDataGrid; use Webkul\Admin\Http\Controllers\Controller; use Webkul\Workflow\Repositories\WorkflowRepository; @@ -17,13 +21,11 @@ public function __construct(protected WorkflowRepository $workflowRepository) {} /** * Display a listing of the workflow. - * - * @return \Illuminate\View\View */ - public function index() + public function index(): View|JsonResponse { if (request()->ajax()) { - return app(\Webkul\Admin\DataGrids\Setting\WorkflowDataGrid::class)->toJson(); + return datagrid(WorkflowDataGrid::class)->process(); } return view('admin::settings.workflows.index'); @@ -31,20 +33,16 @@ public function index() /** * Show the form for creating a new resource. - * - * @return \Illuminate\View\View */ - public function create() + public function create(): View { return view('admin::settings.workflows.create'); } /** * Store a newly created workflow in storage. - * - * @return \Illuminate\Http\Response */ - public function store() + public function store(): RedirectResponse { $this->validate(request(), [ 'name' => 'required', @@ -63,11 +61,8 @@ public function store() /** * Show the form for editing the specified workflow. - * - * @param int $id - * @return \Illuminate\View\View */ - public function edit($id) + public function edit(int $id): View { $workflow = $this->workflowRepository->findOrFail($id); @@ -76,11 +71,8 @@ public function edit($id) /** * Update the specified workflow in storage. - * - * @param int $id - * @return \Illuminate\Http\Response */ - public function update($id) + public function update(int $id): RedirectResponse { $this->validate(request(), [ 'name' => 'required', @@ -99,11 +91,8 @@ public function update($id) /** * Remove the specified workflow from storage. - * - * @param int $id - * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(int $id): JsonResponse { $workflow = $this->workflowRepository->findOrFail($id); diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index 2dd12473a..a34500776 100644 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -352,7 +352,6 @@ Route::delete('{id}', 'SourceController@destroy')->name('admin.settings.sources.delete'); }); - // Email Templates Routes Route::prefix('email-templates')->group(function () { Route::get('', 'EmailTemplateController@index')->name('admin.settings.email_templates.index'); @@ -400,20 +399,7 @@ Route::delete('{id}', 'LocationController@destroy')->name('admin.settings.locations.delete'); }); - // Workflows Routes - Route::prefix('workflows')->group(function () { - Route::get('', 'WorkflowController@index')->name('admin.settings.workflows.index'); - - Route::get('create', 'WorkflowController@create')->name('admin.settings.workflows.create'); - - Route::post('create', 'WorkflowController@store')->name('admin.settings.workflows.store'); - - Route::get('edit/{id?}', 'WorkflowController@edit')->name('admin.settings.workflows.edit'); - - Route::put('edit/{id}', 'WorkflowController@update')->name('admin.settings.workflows.update'); - - Route::delete('{id}', 'WorkflowController@destroy')->name('admin.settings.workflows.delete'); - }); + // Tags Routes Route::prefix('tags')->group(function () { diff --git a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php index 9d2f37768..4634f5084 100644 --- a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php @@ -6,9 +6,9 @@ use Illuminate\Foundation\AliasLoader; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Blade; +use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Webkul\Admin\Http\Middleware\Locale; -use Illuminate\Support\Facades\Route; class AdminServiceProvider extends ServiceProvider { diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 676b856c2..3e616ea15 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -232,6 +232,18 @@ ], ], ], + + 'workflows' => [ + 'is-equal-to' => 'Is equal to', + 'is-not-equal-to' => 'Is not equal to', + 'equals-or-greater-than' => 'Equals or greater than', + 'equals-or-less-than' => 'Equals or less than', + 'greater-than' => 'Greater than', + 'less-than' => 'Less than', + 'contain' => 'Contain', + 'contains' => 'Contains', + 'does-not-contain' => 'Does not contain', + ], ], // ----------------------------------------------------------------Old version locale ---------------------------------- @@ -872,83 +884,83 @@ // 'delete-failed' => 'Email Template can not be deleted.', // ], - // 'workflows' => [ - // 'title' => 'Workflows', - // 'create-title' => 'Create Workflow', - // 'edit-title' => 'Edit Workflow', - // 'save-btn-title' => 'Save as Workflow', - // 'back' => 'Back', - // 'cancel' => 'Cancel', - // 'information' => 'Information', - // 'name' => 'Name', - // 'description' => 'Description', - // 'event' => 'Event', - // 'events' => 'Events', - // 'created' => 'Created', - // 'updated' => 'Updated', - // 'deleted' => 'Deleted', - // 'event-info' => 'An event automatically triggers to check conditions and perform a respective pre-defined set of actions', - // 'conditions' => 'Conditions', - // 'condition-info' => 'Conditions are set of rules which checks for specific scenarios and are triggered on specific occasions', - // 'condition-type' => 'Condition Type', - // 'all-conditions-true' => 'All Conditions are True', - // 'any-condition-true' => 'Any Condition is True', - // 'add-condition' => 'Add Condition', - // 'choose-condition-to-add' => 'Choose a condition to add', - // 'is-equal-to' => 'Is equal to', - // 'is-not-equal-to' => 'Is not equal to', - // 'equals-or-greater-than' => 'Equals or greater than', - // 'equals-or-less-than' => 'Equals or less than', - // 'greater-than' => 'Greater than', - // 'less-than' => 'Less than', - // 'contain' => 'Contain', - // 'contains' => 'Contains', - // 'does-not-contain' => 'Does not contain', - // 'actions' => 'Actions', - // 'action-info' => 'An action not only reduces the workload but also makes it quite easier for CRM automation', - // 'choose-action-to-add' => 'Choose action to add', - // 'update-lead' => 'Update lead', - // 'update-person' => 'Update person', - // 'send-email-to-person' => 'Send email to person', - // 'send-email-to-sales-owner' => 'Send email to sales owner', - // 'send-email-to-participants' => 'Send email to participants', - // 'add-tag' => 'Add tag', - // 'add-note-as-activity' => 'Add note as activity', - // 'choose-attribute' => 'Choose attribute', - // 'choose-option' => 'Choose option', - // 'update-person' => 'Update person', - // 'update-related-leads' => 'Update related leads', - // 'update-quote' => 'Update quote', - // 'add-action' => 'Add Action', - // 'create-success' => 'Workflow created successfully.', - // 'update-success' => 'Workflow updated successfully.', - // 'delete-success' => 'Workflow deleted successfully.', - // 'delete-failed' => 'Workflow can not be deleted.', - // 'add-webhook' => 'Trigger webhook', - // 'webhook_heading' => 'Webhook settings', - // 'webhook_url' => 'Enter URL', - // 'request-headers' => 'Request Headers', - // 'webhook_request_method' => 'Request method', - // 'get_method' => 'GET', - // 'post_method' => 'POST', - // 'put_method' => 'PUT', - // 'patch_method' => 'PATCH', - // 'delete_method' => 'DELETE', - // 'webhook_encoding' => 'Select encoding', - // 'encoding_json' => 'JSON', - // 'encoding_http_query' => 'X-www-form-urlencoded', - // 'request_body' => 'Request Body', - // 'request_body_info' => 'Add key value pair in new line, i.e., key=value', - // 'simple_body' => 'Simple', - // 'raw' => 'Raw', - // 'lead' => 'Lead', - // 'person' => 'Person', - // 'quote' => 'Quote', - // 'activity' => 'Activity', - // 'add_header' => 'Add header', - // 'header_key' => 'Key', - // 'header_value' => 'Value', - // ], + // 'workflows' => [ + // 'title' => 'Workflows', + // 'create-title' => 'Create Workflow', + // 'edit-title' => 'Edit Workflow', + // 'save-btn-title' => 'Save as Workflow', + // 'back' => 'Back', + // 'cancel' => 'Cancel', + // 'information' => 'Information', + // 'name' => 'Name', + // 'description' => 'Description', + // 'event' => 'Event', + // 'events' => 'Events', + // 'created' => 'Created', + // 'updated' => 'Updated', + // 'deleted' => 'Deleted', + // 'event-info' => 'An event automatically triggers to check conditions and perform a respective pre-defined set of actions', + // 'conditions' => 'Conditions', + // 'condition-info' => 'Conditions are set of rules which checks for specific scenarios and are triggered on specific occasions', + // 'condition-type' => 'Condition Type', + // 'all-conditions-true' => 'All Conditions are True', + // 'any-condition-true' => 'Any Condition is True', + // 'add-condition' => 'Add Condition', + // 'choose-condition-to-add' => 'Choose a condition to add', + // 'is-equal-to' => 'Is equal to', + // 'is-not-equal-to' => 'Is not equal to', + // 'equals-or-greater-than' => 'Equals or greater than', + // 'equals-or-less-than' => 'Equals or less than', + // 'greater-than' => 'Greater than', + // 'less-than' => 'Less than', + // 'contain' => 'Contain', + // 'contains' => 'Contains', + // 'does-not-contain' => 'Does not contain', + // 'actions' => 'Actions', + // 'action-info' => 'An action not only reduces the workload but also makes it quite easier for CRM automation', + // 'choose-action-to-add' => 'Choose action to add', + // 'update-lead' => 'Update lead', + // 'update-person' => 'Update person', + // 'send-email-to-person' => 'Send email to person', + // 'send-email-to-sales-owner' => 'Send email to sales owner', + // 'send-email-to-participants' => 'Send email to participants', + // 'add-tag' => 'Add tag', + // 'add-note-as-activity' => 'Add note as activity', + // 'choose-attribute' => 'Choose attribute', + // 'choose-option' => 'Choose option', + // 'update-person' => 'Update person', + // 'update-related-leads' => 'Update related leads', + // 'update-quote' => 'Update quote', + // 'add-action' => 'Add Action', + // 'create-success' => 'Workflow created successfully.', + // 'update-success' => 'Workflow updated successfully.', + // 'delete-success' => 'Workflow deleted successfully.', + // 'delete-failed' => 'Workflow can not be deleted.', + // 'add-webhook' => 'Trigger webhook', + // 'webhook_heading' => 'Webhook settings', + // 'webhook_url' => 'Enter URL', + // 'request-headers' => 'Request Headers', + // 'webhook_request_method' => 'Request method', + // 'get_method' => 'GET', + // 'post_method' => 'POST', + // 'put_method' => 'PUT', + // 'patch_method' => 'PATCH', + // 'delete_method' => 'DELETE', + // 'webhook_encoding' => 'Select encoding', + // 'encoding_json' => 'JSON', + // 'encoding_http_query' => 'X-www-form-urlencoded', + // 'request_body' => 'Request Body', + // 'request_body_info' => 'Add key value pair in new line, i.e., key=value', + // 'simple_body' => 'Simple', + // 'raw' => 'Raw', + // 'lead' => 'Lead', + // 'person' => 'Person', + // 'quote' => 'Quote', + // 'activity' => 'Activity', + // 'add_header' => 'Add header', + // 'header_key' => 'Key', + // 'header_value' => 'Value', + // ], // 'tags' => [ // 'title' => 'Tags', diff --git a/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit-old.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit-old.blade.php new file mode 100644 index 000000000..9b3a45d72 --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit-old.blade.php @@ -0,0 +1,763 @@ +@extends('admin::layouts.master') + +@section('page_title') + {{ __('admin::app.settings.workflows.edit-title') }} +@stop + +@section('content-wrapper') +
+ {!! view_render_event('admin.settings.workflows.edit.header.before') !!} + + + + {!! view_render_event('admin.settings.workflows.edit.header.after') !!} + +
+
+
+
+
+ {!! view_render_event('admin.settings.workflows.edit.form_buttons.before') !!} + + + + + {{ __('admin::app.layouts.back') }} + + + {!! view_render_event('admin.settings.workflows.edit.form_buttons.after') !!} +
+ +
+ {!! view_render_event('admin.settings.workflows.edit.form_controls.before') !!} + + @csrf() + + + + + + {!! view_render_event('admin.settings.workflows.edit.form_controls.after') !!} +
+
+
+
+
+
+ + @include('admin::common.custom-attributes.edit.lookup') +@stop + +@push('scripts') + @parent + + + + + + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit.blade.php index 2afea23db..22916c0b9 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/workflows/edit.blade.php @@ -1,758 +1,1064 @@ -@extends('admin::layouts.master') - -@section('page_title') - {{ __('admin::app.settings.workflows.edit-title') }} -@stop - -@section('content-wrapper') -
- {!! view_render_event('admin.settings.workflows.edit.header.before') !!} - -