Skip to content

Commit 1606d4b

Browse files
datagrid updates
1 parent 27720c2 commit 1606d4b

File tree

27 files changed

+239
-69
lines changed

27 files changed

+239
-69
lines changed

packages/Webkul/Admin/publishable/assets/css/admin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/Webkul/Admin/publishable/assets/js/admin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/Webkul/Admin/publishable/assets/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"/js/admin.js": "/js/admin.js?id=b917fdffda40b4c4377b",
3-
"/css/admin.css": "/css/admin.css?id=4941fdb47ba308dad2d7",
2+
"/js/admin.js": "/js/admin.js?id=ed2a8a7b327909c30b7c",
3+
"/css/admin.css": "/css/admin.css?id=99dd442249ceec6f4235",
44
"/images/activities-active-icon.svg": "/images/activities-active-icon.svg?id=f7887e3fdcddf68567ce",
55
"/images/activities-icon.svg": "/images/activities-icon.svg?id=0755224d86e0281d031f",
66
"/images/avatar-dark-icon.svg": "/images/avatar-dark-icon.svg?id=abefe06bd1ce2bfe7029",

packages/Webkul/Admin/src/DataGrids/Activity/ActivityDataGrid.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class ActivityDataGrid extends DataGrid
1010
{
1111
protected $users = [];
12+
protected $persons = [];
1213
protected $tabFilters = [];
1314

1415
protected $redirectRow = [
@@ -18,6 +19,7 @@ class ActivityDataGrid extends DataGrid
1819

1920
public function __construct()
2021
{
22+
// table tab filters
2123
$this->tabFilters = [
2224
[
2325
'type' => 'pill',
@@ -80,6 +82,7 @@ public function __construct()
8082
],
8183
];
8284

85+
// users list to filter table data
8386
$userRepository = app('\Webkul\User\Repositories\UserRepository');
8487

8588
$users = $userRepository->all();
@@ -91,6 +94,18 @@ public function __construct()
9194
]);
9295
}
9396

97+
// persons list to filter table data
98+
$personRepository = app('\Webkul\Contact\Repositories\PersonRepository');
99+
100+
$persons = $personRepository->all();
101+
102+
foreach ($persons as $person) {
103+
array_push($this->persons, [
104+
'value' => $person['id'],
105+
'label' => $person['name'],
106+
]);
107+
}
108+
94109
parent::__construct();
95110
}
96111

@@ -117,7 +132,9 @@ public function prepareQueryBuilder()
117132

118133
$this->addFilter('id', 'lead_activities.id');
119134
$this->addFilter('assigned_to', 'users.name');
135+
$this->addFilter('contact_person', 'persons.id');
120136
$this->addFilter('user', 'lead_activities.user_id');
137+
$this->addFilter('created_at', 'lead_activities.created_at');
121138

