Skip to content

Commit c10844c

Browse files
Merged with master
1 parent abd03fd commit c10844c

File tree

17 files changed

+232
-166
lines changed

17 files changed

+232
-166
lines changed

config/datagrid_filters.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
5+
];
6+
7+
?>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
return [
4+
"activities" => [
5+
[
6+
'type' => 'pill',
7+
'key' => 'type',
8+
'condition' => 'eq',
9+
'values' => [
10+
[
11+
'name' => 'admin::app.leads.all',
12+
'isActive' => true,
13+
'key' => 'all',
14+
], [
15+
'name' => 'admin::app.leads.note',
16+
'isActive' => false,
17+
'key' => 'note',
18+
], [
19+
'name' => 'admin::app.leads.call',
20+
'isActive' => false,
21+
'key' => 'call',
22+
], [
23+
'name' => 'admin::app.leads.email',
24+
'isActive' => false,
25+
'key' => 'email',
26+
], [
27+
'name' => 'admin::app.leads.meeting',
28+
'isActive' => false,
29+
'key' => 'meeting',
30+
]
31+
]
32+
], [
33+
'type' => 'group',
34+
'key' => 'duration',
35+
'condition' => 'eq',
36+
'values' => [
37+
[
38+
'name' => 'admin::app.datagrid.filters.yesterday',
39+
'isActive' => false,
40+
'key' => 'yesterday',
41+
], [
42+
'name' => 'admin::app.datagrid.filters.today',
43+
'isActive' => false,
44+
'key' => 'today',
45+
], [
46+
'name' => 'admin::app.datagrid.filters.tomorrow',
47+
'isActive' => false,
48+
'key' => 'tomorrow',
49+
], [
50+
'name' => 'admin::app.datagrid.filters.this-week',
51+
'isActive' => false,
52+
'key' => 'this_week',
53+
], [
54+
'name' => 'admin::app.datagrid.filters.this-month',
55+
'isActive' => true,
56+
'key' => 'this_month',
57+
], [
58+
'name' => 'admin::app.datagrid.filters.custom',
59+
'isActive' => false,
60+
'key' => 'custom',
61+
]
62+
]
63+
],
64+
],
65+
66+
"leads" => [
67+
[
68+
'type' => 'pill',
69+
'key' => 'type',
70+
'condition' => 'eq',
71+
"value_type" => "lookup",
72+
"repositoryClass" => "\Webkul\Lead\Repositories\StageRepository",
73+
]
74+
]
75+
];
76+
77+
?>

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

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -20,79 +20,7 @@ class ActivityDataGrid extends DataGrid
2020
public function __construct()
2121
{
2222
// table tab filters
23-
$this->tabFilters = [
24-
[
25-
'type' => 'pill',
26-
'key' => 'type',
27-
'condition' => 'eq',
28-
'values' => [
29-
[
30-
'name' => trans('admin::app.leads.all'),
31-
'isActive' => true,
32-
'key' => 'all',
33-
], [
34-
'name' => trans('admin::app.leads.note'),
35-
'isActive' => false,
36-
'key' => 'note',
37-
], [
38-
'name' => trans('admin::app.leads.call'),
39-
'isActive' => false,
40-
'key' => 'call',
41-
], [
42-
'name' => trans('admin::app.leads.email'),
43-
'isActive' => false,
44-
'key' => 'email',
45-
], [
46-
'name' => trans('admin::app.leads.meeting'),
47-
'isActive' => false,
48-
'key' => 'meeting',
49-
]
50-
]
51-
], [
52-
'type' => 'group',
53-
'key' => 'duration',
54-
'condition' => 'eq',
55-
'values' => [
56-
[
57-
'name' => 'Yesterday',
58-
'isActive' => false,
59-
'key' => 'yesterday',
60-
], [
61-
'name' => 'Today',
62-
'isActive' => false,
63-
'key' => 'today',
64-
], [
65-
'name' => 'Tomorrow',
66-
'isActive' => false,
67-
'key' => 'tomorrow',
68-
], [
69-
'name' => 'This week',
70-
'isActive' => false,
71-
'key' => 'this_week',
72-
], [
73-
'name' => 'This month',
74-
'isActive' => true,
75-
'key' => 'this_month',
76-
], [
77-
'name' => 'Custom',
78-
'isActive' => false,
79-
'key' => 'custom',
80-
]
81-
]
82-
],
83-
];
84-
85-
// persons list to filter table data
86-
$personRepository = app('\Webkul\Contact\Repositories\PersonRepository');
87-
88-
$persons = $personRepository->all();
89-
90-
foreach ($persons as $person) {
91-
array_push($this->persons, [
92-
'value' => $person['id'],
93-
'label' => $person['name'],
94-
]);
95-
}
23+
$this->tabFilters = $this->prepareTabFilters("activities");
9624

9725
parent::__construct();
9826
}
@@ -126,7 +54,7 @@ public function prepareQueryBuilder()
12654

