Fix checkbox logic on export page

This commit is contained in:
Hillel Coren 2016-09-13 16:12:27 +03:00
parent 29a014df20
commit 3588f82fce

View File

@ -49,7 +49,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
{!! Former::select('format') {!! Former::select('format')
->onchange('setEntityTypesVisible()') ->onchange('setCheckboxesEnabled()')
->addOption('CSV', 'CSV') ->addOption('CSV', 'CSV')
->addOption('XLS', 'XLS') ->addOption('XLS', 'XLS')
->addOption('JSON', 'JSON') ->addOption('JSON', 'JSON')
@ -58,7 +58,7 @@
{!! Former::inline_radios('include_radio') {!! Former::inline_radios('include_radio')
->onchange('onIncludeChange()') ->onchange('setCheckboxesEnabled()')
->label(trans('texts.include')) ->label(trans('texts.include'))
->radios([ ->radios([
trans('texts.all') . ' &nbsp; ' => ['value' => 'all', 'name' => 'include'], trans('texts.all') . ' &nbsp; ' => ['value' => 'all', 'name' => 'include'],
@ -92,17 +92,18 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
setFileTypesVisible(); setCheckboxesEnabled();
onIncludeChange();
}); });
function setEntityTypesVisible() { function setCheckboxesEnabled() {
var selector = '.entity-types input[type=checkbox]'; var $checkboxes = $('input[type=checkbox]');
if ($('#format').val() === 'JSON') { var include = $('input[name=include]:checked').val()
$(selector).attr('disabled', true); var format = $('#format').val();
} else { if (include === 'all' || format === 'JSON') {
$(selector).removeAttr('disabled'); $checkboxes.attr('disabled', true);
} } else {
$checkboxes.removeAttr('disabled');
}
} }
function setFileTypesVisible() { function setFileTypesVisible() {
@ -128,16 +129,6 @@
@endforeach @endforeach
} }
function onIncludeChange() {
var $checkboxes = $('input[type=checkbox]');
var val = $('input[name=include]:checked').val()
if (val == 'all') {
$checkboxes.attr('disabled', true);
} else {
$checkboxes.removeAttr('disabled');
}
}
</script> </script>
@stop @stop