Skip to content

Commit

Permalink
Beginning of #851 - no controller methods yet, but still troubleshoot…
Browse files Browse the repository at this point in the history
…ing stupid datatables errors.

[Error] TypeError: undefined is not an object (evaluating 'f.nTf=a[b].cell')
	jb (jquery.dataTables.min.js, line 24)
	ga (jquery.dataTables.min.js, line 45)
	(anonymous function) (jquery.dataTables.min.js, line 92)
	each (jquery-latest.js, line 383)
	each (jquery-latest.js, line 136)
	o (jquery.dataTables.min.js, line 82)
	(anonymous function) (users, line 371)
	fire (jquery-latest.js, line 3119)
	fireWith (jquery-latest.js, line 3231)
	ready (jquery-latest.js, line 3443)
	completed (jquery-latest.js, line 3474)
  • Loading branch information
snipe committed Jul 9, 2015
1 parent c8842a8 commit 6524ac3
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 32 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,10 @@ public function getDatatable($status = null)


return Datatable::collection($users)
->addColumn('',function($users)
{
return '<input type="checkbox" name="edit_user['.$users->id.']" class="one_required">';
})
->addColumn('name',function($users)
{
return '<a title="'.$users->fullName().'" href="users/'.$users->id.'/view">'.$users->fullName().'</a>';
Expand Down
9 changes: 9 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@
Route::get('{userId}/restore', array('as' => 'restore/user', 'uses' => 'UsersController@getRestore'));
Route::get('{userId}/view', array('as' => 'view/user', 'uses' => 'UsersController@getView'));
Route::get('{userId}/unsuspend', array('as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend'));

Route::post('bulkedit',
array('as' => 'users/bulkedit',
'uses' => 'UsersController@postBulkEdit'));
Route::post('bulksave',
array('as' => 'users/bulksave',
'uses' => 'UsersController@postBulkSave'));


Route::get('/', array('as' => 'users', 'uses' => 'UsersController@getIndex'));

});
Expand Down
20 changes: 10 additions & 10 deletions app/views/backend/hardware/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('backend/layouts/default')

@section('title0')

@if (Input::get('status'))
@if (Input::get('status')=='Pending')
@lang('general.pending')
Expand Down Expand Up @@ -57,16 +57,16 @@