12755
$this->addFilter('id', 'lead_activities.id');
12856
$this->addFilter('assigned_to', 'users.name');
129-
$this->addFilter('contact_person', 'persons.id');
57+
$this->addFilter('contact_person', 'persons.name');
13058
$this->addFilter('user', 'lead_activities.user_id');
13159
$this->addFilter('created_at', 'lead_activities.created_at');
13260

@@ -163,13 +91,15 @@ public function addColumns()
16391
]);
16492

16593
$this->addColumn([
166-
'index' => 'type',
167-
'label' => trans('admin::app.datagrid.type'),
168-
'type' => 'boolean',
94+
'index' => 'type',
95+
'head_style' => 'width: 70px',
96+
'label' => trans('admin::app.datagrid.type'),
97+
'type' => 'boolean',
16998
]);
17099

171100
$this->addColumn([
172101
'index' => 'is_done',
102+
'head_style' => 'width: 100px',
173103
'label' => trans('admin::app.datagrid.is_done'),
174104
'type' => 'boolean',
175105
'filterable_type' => 'dropdown',
@@ -195,8 +125,7 @@ public function addColumns()
195125
'index' => 'contact_person',
196126
'label' => trans('admin::app.datagrid.contact_person'),
197127
'type' => 'string',
198-
'filterable_type' => 'dropdown',
199-
'filterable_options' => $this->persons,
128+
'filterable_type' => 'add',
200129
'closure' => function ($row) {
201130
$route = urldecode(route('admin.contacts.persons.index', ['id[eq]' => $row->contact_person_id]));
202131

@@ -217,6 +146,7 @@ public function addColumns()
217146

218147
$this->addColumn([
219148
'index' => 'schedule_from',
149+
'head_style' => 'width: 100px',
220150
'label' => trans('admin::app.datagrid.schedule_from'),
221151
'title' => true,
222152
'type' => 'string',
@@ -229,6 +159,7 @@ public function addColumns()
229159

230160
$this->addColumn([
231161
'index' => 'schedule_to',
162+
'head_style' => 'width: 100px',
232163
'label' => trans('admin::app.datagrid.schedule_to'),
233164
'title' => true,
234165
'type' => 'string',
@@ -241,6 +172,7 @@ public function addColumns()
241172

242173
$this->addColumn([
243174
'index' => 'created_at',
175+
'head_style' => 'width: 100px',
244176
'label' => trans('admin::app.datagrid.created_at'),
245177
'title' => true,
246178
'type' => 'string',

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ public function addColumns()
5252
]);
5353

5454
$this->addColumn([
55-
'index' => 'emails',
56-
'label' => trans('admin::app.datagrid.emails'),
57-
'type' => 'string',
58-
'searchable' => true,
59-
'sortable' => false,
60-
'closure' => function ($row) {
55+
'index' => 'emails',
56+
'label' => trans('admin::app.datagrid.emails'),
57+
'type' => 'string',
58+
'searchable' => true,
59+
'sortable' => false,
60+
'filterable_type' => 'add',
61+
'closure' => function ($row) {
6162
$emails = json_decode($row->emails, true);
6263

6364
if ($emails) {
@@ -69,12 +70,13 @@ public function addColumns()
6970
]);
7071

7172
$this->addColumn([
72-
'index' => 'contact_numbers',
73-
'label' => trans('admin::app.datagrid.contact_numbers'),
74-
'type' => 'string',
75-
'searchable' => true,
76-
'sortable' => false,
77-
'closure' => function ($row) {
73+
'index' => 'contact_numbers',
74+
'label' => trans('admin::app.datagrid.contact_numbers'),
75+
'type' => 'string',
76+
'searchable' => true,
77+
'sortable' => false,
78+
'filterable_type' => 'add',
79+
'closure' => function ($row) {
7880
$contactNumbers = json_decode($row->contact_numbers, true);
7981

8082
if ($contactNumbers) {

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

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,7 @@ class LeadDataGrid extends DataGrid
1919
public function __construct()
2020
{
2121
// get all stages
22-
$stagesValues = [
23-
[
24-
'name' => trans('admin::app.leads.all'),
25-
'isActive' => true,
26-
'key' => 'all',
27-
]
28-
];
29-
30-
$stages = app('\Webkul\Lead\Repositories\StageRepository')
31-
->select('name', 'code as key')
32-
->get()
33-
->toArray();
34-
35-
foreach ($stages as $stage) {
36-
$stage['isActive'] = false;
37-
array_push($stagesValues, $stage);
38-
}
39-
40-
$this->tabFilters = [
41-
[
42-
'type' => 'pill',
43-
'key' => 'type',
44-
'condition' => 'eq',
45-
'values' => $stagesValues,
46-
],
47-
];
22+
$this->tabFilters = $this->prepareTabFilters("leads");
4823

4924
parent::__construct();
5025
}
@@ -113,12 +88,13 @@ public function addColumns()
11388
]);
11489

11590
$this->addColumn([
116-
'index' => 'lead_value',
117-
'label' => trans('admin::app.datagrid.lead_value'),
118-
'type' => 'string',
119-
'searchable' => true,
120-
'sortable' => true,
121-
'closure' => function ($row) {
91+
'index' => 'lead_value',
92+
'label' => trans('admin::app.datagrid.lead_value'),
93+
'type' => 'string',
94+
'searchable' => true,
95+
'sortable' => true,
96+
'filterable_type' => 'add',
97+
'closure' => function ($row) {
12298
return round($row->lead_value, 2);
12399
},
124100
]);

packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ public function addColumns()
4747
]);
4848

4949
$this->addColumn([
50-
'index' => 'price',
51-
'label' => trans('admin::app.datagrid.price'),
52-
'type' => 'string',
53-
'searchable' => true,
54-
'sortable' => true,
55-
'closure' => function ($row) {
50+
'index' => 'price',
51+
'label' => trans('admin::app.datagrid.price'),
52+
'type' => 'string',
53+
'searchable' => true,
54+
'sortable' => true,
55+
'filterable_type' => 'add',
56+
'closure' => function ($row) {
5657
return round($row->price, 2);
5758
},
5859
]);

packages/Webkul/Admin/src/DataGrids/Quote/QuoteDataGrid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function prepareQueryBuilder()
2727
'users.id as user_id',
2828
'users.name as user_name',
2929
'persons.id as person_id',
30-
'persons.name as person_name',
30+
'persons.name as person_name'
3131
)
3232
->leftJoin('users', 'quotes.user_id', '=', 'users.id')
3333
->leftJoin('persons', 'quotes.person_id', '=', 'persons.id');

packages/Webkul/Admin/src/Providers/AdminServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ protected function registerConfig()
9999
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/menu.php', 'menu.admin');
100100
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/core_config.php', 'core_config');
101101
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/dashboard_cards.php', 'dashboard_cards');
102+
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/datagrid_filters.php', 'datagrid_filters');
102103
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/attribute_lookups.php', 'attribute_lookups');
103104
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/attribute_entity_types.php', 'attribute_entity_types');
104105
}

packages/Webkul/Admin/src/Resources/lang/en/app.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@
529529
'comment' => 'Comment',
530530
'is_done' => 'Is Done',
531531
'type' => 'Type',
532+
'all' => 'All',
532533
'user' => 'User',
533534
'sales-person' => 'Sales Person',
534535
'person' => 'Person',
@@ -552,6 +553,14 @@
552553
'update-success' => ':resource updated successfully.',
553554
'destroy-success' => ':resource deleted successfully.',
554555
'destroy-failed' => ':resource can not be deleted.',
556+
'filters' => [
557+
'yesterday' => 'Yesterday',
558+
'today' => 'Today',
559+
'tomorrow' => 'Tomorrow',
560+
'this-week' => 'This week',
561+
'this-month' => 'This month',
562+
'custom' => 'Custom',
563+
]
555564
],
556565

557566
'response' => [

packages/Webkul/UI/publishable/assets/css/ui.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.

0 commit comments

Comments
 (0)