Skip to content

Commit e412eb4

Browse files
UI updates for better user experience, better client side error tracking, brings more awesomeness
1 parent d880814 commit e412eb4

28 files changed

+339
-121
lines changed

app/Http/Controllers/AutocompleteController.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,39 +115,47 @@ public function getData(Request $request)
115115
public function getUniverseResults($query)
116116
{
117117
$pages = [
118-
['label' => __('Modules'), 'val' => route('show.app.modules')],
119-
['label' => __('Activity'), 'val' => route('show.app.activity')],
120-
['label' => __('Settings'), 'val' => route('show.app.settings')],
121-
['label' => __('Profile'), 'val' => route('show.doc', ['slug' => 'user', 'id' => auth()->user()->id])],
118+
['label' => __('Modules'), 'value' => __('Modules'), 'redirect_to' => route('show.app.modules')],
119+
['label' => __('Activity'), 'value' => __('Activity'), 'redirect_to' => route('show.app.activity')],
120+
['label' => __('Settings'), 'value' => __('Settings'), 'redirect_to' => route('show.app.settings')],
121+
['label' => __('Profile'), 'value' => __('Profile'), 'redirect_to' => route('show.doc', ['slug' => 'user', 'id' => auth()->user()->id])],
122122
];
123123

124124
$allowed_modules = [];
125125
$reports = [];
126126

127127
if (auth()->user()->role == "Administrator" && auth()->user()->username == "admin") {
128-
array_push($pages, ['label' => __('Backups'), 'val' => route('show.app.backups')]);
128+
array_push($pages, ['label' => __('Backups'), 'value' => __('Backups'), 'redirect_to' => route('show.app.backups')]);
129129
}
130130

131131
$modules = $this->getAppModules();
132132

133133
if (auth()->user()->role == 'System Administrator') {
134134
foreach ($modules as $module_name => $config) {
135-
array_push($allowed_modules, ['label' => '<b>' . __($config['display_name']) . '</b> ' . __('List'), 'val' => route('show.list', $config['slug'])]);
135+
array_push($allowed_modules, [
136+
'label' => '<b>' . __($config['display_name']) . '</b> ' . __('List'),
137+
'value' => __($config['display_name']) . ' ' . __('List'),
138+
'redirect_to' => route('show.list', $config['slug'])
139+
]);
136140
}
137141
} else {
138142
$role_modules = $this->roleWiseModules(auth()->user()->role, "Read");
139143

140144
if ($role_modules) {
141145
foreach ($modules as $module_name => $config) {
142146
if (in_array($module_name, $role_modules)) {
143-
array_push($allowed_modules, ['label' => '<b>' . __($config['display_name']) . '</b> ' . __('List'), 'val' => route('show.list', $config['slug'])]);
147+
array_push($allowed_modules, [
148+
'label' => '<b>' . __($config['display_name']) . '</b> ' . __('List'),
149+
'value' => __($config['display_name']) . ' ' . __('List'),
150+
'redirect_to' => route('show.list', $config['slug'])
151+
]);
144152
}
145153
}
146154
}
147155
}
148156

149157
if (in_array(auth()->user()->role, ["System Administrator", "Administrator"])) {
150-
array_push($pages, ['label' => __('Reports'), 'val' => route('show.app.reports')]);
158+
array_push($pages, ['label' => __('Reports'), 'value' => __('Reports'), 'redirect_to' => route('show.app.reports')]);
151159
}
152160

153161
$app_reports = config('reports');
@@ -157,7 +165,7 @@ public function getUniverseResults($query)
157165
continue;
158166
}
159167

160-
array_push($reports, ['label' => __($report['label']), 'val' => route('show.report', Str::snake($report_name))]);
168+
array_push($reports, ['label' => __($report['label']), 'value' => __($report['label']), 'redirect_to' => route('show.report', Str::snake($report_name))]);
161169
}
162170

163171
if ($reports && count($reports)) {
@@ -171,15 +179,15 @@ public function getUniverseResults($query)
171179
}
172180

173181
if (!$found) {
174-
array_push($pages, ['label' => __('Reports'), 'val' => route('show.app.reports')]);
182+
array_push($pages, ['label' => __('Reports'), 'value' => __('Reports'), 'redirect_to' => route('show.app.reports')]);
175183
}
176184
}
177185

178186
$result = array_merge($pages, $allowed_modules, $reports);
179187