{{ Datatable::table()
->addColumn('<input type="checkbox" id="checkAll" style="padding-left: 0px;">',Lang::get('admin/hardware/form.name'),
Lang::get('admin/hardware/table.asset_tag'),
->addColumn('<input type="checkbox" id="checkAll" style="padding-left: 0px;">',Lang::get('admin/hardware/form.name'),
Lang::get('admin/hardware/table.asset_tag'),
Lang::get('admin/hardware/table.serial'),
Lang::get('admin/hardware/form.model'),
Lang::get('admin/hardware/table.status'),
Lang::get('admin/hardware/table.location'),
Lang::get('general.category'),
Lang::get('admin/hardware/table.eol'),
Lang::get('admin/hardware/table.checkout_date'),
Lang::get('admin/hardware/table.change'),
Lang::get('admin/hardware/table.checkout_date'),
Lang::get('admin/hardware/table.change'),
Lang::get('table.actions'))
->setOptions(
array(
Expand All @@ -75,7 +75,7 @@
'lengthMenu' => Lang::get('general.page_menu'),
'loadingRecords' => Lang::get('general.loading'),
'zeroRecords' => Lang::get('general.no_results'),
'info' => Lang::get('general.pagination_info'),
'info' => Lang::get('general.pagination_info'),
'processing' => Lang::get('general.processing'),
'paginate'=> array(
'first'=>Lang::get('general.first'),
Expand Down Expand Up @@ -112,17 +112,17 @@ function checkForChecked() {
$('#bulkEdit').attr('disabled', 'disabled');
}
}
$('table').on('change','input.one_required',checkForChecked);
$("#checkAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
checkForChecked();
});
});
</script>


Expand Down
37 changes: 37 additions & 0 deletions app/views/backend/users/datatable.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<table id="{{ $id }}" class="{{ $class }}">
<colgroup>
@for ($i = 0; $i < count($columns); $i++)
<col class="con{{ $i }}" />
@endfor
</colgroup>
<thead>
<tr>
@foreach($columns as $i => $c)
<th align="center" valign="middle" class="head{{ $i }}">{{ $c }}</th>
@endforeach
</tr>
</thead>
<tfoot>
<tr>
<td colspan="12">
<select name="bulk_actions">
<option value="edit">Bulk Edit</option>
<option value="delete">Bulk Delete</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>Go</button></td>
</tr>
</tfoot>
<tbody>
@foreach($data as $d)
<tr>
@foreach($d as $dd)
<td>{{ $dd }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>

@if (!$noScript)
@include(Config::get('datatable::table.script_view'), array('id' => $id, 'options' => $options, 'callbacks' => $callbacks))
@endif
105 changes: 83 additions & 22 deletions app/views/backend/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,95 @@
</div>

<div class="row">
{{ Form::open([
'method' => 'POST',
'route' => ['users/bulkedit'],
'class' => 'form-horizontal' ]) }}

{{ Datatable::table()
->addColumn(
Lang::get('admin/users/table.name'),
'<i class="fa fa-envelope fa-lg"></i>',
Lang::get('admin/users/table.manager'),
Lang::get('admin/users/table.location'),
'<i class="fa fa-barcode fa-lg"></i>',
'<i class="fa fa-certificate fa-lg"></i>',
'<i class="fa fa-keyboard-o fa-lg"></i>',
'<i class="fa fa-tint fa-lg"></i>',
Lang::get('general.groups'),
Lang::get('table.actions')
)
->setOptions(
array(
'sAjaxSource'=>route('api.users.list', Input::get('status')),
'dom' =>'CT<"clear">lfrtip',
'colVis'=> array('showAll'=>'Show All','restore'=>'Restore','activate'=>'mouseover'),
'columnDefs'=> array(array('visible'=>false,'targets'=>array()),array('bSortable'=>false,'targets'=>array(8))),
'order'=>array(array(1,'asc')),

{{ Datatable::table()
->addColumn('<input type="checkbox" id="checkAll" style="padding-left: 0px;">',
Lang::get('admin/users/table.name'),
'<i class="fa fa-envelope fa-lg"></i>',
Lang::get('admin/users/table.manager'),
Lang::get('admin/users/table.location'),
'<i class="fa fa-barcode fa-lg"></i>',
'<i class="fa fa-certificate fa-lg"></i>',
'<i class="fa fa-keyboard-o fa-lg"></i>',
'<i class="fa fa-tint fa-lg"></i>',
Lang::get('general.groups'),
Lang::get('table.actions'))
->setOptions(
array(
'language' => array(
'search' => Lang::get('general.search'),
'lengthMenu' => Lang::get('general.page_menu'),
'loadingRecords' => Lang::get('general.loading'),
'zeroRecords' => Lang::get('general.no_results'),
'info' => Lang::get('general.pagination_info'),
'processing' => Lang::get('general.processing'),
'paginate'=> array(
'first'=>Lang::get('general.first'),
'previous'=>Lang::get('general.previous'),
'next'=>Lang::get('general.next'),
'last'=>Lang::get('general.last'),
),
),
'sAjaxSource'=> route('api.users.list', Input::get('status')),
'dom' =>'CT<"clear">lfrtip',
'colVis'=>
array(
'showAll'=>'Show All',
'restore'=>'Restore',
'exclude'=>array(0,10),
'activate'=>'mouseover'
),
'columnDefs'=>
array(
array(
'visible'=>false,
'targets'=>array()
),
array(
'orderable'=>false,
'targets'=>array(0,10)
)
),
'order'=>array(array(1,'asc')),
)
)
->render() }}

->render('backend/users/datatable') }}

{{ Form::close() }}
</div>
</div>

<script>
$(function() {
function checkForChecked() {
var check_checked = $('input.one_required:checked').length;
if (check_checked > 0) {
$('#bulkEdit').removeAttr('disabled');
}
else {
$('#bulkEdit').attr('disabled', 'disabled');
}
}
$('table').on('change','input.one_required',checkForChecked);
$("#checkAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
checkForChecked();
});
});
</script>

@stop

0 comments on commit 6524ac3

Please sign in to comment.