More jquery and form fixes for users

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-04-03 17:08:21 -07:00
parent 790f9c2fc4
commit 2c5ddca695

View file

@ -112,7 +112,7 @@
type="text" type="text"
name="username" name="username"
id="username" id="username"
value="{{ Request::old('username', $user->username) }}" value="{{ old('username', $user->username) }}"
autocomplete="off" autocomplete="off"
maxlength="191" maxlength="191"
readonly readonly
@ -228,7 +228,7 @@
@else @else
<!-- everything is normal - as you were --> <!-- everything is normal - as you were -->
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('activated', '1', old('activated'), ['checked'=> 'checked', 'aria-label'=>'update_real_loc']) }} {{ Form::checkbox('activated', '1', old('activated'), ['id' => 'activated', 'checked'=> 'checked', 'aria-label'=>'update_real_loc']) }}
{{ trans('admin/users/general.activated_help_text') }} {{ trans('admin/users/general.activated_help_text') }}
</label> </label>
@endif @endif
@ -266,8 +266,10 @@
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label class="form-control form-control--disabled"> <label class="form-control form-control--disabled">
{{ Form::checkbox('email_user', '1', old('email_user'), ['id' => 'email_user_checkbox', 'disabled' => true, 'checked'=> 'checked', 'aria-label'=>'update_real_loc']) }}
Email this user their credentials? {{ Form::checkbox('email_user', '1', old('email_user'), ['id' => "email_user_checkbox", 'aria-label'=>'email_user']) }}
{{ trans('admin/users/general.email_user_creds_on_create') }}
</label> </label>
<p class="help-block"> {{ trans('admin/users/general.send_email_help') }}</p> <p class="help-block"> {{ trans('admin/users/general.send_email_help') }}</p>
@ -617,35 +619,48 @@
@section('moar_scripts') @section('moar_scripts')
<script nonce="{{ csrf_token() }}"> <script nonce="{{ csrf_token() }}">
$(document).ready(function() { $(document).ready(function() {
$('#email_user_checkbox').prop("disabled", true);
$('#activated').on('ifChecked', function(event){ // If the "user can login" check box is checked, show them the ability to email the user credentials
console.log('user activated is checked'); $("#activated").change(function() {
$("#email_user_row").show(); if (this.checked) {
}); $("#email_user_row").show();
} else {
$('#activated').on('ifUnchecked', function(event){ $("#email_user_row").hide();
$("#email_user_row").hide(); }
}); });
// Set some defaults
$('#email_user_checkbox').prop("disabled", true);
$('#email_user_checkbox').prop("checked", false);
$("#email_user_checkbox").removeAttr('checked');
// If the email address is longer than 5 characters, enable the "send email" checkbox
$('#email').on('keyup',function(){ $('#email').on('keyup',function(){
event.preventDefault(); //event.preventDefault();
@if (!config('app.lock_passwords')) @if (!config('app.lock_passwords'))
if(this.value.length > 5){
if (this.value.length > 5){
console.log('email field is ' + this.value.length + ' - enable the checkbox');
$('#email_user_checkbox').prop("disabled", false); $('#email_user_checkbox').prop("disabled", false);
$("#email_user_checkbox").parent().removeClass("form-control--disabled"); $("#email_user_checkbox").parent().removeClass("form-control--disabled");
} else { } else {
console.log('email field is ' + this.value.length + ' - DISABLE the checkbox');
$('#email_user_checkbox').prop("disabled", true); $('#email_user_checkbox').prop("disabled", true);
$('#email_user_checkbox').prop("checked", false);
$("#email_user_checkbox").parent().addClass("form-control--disabled");
} }
@endif @endif
}); });
// Check/Uncheck all radio buttons in the group // Check/Uncheck all radio buttons in the group
$('tr.header-row input:radio').on('ifClicked', function () { $('tr.header-row input:radio').change(function() {
value = $(this).attr('value'); value = $(this).attr('value');
area = $(this).data('checker-group'); area = $(this).data('checker-group');
$('.radiochecker-'+area+'[value='+value+']').iCheck('check'); $('.radiochecker-'+area+'[value='+value+']').iCheck('check');