From f047e315135d9ede27c41574867d34b93e0359af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anh=20Tu=E1=BA=A5n?= Date: Sat, 28 Oct 2017 14:01:58 +0700 Subject: [PATCH 1/2] Merge disable/delete column to Control --- app/Http/Controllers/AdminPaginationController.php | 10 ++++++++-- public/js/AdminCtrl.js | 13 +++++-------- resources/views/snippets/link_table.blade.php | 3 +-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/AdminPaginationController.php b/app/Http/Controllers/AdminPaginationController.php index 01297ab..2cb51b4 100644 --- a/app/Http/Controllers/AdminPaginationController.php +++ b/app/Http/Controllers/AdminPaginationController.php @@ -1,4 +1,5 @@ '; } + public function renderControlLinkCell($link){ + return '
+ ' . $this->renderToggleLinkActiveCell($link) . $this->renderDeleteLinkCell($link) . ' +
'; + } + /* DataTables bindings */ public function paginateAdminUsers(Request $request) { @@ -143,8 +150,7 @@ class AdminPaginationController extends Controller { $admin_links = Link::select(['short_url', 'long_url', 'clicks', 'created_at', 'creator', 'is_disabled']); return Datatables::of($admin_links) - ->addColumn('disable', [$this, 'renderToggleLinkActiveCell']) - ->addColumn('delete', [$this, 'renderDeleteLinkCell']) + ->addColumn('control', [$this, 'renderControlLinkCell']) ->editColumn('clicks', [$this, 'renderClicksCell']) ->editColumn('long_url', [$this, 'renderLongUrlCell']) ->escapeColumns(['short_url', 'creator']) diff --git a/public/js/AdminCtrl.js b/public/js/AdminCtrl.js index 586fb96..2fbbd2c 100644 --- a/public/js/AdminCtrl.js +++ b/public/js/AdminCtrl.js @@ -152,15 +152,12 @@ polr.controller('AdminCtrl', function($scope, $compile, $timeout) { "ajax": BASE_API_PATH + 'admin/get_admin_links', "columns": [ - {className: 'wrap-text', data: 'short_url', name: 'short_url'}, + {className: 'wrap-text', data: 'short_url', name: 'short_url', width: '10%'}, {className: 'wrap-text', data: 'long_url', name: 'long_url'}, - {data: 'clicks', name: 'clicks'}, - {data: 'created_at', name: 'created_at'}, - {data: 'creator', name: 'creator'}, - - {data: 'disable', name: 'disable', orderable: false, searchable: false}, - {data: 'delete', name: 'delete', orderable: false, searchable: false} - + {data: 'clicks', name: 'clicks', width: '10%'}, + {data: 'created_at', name: 'created_at', width: '18%'}, + {data: 'creator', name: 'creator', width: '20%'}, + {data: 'control', name: 'control', orderable: false, searchable: false, width: '15%'}, ] }, datatables_config)); } diff --git a/resources/views/snippets/link_table.blade.php b/resources/views/snippets/link_table.blade.php index 554d9a2..a8a2e5a 100644 --- a/resources/views/snippets/link_table.blade.php +++ b/resources/views/snippets/link_table.blade.php @@ -8,8 +8,7 @@ @if ($table_id == "admin_links_table") {{-- Show action buttons only if admin view --}} Creator - Disable - Delete + Control @endif From 357d134818e7e82fd70ea13bd21e0c8929170654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anh=20Tu=E1=BA=A5n?= Date: Sat, 28 Oct 2017 15:43:37 +0700 Subject: [PATCH 2/2] Remove enter on top --- app/Http/Controllers/AdminPaginationController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/AdminPaginationController.php b/app/Http/Controllers/AdminPaginationController.php index 2cb51b4..79a5818 100644 --- a/app/Http/Controllers/AdminPaginationController.php +++ b/app/Http/Controllers/AdminPaginationController.php @@ -1,5 +1,4 @@