1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 11:42:28 +01:00

Merge disable/delete column to Control

This commit is contained in:
Anh Tuấn 2017-10-28 14:01:58 +07:00
parent a2cd017684
commit f047e31513
3 changed files with 14 additions and 12 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Yajra\Datatables\Facades\Datatables; use Yajra\Datatables\Facades\Datatables;
@ -123,6 +124,12 @@ class AdminPaginationController extends Controller {
</a>'; </a>';
} }
public function renderControlLinkCell($link){
return '<div class="btn-group" role="group">
' . $this->renderToggleLinkActiveCell($link) . $this->renderDeleteLinkCell($link) . '
</div>';
}
/* DataTables bindings */ /* DataTables bindings */
public function paginateAdminUsers(Request $request) { 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']); $admin_links = Link::select(['short_url', 'long_url', 'clicks', 'created_at', 'creator', 'is_disabled']);
return Datatables::of($admin_links) return Datatables::of($admin_links)
->addColumn('disable', [$this, 'renderToggleLinkActiveCell']) ->addColumn('control', [$this, 'renderControlLinkCell'])
->addColumn('delete', [$this, 'renderDeleteLinkCell'])
->editColumn('clicks', [$this, 'renderClicksCell']) ->editColumn('clicks', [$this, 'renderClicksCell'])
->editColumn('long_url', [$this, 'renderLongUrlCell']) ->editColumn('long_url', [$this, 'renderLongUrlCell'])
->escapeColumns(['short_url', 'creator']) ->escapeColumns(['short_url', 'creator'])

View File

@ -152,15 +152,12 @@ polr.controller('AdminCtrl', function($scope, $compile, $timeout) {
"ajax": BASE_API_PATH + 'admin/get_admin_links', "ajax": BASE_API_PATH + 'admin/get_admin_links',
"columns": [ "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'}, {className: 'wrap-text', data: 'long_url', name: 'long_url'},
{data: 'clicks', name: 'clicks'}, {data: 'clicks', name: 'clicks', width: '10%'},
{data: 'created_at', name: 'created_at'}, {data: 'created_at', name: 'created_at', width: '18%'},
{data: 'creator', name: 'creator'}, {data: 'creator', name: 'creator', width: '20%'},
{data: 'control', name: 'control', orderable: false, searchable: false, width: '15%'},
{data: 'disable', name: 'disable', orderable: false, searchable: false},
{data: 'delete', name: 'delete', orderable: false, searchable: false}
] ]
}, datatables_config)); }, datatables_config));
} }

View File

@ -8,8 +8,7 @@
@if ($table_id == "admin_links_table") @if ($table_id == "admin_links_table")
{{-- Show action buttons only if admin view --}} {{-- Show action buttons only if admin view --}}
<th>Creator</th> <th>Creator</th>
<th>Disable</th> <th>Control</th>
<th>Delete</th>
@endif @endif
</tr> </tr>
</thead> </thead>