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