Display message and update checkbox depending on EULA status

This commit is contained in:
Marcus Moore 2023-07-11 16:12:43 -07:00
parent 2bc4235368
commit af681d8190
No known key found for this signature in database

View file

@ -73,10 +73,12 @@
{{ Form::checkbox('checkin_email', '1', old('checkin_email', $item->checkin_email), ['aria-label'=>'checkin_email']) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
<span id="email_will_be_sent_message" class="help-block">
An email will be sent to the user because a EULA is set for this category.
</span>
</div>
</div>
@include ('partials.forms.edit.image-upload', ['image_path' => app('categories_upload_path')])
@ -109,3 +111,31 @@
@stop
@section('moar_scripts')
<script type="text/javascript">
$(document).ready(function() {
let textarea = $('textarea[name="eula_text"]');
let shouldSendEmail = $('input[name="checkin_email"]')
let message = $('#email_will_be_sent_message');
function handleEulaChange() {
if (textarea.val().trim() !== '') {
shouldSendEmail.prop('checked', true);
shouldSendEmail.prop('disabled', true);
message.show();
} else {
shouldSendEmail.prop('checked', false);
shouldSendEmail.prop('disabled', false);
message.hide();
}
}
textarea.on('change keyup', function() {
handleEulaChange();
});
handleEulaChange();
});
</script>
@stop