Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivendra-webkul committed Jul 24, 2024
2 parents 2e4322c + 9d6c75e commit 31adef1
Show file tree
Hide file tree
Showing 12 changed files with 620 additions and 644 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -23,33 +21,37 @@ public function prepareQueryBuilder()

$this->addFilter('id', 'email_templates.id');

$this->setQueryBuilder($queryBuilder);
return $queryBuilder;
}

/**
* Add columns.
*
* @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,
]);
Expand All @@ -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),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -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',
Expand All @@ -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);

Expand All @@ -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',
Expand All @@ -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);
}
}
51 changes: 51 additions & 0 deletions packages/Webkul/Admin/src/Http/Controllers/TinyMCEController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Webkul\Admin\Http\Controllers;

use Illuminate\Support\Facades\Storage;

class TinyMCEController extends Controller
{
/**
* Storage folder path.
*
* @var string
*/
private $storagePath = 'tinymce';

/**
* Upload file from tinymce.
*
* @return void
*/
public function upload()
{
$media = $this->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),
];
}
}
41 changes: 41 additions & 0 deletions packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
<x-admin::tinymce
:selector="'textarea#' . $attributes->get('id')"
:prompt="stripcslashes($attributes->get('prompt', ''))"
::field="field"
>
</x-admin::tinymce>
/>
@endif
</v-field>

Expand Down
Loading

0 comments on commit 31adef1

Please sign in to comment.