Skip to content

Commit

Permalink
Merge pull request cydrobolt#385 from tdtgit/better-admin-polr
Browse files Browse the repository at this point in the history
Better dashboard: Merge Delete/Disable column to Control column
  • Loading branch information
overint authored Mar 29, 2018
2 parents eafce58 + 13d76e9 commit 8c0d012
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/AdminPaginationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public function renderToggleLinkActiveCell($link) {
</a>';
}

public function renderControlLinkCell($link){
return '<div class="btn-group" role="group">
' . $this->renderToggleLinkActiveCell($link) . $this->renderDeleteLinkCell($link) . '
</div>';
}

/* DataTables bindings */

public function paginateAdminUsers(Request $request) {
Expand All @@ -143,8 +149,7 @@ public function paginateAdminLinks(Request $request) {

$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'])
Expand Down
13 changes: 5 additions & 8 deletions public/js/AdminCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
3 changes: 1 addition & 2 deletions resources/views/snippets/link_table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
@if ($table_id == "admin_links_table")
{{-- Show action buttons only if admin view --}}
<th>Creator</th>
<th>Disable</th>
<th>Delete</th>
<th>Control</th>
@endif
</tr>
</thead>
Expand Down

0 comments on commit 8c0d012

Please sign in to comment.