122139
$this->setQueryBuilder($queryBuilder);
123140
}
@@ -126,19 +143,19 @@ public function addColumns()
126143
{
127144
$this->addColumn([
128145
'index' => 'user',
129-
'label' => trans('admin::app.datagrid.user'),
146+
'label' => trans('admin::app.datagrid.assigned_to'),
130147
'type' => 'hidden',
131148
'sortable' => true,
132149
'filterable_type' => 'dropdown',
133150
'filterable_options' => $this->users,
134151
]);
135152

136153
$this->addColumn([
137-
'index' => 'subject',
138-
'label' => trans('admin::app.datagrid.subject'),
154+
'index' => 'lead',
155+
'label' => trans('admin::app.datagrid.lead'),
139156
'type' => 'string',
140157
'closure' => function ($row) {
141-
$route = urldecode(route('admin.leads.index', ['type' => 'table', 'id[eq]' => $row->lead_id]));
158+
$route = urldecode(route('admin.leads.index', ['view_type' => 'table', 'id[eq]' => $row->lead_id]));
142159

143160
return "<a href='" . $route . "'>" . $row->lead_title . "</a>";
144161
},
@@ -181,10 +198,12 @@ public function addColumns()
181198
]);
182199

183200
$this->addColumn([
184-
'index' => 'contact_person',
185-
'label' => trans('admin::app.datagrid.contact_person'),
186-
'type' => 'string',
187-
'closure' => function ($row) {
201+
'index' => 'contact_person',
202+
'label' => trans('admin::app.datagrid.contact_person'),
203+
'type' => 'string',
204+
'filterable_type' => 'dropdown',
205+
'filterable_options' => $this->persons,
206+
'closure' => function ($row) {
188207
$route = urldecode(route('admin.contacts.persons.index', ['id[eq]' => $row->contact_person_id]));
189208

190209
return "<a href='" . $route . "'>" . $row->contact_person . "</a>";

packages/Webkul/Admin/src/DataGrids/Contact/OrganizationDataGrid.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44

55
use Webkul\UI\DataGrid\DataGrid;
66
use Illuminate\Support\Facades\DB;
7+
use Webkul\Contact\Repositories\PersonRepository;
78

89
class OrganizationDataGrid extends DataGrid
910
{
11+
protected $personRepository;
12+
1013
protected $redirectRow = [
1114
"id" => "id",
1215
"route" => "admin.contacts.organizations.edit",
1316
];
1417

18+
public function __construct(PersonRepository $personRepository)
19+
{
20+
$this->personRepository = $personRepository;
21+
22+
parent::__construct();
23+
}
24+
1525
public function prepareQueryBuilder()
1626
{
1727
$queryBuilder = DB::table('organizations')
@@ -27,6 +37,16 @@ public function prepareQueryBuilder()
2737

2838
public function addColumns()
2939
{
40+
$this->addColumn([
41+
'index' => 'id',
42+
'head_style' => 'width: 50px',
43+
'label' => trans('admin::app.datagrid.id'),
44+
'type' => 'string',
45+
'searchable' => true,
46+
'sortable' => true,
47+
'filterable_type' => 'add'
48+
]);
49+
3050
$this->addColumn([
3151
'index' => 'name',
3252
'label' => trans('admin::app.datagrid.name'),
@@ -36,6 +56,23 @@ public function addColumns()
3656
'filterable_type' => 'add'
3757
]);
3858

59+
$this->addColumn([
60+
'index' => 'persons_count',
61+
'head_style' => 'width: 100px',
62+
'label' => trans('admin::app.datagrid.persons_count'),
63+
'type' => 'string',
64+
'searchable' => true,
65+
'closure' => function ($row) {
66+
$personsCount = $this->personRepository
67+
->findWhere(['organization_id' => $row->id])
68+
->count();
69+
70+
$route = urldecode(route('admin.contacts.persons.index', ['organization[in]' => $row->id]));
71+
72+
return "<a href='" . $route . "'>" . $personsCount . "</a>";
73+
},
74+
]);
75+
3976
$this->addColumn([
4077
'index' => 'created_at',
4178
'label' => trans('admin::app.datagrid.created_at'),

packages/Webkul/Admin/src/DataGrids/Contact/PersonDataGrid.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,31 @@
55
use Illuminate\Support\Facades\DB;
66
use Illuminate\Support\Arr;
77
use Webkul\UI\DataGrid\DataGrid;
8+
use Webkul\Contact\Repositories\OrganizationRepository;
89

910
class PersonDataGrid extends DataGrid
1011
{
12+
protected $organizations = [];
13+
1114
protected $redirectRow = [
1215
"id" => "id",
1316
"route" => "admin.contacts.persons.edit",
1417
];
1518

19+
public function __construct(OrganizationRepository $organizationRepository)
20+
{
21+
$organizations = $organizationRepository->all();
22+
23+
foreach ($organizations as $organization) {
24+
array_push($this->organizations, [
25+
'value' => $organization['id'],
26+
'label' => $organization['name'],
27+
]);
28+
}
29+
30+
parent::__construct();
31+
}
32+
1633
public function prepareQueryBuilder()
1734
{
1835
$queryBuilder = DB::table('persons')
@@ -21,13 +38,13 @@ public function prepareQueryBuilder()
2138
'persons.name',
2239
'persons.emails',
2340
'persons.contact_numbers',
24-
'organizations.name as organization_name'
41+
'organizations.name as organization'
2542
)
2643
->leftJoin('organizations', 'persons.organization_id', '=', 'organizations.id');
2744

2845
$this->addFilter('id', 'persons.id');
2946
$this->addFilter('name', 'persons.name');
30-
$this->addFilter('organization_name', 'organizations.name');
47+
$this->addFilter('organization', 'organizations.id');
3148

3249
$this->setQueryBuilder($queryBuilder);
3350
}
@@ -84,12 +101,13 @@ public function addColumns()
84101
]);
85102

86103
$this->addColumn([
87-
'index' => 'organization_name',
88-
'label' => trans('admin::app.datagrid.organization_name'),
89-
'type' => 'string',
90-
'searchable' => true,
91-
'sortable' => true,
92-
'filterable_type' => 'add'
104+
'index' => 'organization',
105+
'label' => trans('admin::app.datagrid.organization_name'),
106+
'type' => 'string',
107+
'searchable' => true,
108+
'sortable' => true,
109+
'filterable_type' => 'dropdown',
110+
'filterable_options' => $this->organizations,
93111
]);
94112
}
95113

packages/Webkul/Admin/src/DataGrids/Lead/LeadDataGrid.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function prepareQueryBuilder()
7070
'leads.status',
7171
'leads.lead_value',
7272
'leads.created_at',
73+
'users.id as user_id',
7374
'users.name as user_name',
7475
'lead_stages.name as stage'
7576
)
@@ -119,7 +120,7 @@ public function addColumns()
119120

120121
$this->addColumn([
121122
'index' => 'lead_value',
122-
'label' => trans('admin::app.datagrid.deal_amount'),
123+
'label' => trans('admin::app.datagrid.lead_value'),
123124
'type' => 'string',
124125
'searchable' => true,
125126
'sortable' => true,
@@ -128,21 +129,15 @@ public function addColumns()
128129
},
129130
]);
130131

131-
$this->addColumn([
132-
'index' => 'created_at',
133-
'label' => trans('admin::app.datagrid.created_at'),
134-
'type' => 'string',
135-
'sortable' => true,
136-
'filterable_type' => 'date_range',
137-
'closure' => function ($row) {
138-
return core()->formatDate($row->created_at);
139-
},
140-
]);
141-
142132
$this->addColumn([
143133
'index' => 'user_name',
144134
'label' => trans('admin::app.datagrid.contact_person'),
145-
'type' => 'string'
135+
'type' => 'string',
136+
'closure' => function ($row) {
137+
$route = urldecode(route('admin.contacts.persons.index', ['id[eq]' => $row->user_id]));
138+
139+
return "<a href='" . $route . "'>" . $row->user_name . "</a>";
140+
},
146141
]);
147142

148143
$this->addColumn([
@@ -161,6 +156,17 @@ public function addColumns()
161156
return "<span class='badge badge-round badge-$badge'></span>" . $row->stage;
162157
},
163158
]);
159+
160+
$this->addColumn([
161+
'index' => 'created_at',
162+
'label' => trans('admin::app.datagrid.created_at'),
163+
'type' => 'string',
164+
'sortable' => true,
165+
'filterable_type' => 'date_range',
166+
'closure' => function ($row) {
167+
return core()->formatDate($row->created_at);
168+
},
169+
]);
164170
}
165171

166172
public function prepareActions()

packages/Webkul/Admin/src/DataGrids/Setting/AttributeDataGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function addColumns()
7070
{
7171
$this->addColumn([
7272
'index' => 'id',
73+
'head_style' => 'width: 50px',
7374
'label' => trans('admin::app.datagrid.id'),
7475
'type' => 'string',
7576
'searchable' => true,

packages/Webkul/Admin/src/DataGrids/Setting/RoleDataGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function addColumns()
2929
{
3030
$this->addColumn([
3131
'index' => 'id',
32+
'head_style' => 'width: 50px',
3233
'label' => trans('admin::app.datagrid.id'),
3334
'type' => 'string',
3435
'searchable' => true,

packages/Webkul/Admin/src/DataGrids/Setting/SourceDataGrid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function prepareQueryBuilder()
1717
$queryBuilder = DB::table('lead_sources')
1818
->addSelect(
1919
'lead_sources.id',
20-
'lead_sources.name',
20+
'lead_sources.name'
2121
);
2222

2323
$this->setQueryBuilder($queryBuilder);
@@ -27,6 +27,7 @@ public function addColumns()
2727
{
2828
$this->addColumn([
2929
'index' => 'id',
30+
'head_style' => 'width: 50px',
3031
'label' => trans('admin::app.datagrid.id'),
3132
'type' => 'string',
3233
'searchable' => true,

0 commit comments

Comments
 (0)