180188
if ($query) {
181189
foreach ($result as $idx => $res) {
182-
if (!Str::contains(strip_tags(strtolower($res['label'])), strtolower($query))) {
190+
if (!Str::contains(strip_tags(strtolower($res['value'])), strtolower($query))) {
183191
unset($result[$idx]);
184192
}
185193
}
@@ -247,7 +255,8 @@ public function getUniverseResults($query)
247255
foreach ($data as $idx => $record) {
248256
array_push($result, [
249257
'label' => $table['module_label'] . ' <b>' . __(strval($record->{$table['fetch_fields'][1]})) . '</b>',
250-
'val' => route('show.doc', ['slug' => $table['module_slug'], 'id' => $record->id])
258+
'value' => $table['module_label'] . ' ' . __(strval($record->{$table['fetch_fields'][1]})),
259+
'redirect_to' => route('show.doc', ['slug' => $table['module_slug'], 'id' => $record->id])
251260
]);
252261
}
253262
}

app/Http/Controllers/CommonController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ public function getModuleSlug($module)
4949
// get table name from module
5050
public function getModuleTable($module)
5151
{
52-
$module_config = $this->getAppModules();
53-
return $module_config[$module]['table_name'];
52+
$app_modules = $this->getAppModules();
53+
54+
if (isset($app_modules[$module]) && $app_modules[$module]) {
55+
if (isset($app_modules[$module]['table_name']) && $app_modules[$module]['table_name']) {
56+
return $app_modules[$module]['table_name'];
57+
}
58+
}
59+
60+
return false;
5461
}
5562

5663
// check is referer is list view

app/Http/Controllers/ListViewController.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public function showList(Request $request, $slug)
4949

5050
public function showListView($request)
5151
{
52-
$table_name = $this->module['table_name'];
53-
$columns = array_map('trim', explode(",", $this->module['list_view_columns']));
54-
$form_title = $this->module['form_title'];
55-
5652
if ($request->ajax() || $request->is('api/*')) {
53+
$table_name = $this->module['table_name'];
54+
$columns = array_map('trim', explode(",", $this->module['list_view_columns']));
55+
$form_title = $this->module['form_title'];
56+
5757
if ($request->filled('delete_list')) {
5858
$delete_data = $this->deleteSelectedRecords($request, $request->get('delete_list'));
5959
return response()->json(['data' => $delete_data], 200);
@@ -63,7 +63,7 @@ public function showListView($request)
6363
$list_view_data = $this->prepareListViewData($request);
6464
return $list_view_data;
6565
} catch(Exception $e) {
66-
return response()->json(['message' => $e->getMessage()], 404);
66+
return response()->json(['msg' => $e->getMessage()], 200);
6767
}
6868
}
6969
else {
@@ -82,11 +82,15 @@ public function prepareListViewData($request)
8282
$user_role = auth()->user()->role;
8383
$table_schema = $this->getTableSchema($this->module['table_name']);
8484

85-
try {
86-
$rows = $this->getRecords($request, $table_schema);
87-
} catch(Exception $e) {
88-
$error = str_replace("'", "", $e->getMessage());
89-
throw new Exception($error);
85+
if ($request->ajax() || $request->is('api/*')) {
86+
try {
87+
$rows = $this->getRecords($request, $table_schema);
88+
} catch(Exception $e) {
89+
$error = str_replace("'", "", $e->getMessage());
90+
throw new Exception($error);
91+
}
92+
} else {
93+
$rows = [];
9094
}
9195

9296
if ($user_role == 'System Administrator') {
@@ -130,6 +134,7 @@ public function deleteSelectedRecords($request, $delete_records)
130134

131135
public function getRecords($request, $table_schema)
132136
{
137+
logger('getRecords');
133138
$table = $this->module['table_name'];
134139
$table_columns = array_map('trim', explode(",", $this->module['list_view_columns']));
135140
$sort_field = $this->module['sort_field'];

app/Http/Controllers/ReportController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace App\Http\Controllers;
44

5+
use Str;
6+
use Exception;
57
use App\Exports\ExcelExport;
68
use Maatwebsite\Excel\Facades\Excel;
79
use App\Http\Controllers\CommonController;
8-
use Str;
910
use Illuminate\Http\Request;
1011

1112
class ReportController extends Controller
@@ -52,7 +53,16 @@ public function showReport(Request $request, $report_name)
5253
$report_data = $this->getData($request, $report_name);
5354

5455
if (isset($report_data['module']) && $report_data['module']) {
55-
$report_data['module_slug'] = $this->getModuleSlug($report_data['module']);
56+
$app_modules = $this->getAppModules();
57+
$report_module = $report_data['module'];
58+
59+
if (isset($app_modules[$report_module]) && $app_modules[$report_module]) {
60+
$report_data['module_name'] = $app_modules[$report_module]['display_name'];
61+
$report_data['module_slug'] = $app_modules[$report_module]['slug'];
62+
$report_data['module_new_record'] = route('new.doc', ['slug' => $report_data['module_slug']]);
63+
} else {
64+
throw new Exception('"' . $report_module . '" Module does not exist. Please update the module in ' . Str::studly($report_name) . ' controller');
65+
}
5666
}
5767

5868
return $report_data;

public/css/all.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.

public/img/add.svg

Lines changed: 12 additions & 0 deletions
Loading

public/img/no_results.svg

Lines changed: 12 additions & 0 deletions
Loading

public/js/all.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.

public/js/origin/activity.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.

0 commit comments

Comments
 (0)