2015-03-16 22:45:25 +01:00
|
|
|
@extends('header')
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::open($entityType . 's/bulk')->addClass('listForm') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
<div style="display:none">
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::text('action') !!}
|
|
|
|
{!! Former::text('statusId') !!}
|
|
|
|
{!! Former::text('id') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
</div>
|
|
|
|
|
2015-04-01 17:44:55 +02:00
|
|
|
{!! DropdownButton::normal(trans('texts.archive'))->withContents([
|
|
|
|
['label' => trans('texts.archive_'.$entityType), 'url' => "javascript:submitForm('archive')"],
|
|
|
|
['label' => trans('texts.delete_'.$entityType), 'url' => "javascript:submitForm('delete')"],
|
|
|
|
])->withAttributes(['class'=>'archive'])->split() !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
<label for="trashed" style="font-weight:normal; margin-left: 10px;">
|
|
|
|
<input id="trashed" type="checkbox" onclick="setTrashVisible()"
|
|
|
|
{{ Session::get("show_trash:{$entityType}") ? 'checked' : ''}}/> {{ trans('texts.show_archived_deleted')}} {{ strtolower(trans('texts.'.$entityType.'s')) }}
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<div id="top_right_buttons" class="pull-right">
|
|
|
|
<input id="tableFilter" type="text" style="width:140px;margin-right:17px" class="form-control pull-left" placeholder="{{ trans('texts.filter') }}"/>
|
2015-04-01 21:57:02 +02:00
|
|
|
{!! Button::normal(trans("texts.new_$entityType"))->asLinkTo("/{$entityType}s/create")->withAttributes(array('class' => 'pull-right'))->appendIcon(Icon::create('plus-sign')) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
@if (isset($secEntityType))
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Datatable::table()
|
2015-03-16 22:45:25 +01:00
|
|
|
->addColumn($secColumns)
|
|
|
|
->setUrl(route('api.' . $secEntityType . 's'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
2015-03-26 07:24:02 +01:00
|
|
|
->render('datatable') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Datatable::table()
|
2015-03-16 22:45:25 +01:00
|
|
|
->addColumn($columns)
|
|
|
|
->setUrl(route('api.' . $entityType . 's'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
2015-03-26 07:24:02 +01:00
|
|
|
->render('datatable') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::close() !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function submitForm(action) {
|
|
|
|
if (action == 'delete') {
|
|
|
|
if (!confirm('Are you sure?')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#action').val(action);
|
|
|
|
$('form.listForm').submit();
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteEntity(id) {
|
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('delete');
|
|
|
|
}
|
|
|
|
|
|
|
|
function archiveEntity(id) {
|
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('archive');
|
|
|
|
}
|
|
|
|
|
|
|
|
function restoreEntity(id) {
|
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('restore');
|
|
|
|
}
|
|
|
|
function convertEntity(id) {
|
|
|
|
$('#id').val(id);
|
|
|
|
submitForm('convert');
|
|
|
|
}
|
|
|
|
|
|
|
|
function markEntity(id, statusId) {
|
|
|
|
$('#id').val(id);
|
|
|
|
$('#statusId').val(statusId);
|
|
|
|
submitForm('mark');
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTrashVisible() {
|
|
|
|
var checked = $('#trashed').is(':checked');
|
|
|
|
window.location = '{{ URL::to('view_archive/' . $entityType) }}' + (checked ? '/true' : '/false');
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
@stop
|
|
|
|
|
|
|
|
@section('onReady')
|
|
|
|
|
|
|
|
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);
|
|
|
|
})
|
|
|
|
|
|
|
|
window.onDatatableReady = function() {
|
|
|
|
$(':checkbox').click(function() {
|
|
|
|
setArchiveEnabled();
|
|
|
|
});
|
|
|
|
|
2015-04-08 20:19:58 +02:00
|
|
|
$('tbody tr').click(function(event) {
|
2015-03-16 22:45:25 +01:00
|
|
|
if (event.target.type !== 'checkbox' && event.target.type !== 'button' && event.target.tagName.toLowerCase() !== 'a') {
|
|
|
|
$checkbox = $(this).closest('tr').find(':checkbox:not(:disabled)');
|
|
|
|
var checked = $checkbox.prop('checked');
|
|
|
|
$checkbox.prop('checked', !checked);
|
|
|
|
setArchiveEnabled();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('tbody tr').mouseover(function() {
|
|
|
|
$(this).closest('tr').find('.tr-action').css('visibility','visible');
|
|
|
|
}).mouseout(function() {
|
|
|
|
$dropdown = $(this).closest('tr').find('.tr-action');
|
|
|
|
if (!$dropdown.hasClass('open')) {
|
|
|
|
$dropdown.css('visibility','hidden');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-01 17:44:55 +02:00
|
|
|
$('.archive').prop('disabled', true);
|
|
|
|
$('.archive:not(.dropdown-toggle)').click(function() {
|
2015-03-16 22:45:25 +01:00
|
|
|
submitForm('archive');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.selectAll').click(function() {
|
|
|
|
$(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
|
|
|
|
});
|
|
|
|
|
|
|
|
function setArchiveEnabled() {
|
|
|
|
var checked = $('tbody :checkbox:checked').length > 0;
|
2015-04-08 20:19:58 +02:00
|
|
|
$('button.archive').prop('disabled', !checked);
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@stop
|