Skip to content

Commit

Permalink
Merge pull request #1297 from shivendra-webkul/krayin-update
Browse files Browse the repository at this point in the history
Update account page and fixed routes and fix images build issue
  • Loading branch information
jitendra-webkul authored Jul 29, 2024
2 parents 3205673 + 045db81 commit 336b8f5
Show file tree
Hide file tree
Showing 28 changed files with 569 additions and 560 deletions.
83 changes: 45 additions & 38 deletions packages/Webkul/Admin/src/DataGrids/Mail/EmailDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Webkul\Admin\DataGrids\Mail;

use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB;
use Webkul\UI\DataGrid\DataGrid;
use Webkul\DataGrid\DataGrid;

class EmailDataGrid extends DataGrid
{
Expand All @@ -12,7 +13,7 @@ class EmailDataGrid extends DataGrid
*
* @return void
*/
public function prepareQueryBuilder()
public function prepareQueryBuilder(): Builder
{
$queryBuilder = DB::table('emails')
->select(
Expand All @@ -32,40 +33,38 @@ public function prepareQueryBuilder()
$this->addFilter('name', 'emails.name');
$this->addFilter('created_at', 'emails.created_at');

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

/**
* Add columns.
*
* @return void
*/
public function addColumns()
public function prepareColumns(): void
{
$this->addColumn([
'index' => 'attachments',
'label' => '<i class="icon attachment-icon"></i>',
'label' => '<span class="icon-leads text-2xl"></span>',
'type' => 'string',
'searchable' => false,
'filterable' => false,
'sortable' => false,
'closure' => function ($row) {
if ($row->attachments) {
return '<i class="icon attachment-icon"></i>';
return '<i class="icon-leads"></i>';
}
},
]);

$this->addColumn([
'index' => 'name',
'label' => trans('admin::app.datagrid.from'),
'label' => trans('admin::app.mail.index.datagrid.from'),
'type' => 'string',
'sortable' => true,
]);

$this->addColumn([
'index' => 'subject',
'label' => trans('admin::app.datagrid.subject'),
'label' => trans('admin::app.mail.index.datagrid.subject'),
'type' => 'string',
'sortable' => true,
'closure' => function ($row) {
Expand All @@ -74,12 +73,14 @@ public function addColumns()
]);

$this->addColumn([
'index' => 'created_at',
'label' => trans('admin::app.datagrid.created_at'),
'type' => 'date_range',
'searchable' => false,
'sortable' => true,
'closure' => function ($row) {
'index' => 'created_at',
'label' => trans('admin::app.mail.index.datagrid.created-at'),
'type' => 'date',
'searchable' => true,
'filterable' => true,
'filterable_type' => 'date_range',
'sortable' => true,
'closure' => function ($row) {
return core()->formatDate($row->created_at);
},
]);
Expand All @@ -93,28 +94,37 @@ public function addColumns()
public function prepareActions()
{
$this->addAction([
'title' => request('route') == 'draft'
? trans('ui::app.datagrid.edit')
: trans('ui::app.datagrid.view'),
'method' => 'GET',
'route' => 'admin.mail.view',
'params' => ['route' => request('route')],
'index' => 'edit',
'icon' => request('route') == 'draft'
? 'pencil-icon'
: 'eye-icon',
? 'icon-edit'
: 'icon-view',
'title' => request('route') == 'draft'
? trans('admin::app.mail.index.datagrid.edit')
: trans('admin::app.mail.index.datagrid.view'),
'method' => 'GET',
'params' => [
'type' => request('route') == 'trash'
? 'delete'
: 'trash',
],
'url' => function ($row) {
return route('admin.mail.view', $row->id);
},
]);

$this->addAction([
'title' => trans('ui::app.datagrid.delete'),
'index' => 'delete',
'icon' => 'icon-delete',
'title' => trans('admin::app.mail.index.datagrid.delete'),
'method' => 'DELETE',
'route' => 'admin.mail.delete',
'params' => [
'type' => request('route') == 'trash'
? 'delete'
: 'trash',
],
'confirm_text' => trans('ui::app.datagrid.mass-action.delete', ['resource' => 'email']),
'icon' => 'trash-icon',
'url' => function ($row) {
return route('admin.mail.delete', $row->id);
},
]);
}

Expand All @@ -127,24 +137,21 @@ public function prepareMassActions()
{
if (request('route') == 'trash') {
$this->addMassAction([
'type' => 'delete',
'label' => trans('admin::app.datagrid.move-to-inbox'),
'action' => route('admin.mail.mass_update', [
'folders' => ['inbox'],
]),
'method' => 'PUT',
'title' => trans('admin::app.mail.index.datagrid.move-to-inbox'),
'method' => 'POST',
'url' => route('admin.mail.mass_update', ['folders' => ['inbox']]),
]);
}

$this->addMassAction([
'type' => 'delete',
'label' => trans('ui::app.datagrid.delete'),
'action' => route('admin.mail.mass_delete', [
'icon' => 'icon-delete',
'title' => trans('admin::app.mail.index.datagrid..delete'),
'method' => 'POST',
'url' => route('admin.mail.mass_delete', [
'type' => request('route') == 'trash'
? 'delete'
: 'trash',
]),
'method' => 'PUT',
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class PipelineDataGrid extends DataGrid
{

/**
* Prepare query builder.
*/
Expand Down
18 changes: 9 additions & 9 deletions packages/Webkul/Admin/src/DataGrids/Settings/UserDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB;
use Webkul\DataGrid\DataGrid;
use Illuminate\Support\Facades\Storage;
use Webkul\DataGrid\DataGrid;
use Webkul\User\Repositories\UserRepository;

class UserDataGrid extends DataGrid
Expand All @@ -16,7 +16,7 @@ class UserDataGrid extends DataGrid
* @return void
*/
public function __construct(protected UserRepository $userRepository) {}

/**
* Prepare query builder.
*
Expand Down Expand Up @@ -64,14 +64,14 @@ public function prepareColumns(): void
]);

$this->addColumn([
'index' => 'name',
'label' => trans('admin::app.settings.users.index.datagrid.name'),
'type' => 'string',
'sortable' => true,
'index' => 'name',
'label' => trans('admin::app.settings.users.index.datagrid.name'),
'type' => 'string',
'sortable' => true,
'closure' => function ($row) {
return [
return [
'image' => $row->image ? Storage::url($row->image) : null,
'name' => $row->name
'name' => $row->name,
];
},
]);
Expand All @@ -90,7 +90,7 @@ public function prepareColumns(): void
'filterable' => true,
'sortable' => true,
]);

$this->addColumn([
'index' => 'created_at',
'label' => trans('admin::app.settings.users.index.datagrid.created-at'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

namespace Webkul\Admin\Http\Controllers\Mail;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Webkul\Admin\DataGrids\Mail\EmailDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Email\Mails\Email;
use Webkul\Email\Repositories\AttachmentRepository;
Expand All @@ -26,10 +30,8 @@ public function __construct(

/**
* Display a listing of the resource.
*
* @return \Illuminate\View\View
*/
public function index()
public function index(): View|JsonResponse|RedirectResponse
{
if (! request('route')) {
return redirect()->route('admin.mail.index', ['route' => 'inbox']);
Expand All @@ -45,7 +47,7 @@ public function index()

default:
if (request()->ajax()) {
return app(\Webkul\Admin\DataGrids\Mail\EmailDataGrid::class)->toJson();
return datagrid(EmailDataGrid::class)->process();
}

return view('admin::mail.index');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Webkul\Admin\Http\Controllers\Settings;

use Illuminate\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Illuminate\View\View;
use Webkul\Admin\DataGrids\Settings\UserDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Notifications\User\Create;
use Webkul\User\Repositories\GroupRepository;
use Webkul\User\Repositories\RoleRepository;
use Webkul\User\Repositories\UserRepository;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\User\Repositories\GroupRepository;
use Webkul\Admin\DataGrids\Settings\UserDataGrid;

class UserController extends Controller
{
Expand Down Expand Up @@ -98,9 +98,9 @@ public function edit(int $id): View|JsonResponse
$groups = $this->groupRepository->all();

return new JsonResponse([
'data' =>$admin,
'roles' =>$roles,
'groups' =>$groups
'data' => $admin,
'roles' => $roles,
'groups' => $groups,
]);
}

Expand Down
Loading

0 comments on commit 336b8f5

Please sign in to comment.