diff --git a/packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php
index 05ffb2d07..d74659055 100644
--- a/packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php
+++ b/packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php
@@ -3,14 +3,12 @@
namespace Webkul\Admin\DataGrids\Settings;
use Illuminate\Support\Facades\DB;
-use Webkul\UI\DataGrid\DataGrid;
+use Webkul\DataGrid\DataGrid;
class EmailTemplateDataGrid extends DataGrid
{
/**
* Prepare query builder.
- *
- * @return void
*/
public function prepareQueryBuilder()
{
@@ -23,7 +21,7 @@ public function prepareQueryBuilder()
$this->addFilter('id', 'email_templates.id');
- $this->setQueryBuilder($queryBuilder);
+ return $queryBuilder;
}
/**
@@ -31,25 +29,29 @@ public function prepareQueryBuilder()
*
* @return void
*/
- public function addColumns()
+ public function prepareColumns()
{
$this->addColumn([
- 'index' => 'id',
- 'label' => trans('admin::app.datagrid.id'),
- 'type' => 'string',
- 'sortable' => true,
+ 'index' => 'id',
+ 'label' => trans('admin::app.settings.email-template.index.datagrid.id'),
+ 'type' => 'string',
+ 'sortable' => true,
+ 'searchable' => true,
+ 'filterable' => true,
]);
$this->addColumn([
- 'index' => 'name',
- 'label' => trans('admin::app.datagrid.name'),
- 'type' => 'string',
- 'sortable' => true,
+ 'index' => 'name',
+ 'label' => trans('admin::app.settings.email-template.index.datagrid.name'),
+ 'type' => 'string',
+ 'sortable' => true,
+ 'searchable' => true,
+ 'filterable' => true,
]);
$this->addColumn([
'index' => 'subject',
- 'label' => trans('admin::app.datagrid.subject'),
+ 'label' => trans('admin::app.settings.email-template.index.datagrid.subject'),
'type' => 'string',
'sortable' => true,
]);
@@ -63,18 +65,19 @@ public function addColumns()
public function prepareActions()
{
$this->addAction([
- 'title' => trans('ui::app.datagrid.edit'),
+ 'index' => 'delete',
+ 'icon' => 'icon-edit',
+ 'title' => trans('admin::app.settings.email-template.index.datagrid.edit'),
'method' => 'GET',
- 'route' => 'admin.settings.email_templates.edit',
- 'icon' => 'pencil-icon',
+ 'url' => fn ($row) => route('admin.settings.email_templates.edit', $row->id),
]);
$this->addAction([
- 'title' => trans('ui::app.datagrid.delete'),
- 'method' => 'DELETE',
- 'route' => 'admin.settings.email_templates.delete',
- 'confirm_text' => trans('ui::app.datagrid.mass-action.delete', ['resource' => 'type']),
- 'icon' => 'trash-icon',
+ 'index' => 'delete',
+ 'icon' => 'icon-delete',
+ 'title' => trans('admin::app.settings.email-template.index.datagrid.delete'),
+ 'method' => 'DELETE',
+ 'url' => fn ($row) => route('admin.settings.email_templates.delete', $row->id),
]);
}
}
diff --git a/packages/Webkul/Admin/src/Http/Controllers/Settings/EmailTemplateController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/EmailTemplateController.php
index 32f2ada1e..0ebe50ef4 100755
--- a/packages/Webkul/Admin/src/Http/Controllers/Settings/EmailTemplateController.php
+++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/EmailTemplateController.php
@@ -2,7 +2,11 @@
namespace Webkul\Admin\Http\Controllers\Settings;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Event;
+use Illuminate\View\View;
+use Webkul\Admin\DataGrids\Settings\EmailTemplateDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\EmailTemplate\Repositories\EmailTemplateRepository;
use Webkul\Workflow\Helpers\Entity;
@@ -21,13 +25,11 @@ public function __construct(
/**
* Display a listing of the email template.
- *
- * @return \Illuminate\View\View
*/
- public function index()
+ public function index(): View|JsonResponse
{
if (request()->ajax()) {
- return app(\Webkul\Admin\DataGrids\Settings\EmailTemplateDataGrid::class)->toJson();
+ return datagrid(EmailTemplateDataGrid::class)->process();
}
return view('admin::settings.email-templates.index');
@@ -47,10 +49,8 @@ public function create()
/**
* Store a newly created email templates in storage.
- *
- * @return \Illuminate\Http\Response
*/
- public function store()
+ public function store(): RedirectResponse
{
$this->validate(request(), [
'name' => 'required',
@@ -64,18 +64,15 @@ public function store()
Event::dispatch('settings.email_templates.create.after', $emailTemplate);
- session()->flash('success', trans('admin::app.settings.email-templates.create-success'));
+ session()->flash('success', trans('admin::app.settings.email-template.index.create-success'));
return redirect()->route('admin.settings.email_templates.index');
}
/**
* Show the form for editing the specified email template.
- *
- * @param int $id
- * @return \Illuminate\View\View
*/
- public function edit($id)
+ public function edit(int $id): View
{
$emailTemplate = $this->emailTemplateRepository->findOrFail($id);
@@ -86,11 +83,8 @@ public function edit($id)
/**
* Update the specified email template in storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
*/
- public function update($id)
+ public function update(int $id): RedirectResponse
{
$this->validate(request(), [
'name' => 'required',
@@ -104,39 +98,36 @@ public function update($id)
Event::dispatch('settings.email_templates.update.after', $emailTemplate);
- session()->flash('success', trans('admin::app.settings.email-templates.update-success'));
+ session()->flash('success', trans('admin::app.settings.email-template.index.update-success'));
return redirect()->route('admin.settings.email_templates.index');
}
/**
* Remove the specified email template from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
*/
- public function destroy($id)
+ public function destroy(int $id): JsonResponse
{
$emailTemplate = $this->emailTemplateRepository->findOrFail($id);
try {
Event::dispatch('settings.email_templates.delete.before', $id);
- $this->emailTemplateRepository->delete($id);
+ $emailTemplate->delete($id);
Event::dispatch('settings.email_templates.delete.after', $id);
return response()->json([
- 'message' => trans('admin::app.settings.email-templates.delete-success'),
+ 'message' => trans('admin::app.settings.email-template.index.delete-success'),
], 200);
} catch (\Exception $exception) {
return response()->json([
- 'message' => trans('admin::app.settings.email-templates.delete-failed'),
+ 'message' => trans('admin::app.settings.email-template.index.delete-failed'),
], 400);
}
return response()->json([
- 'message' => trans('admin::app.settings.email-templates.delete-failed'),
+ 'message' => trans('admin::app.settings.email-template.index.delete-failed'),
], 400);
}
}
diff --git a/packages/Webkul/Admin/src/Http/Controllers/TinyMCEController.php b/packages/Webkul/Admin/src/Http/Controllers/TinyMCEController.php
new file mode 100644
index 000000000..af125c1e3
--- /dev/null
+++ b/packages/Webkul/Admin/src/Http/Controllers/TinyMCEController.php
@@ -0,0 +1,51 @@
+storeMedia();
+
+ if (! empty($media)) {
+ return response()->json([
+ 'location' => $media['file_url'],
+ ]);
+ }
+
+ return response()->json([]);
+ }
+
+ /**
+ * Store media.
+ *
+ * @return array
+ */
+ public function storeMedia()
+ {
+ if (! request()->hasFile('file')) {
+ return [];
+ }
+
+ return [
+ 'file' => $path = request()->file('file')->store($this->storagePath),
+ 'file_name' => request()->file('file')->getClientOriginalName(),
+ 'file_url' => Storage::url($path),
+ ];
+ }
+}
diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php
index 0edb0472a..00a4ea2da 100644
--- a/packages/Webkul/Admin/src/Resources/lang/en/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php
@@ -294,6 +294,47 @@
],
],
],
+
+ 'email-template' => [
+ 'index' => [
+ 'create-btn' => 'Create Email Template',
+ 'title' => 'Email Templates',
+ 'create-success' => 'Email Template created successfully.',
+ 'update-success' => 'Email Template updated successfully.',
+ 'delete-success' => 'Email Template deleted successfully.',
+ 'delete-failed' => 'Email Template can not be deleted.',
+
+ 'datagrid' => [
+ 'delete' => 'Delete',
+ 'edit' => 'Edit',
+ 'id' => 'ID',
+ 'name' => 'Name',
+ 'subject' => 'Subject',
+ ],
+ ],
+
+ 'create' => [
+ 'title' => 'Create Email Template',
+ 'save-btn' => 'Save Email Template',
+ 'email-template' => 'Email Template',
+ 'subject' => 'Subject',
+ 'content' => 'Content',
+ 'subject-placeholders' => 'Subject Placeholders',
+ 'general' => 'General',
+ 'name' => 'Name',
+ ],
+
+ 'edit' => [
+ 'title' => 'Edit Email Template',
+ 'save-btn' => 'Save Email Template',
+ 'email-template' => 'Email Template',
+ 'subject' => 'Subject',
+ 'content' => 'Content',
+ 'subject-placeholders' => 'Subject Placeholders',
+ 'general' => 'General',
+ 'name' => 'Name',
+ ],
+ ],
],
'activities' => [
diff --git a/packages/Webkul/Admin/src/Resources/views/components/form/control-group/control.blade.php b/packages/Webkul/Admin/src/Resources/views/components/form/control-group/control.blade.php
index bdcb4df63..123088b99 100644
--- a/packages/Webkul/Admin/src/Resources/views/components/form/control-group/control.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/components/form/control-group/control.blade.php
@@ -107,10 +107,8 @@ class="flex w-full items-center overflow-hidden rounded-md border text-sm text-g
@if ($attributes->get('tinymce', false) || $attributes->get(':tinymce', false))