2013-12-01 08:33:17 +01:00
|
|
|
@extends('header')
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
|
2013-12-03 18:32:33 +01:00
|
|
|
{{ Former::open($entityType . 's/bulk')->addClass('listForm') }}
|
2013-12-05 16:23:24 +01:00
|
|
|
<div style="display:none">
|
|
|
|
{{ Former::text('action') }}
|
|
|
|
{{ Former::text('id') }}
|
|
|
|
</div>
|
2013-12-01 08:33:17 +01:00
|
|
|
|
|
|
|
{{ DropdownButton::normal('Archive',
|
|
|
|
Navigation::links(
|
|
|
|
array(
|
2013-12-05 21:25:20 +01:00
|
|
|
array('Archive '.ucwords($entityType), "javascript:submitForm('archive')"),
|
|
|
|
array('Delete '.ucwords($entityType), "javascript:submitForm('delete')"),
|
2013-12-01 08:33:17 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
, array('id'=>'archive'))->split(); }}
|
|
|
|
|
|
|
|
|
2013-12-11 21:33:44 +01:00
|
|
|
<div id="top_right_buttons" class="pull-right">
|
|
|
|
<input id="tableFilter" type="text" style="width:140px;margin-right:4px" class="form-control pull-left" placeholder="Filter"/>
|
|
|
|
{{ Button::primary_link(URL::to($entityType . 's/create'), 'New ' . Utils::getEntityName($entityType), array('class' => 'pull-right')) }}
|
|
|
|
</div>
|
|
|
|
|
2013-12-11 12:11:59 +01:00
|
|
|
@if (isset($secEntityType))
|
|
|
|
{{ Datatable::table()
|
|
|
|
->addColumn($secColumns)
|
|
|
|
->setUrl(route('api.' . $secEntityType . 's'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
|
|
|
->render('datatable') }}
|
|
|
|
@endif
|
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
{{ Datatable::table()
|
|
|
|
->addColumn($columns)
|
|
|
|
->setUrl(route('api.' . $entityType . 's'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
|
|
|
->render('datatable') }}
|
2013-12-11 12:11:59 +01:00
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
{{ Former::close() }}
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function submitForm(action) {
|
2013-12-01 21:58:25 +01:00
|
|
|
if (action == 'delete') {
|
|
|
|
if (!confirm('Are you sure')) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-05 16:23:24 +01:00
|
|
|
}
|
2013-12-11 21:33:44 +01:00
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
$('#action').val(action);
|
2013-12-03 18:32:33 +01:00
|
|
|
$('form.listForm').submit();
|
2013-12-01 08:33:17 +01:00
|
|
|
}
|
|
|
|
|
2013-12-01 21:58:25 +01:00
|
|
|
function deleteEntity(id) {
|
2014-01-14 12:52:56 +01:00
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('delete');
|
2013-12-01 21:58:25 +01:00
|
|
|
}
|
|
|
|
|
2013-12-05 16:23:24 +01:00
|
|
|
function archiveEntity(id) {
|
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('archive');
|
|
|
|
}
|
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
@stop
|
|
|
|
|
|
|
|
@section('onReady')
|
2013-12-11 21:33:44 +01:00
|
|
|
|
|
|
|
var tableFilter = '';
|
|
|
|
var searchTimeout = false;
|
|
|
|
|
|
|
|
var oTable0 = $('#DataTables_Table_0').dataTable();
|
|
|
|
var oTable1 = $('#DataTables_Table_1').dataTable();
|
|
|
|
function filterTable(val) {
|
|
|
|
if (val == tableFilter) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tableFilter = val;
|
|
|
|
oTable0.fnFilter(val);
|
|
|
|
@if (isset($secEntityType))
|
|
|
|
oTable1.fnFilter(val);
|
|
|
|
@endif
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#tableFilter').on('keyup', function(){
|
|
|
|
if (searchTimeout) {
|
|
|
|
window.clearTimeout(searchTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
searchTimeout = setTimeout(function() {
|
|
|
|
filterTable($('#tableFilter').val());
|
|
|
|
}, 1000);
|
|
|
|
})
|
|
|
|
|
2014-01-06 19:03:00 +01:00
|
|
|
window.onDatatableReady = function() {
|
2013-12-01 08:33:17 +01:00
|
|
|
$(':checkbox').click(function() {
|
|
|
|
setArchiveEnabled();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('tbody tr').click(function(event) {
|
2013-12-01 21:58:25 +01:00
|
|
|
if (event.target.type !== 'checkbox' && event.target.type !== 'button' && event.target.tagName.toLowerCase() !== 'a') {
|
2013-12-01 08:33:17 +01:00
|
|
|
$checkbox = $(this).closest('tr').find(':checkbox');
|
|
|
|
var checked = $checkbox.prop('checked');
|
|
|
|
$checkbox.prop('checked', !checked);
|
|
|
|
setArchiveEnabled();
|
|
|
|
}
|
|
|
|
});
|
2013-12-01 21:58:25 +01:00
|
|
|
|
|
|
|
$('tbody tr').mouseover(function() {
|
2013-12-05 16:23:24 +01:00
|
|
|
$(this).closest('tr').find('.tr-action').css('visibility','visible');
|
2013-12-01 21:58:25 +01:00
|
|
|
}).mouseout(function() {
|
|
|
|
$dropdown = $(this).closest('tr').find('.tr-action');
|
|
|
|
if (!$dropdown.hasClass('open')) {
|
2013-12-05 16:23:24 +01:00
|
|
|
$dropdown.css('visibility','hidden');
|
|
|
|
}
|
2013-12-01 21:58:25 +01:00
|
|
|
});
|
2013-12-11 21:33:44 +01:00
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#archive > button').prop('disabled', true);
|
|
|
|
$('#archive > button:first').click(function() {
|
|
|
|
submitForm('archive');
|
|
|
|
});
|
|
|
|
|
2013-12-11 12:11:59 +01:00
|
|
|
$('.selectAll').click(function() {
|
|
|
|
$(this).closest('table').find(':checkbox').prop('checked', this.checked);
|
2013-12-01 08:33:17 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
function setArchiveEnabled() {
|
|
|
|
var checked = $('tbody :checkbox:checked').length > 0;
|
|
|
|
$('#archive > button').prop('disabled', !checked);
|
|
|
|
}
|
2013-12-01 21:58:25 +01:00
|
|
|
|
|
|
|
|
2013-12-01 08:33:17 +01:00
|
|
|
|
|
|
|
@stop
|