From f02ff62a08d844881a6fe8d76221ef90b31d7a05 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Nov 2023 18:15:18 -0800 Subject: [PATCH 01/12] Install jquery-validation package --- package-lock.json | 9 +++++++++ package.json | 1 + resources/views/layouts/default.blade.php | 7 +------ webpack.mix.js | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index fccda0022..f46366d03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "jquery-slimscroll": "^1.3.8", "jquery-ui": "^1.13.2", "jquery-ui-bundle": "^1.12.1", + "jquery-validation": "^1.20.0", "jquery.iframe-transport": "^1.0.0", "jspdf-autotable": "^3.5.30", "less": "^4.2.0", @@ -7788,6 +7789,14 @@ "resolved": "https://registry.npmjs.org/jquery-ui-bundle/-/jquery-ui-bundle-1.12.1.tgz", "integrity": "sha512-GHaOlAemudaYqrBzaU0XutgC/vBwcvd+SBQ+TtUTA+dLx4PiVQAfTm3ABrh+JzhV6PZBOk8AIhsC9l+XggpldQ==" }, + "node_modules/jquery-validation": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/jquery-validation/-/jquery-validation-1.20.0.tgz", + "integrity": "sha512-c8tg4ltIIP6L7l0bZ79sRzOJYquyjS48kQZ6iv8MJ2r0OYztxtkWYKTReZyU2/zVFYiINB29i0Z/IRNNuJQN1g==", + "peerDependencies": { + "jquery": "^1.7 || ^2.0 || ^3.1" + } + }, "node_modules/jquery.iframe-transport": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/jquery.iframe-transport/-/jquery.iframe-transport-1.0.0.tgz", diff --git a/package.json b/package.json index eb9641160..8ddf73dae 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "jquery-slimscroll": "^1.3.8", "jquery-ui": "^1.13.2", "jquery-ui-bundle": "^1.12.1", + "jquery-validation": "^1.20.0", "jquery.iframe-transport": "^1.0.0", "jspdf-autotable": "^3.5.30", "less": "^4.2.0", diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 3fe1b3845..74da440b1 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -965,12 +965,7 @@ $('.js-copy-link').tooltip('hide').attr('data-original-title', '{{ trans('general.copied') }}').tooltip('show'); }); - // ignore: 'input[type=hidden]' is required here to validate the select2 lists - $.validate({ - form: '#create-form', - modules: 'date, toggleDisabled', - disabledFormFilter: '#create-form', - showErrorDialogs: true, + $('#create-form').validate({ ignore: 'input[type=hidden]' }); diff --git a/webpack.mix.js b/webpack.mix.js index 9b4fbdd12..4f931be8b 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -154,7 +154,7 @@ mix.combine( "./resources/assets/js/extensions/pGenerator.jquery.js", "./node_modules/chart.js/dist/Chart.js", "./resources/assets/js/signature_pad.js", - //"./node_modules/jquery-form-validator/form-validator/jquery.form-validator.js", //problem? + "./node_modules/jquery-validation/dist/jquery.validate.js", "./node_modules/list.js/dist/list.js", "./node_modules/clipboard/dist/clipboard.js", ], From 0d3589ca245acb913df6296f6784cb9846155dc0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Nov 2023 18:17:39 -0800 Subject: [PATCH 02/12] Update create asset page to use new validation library --- resources/views/hardware/edit.blade.php | 8 ++++---- resources/views/partials/forms/edit/status.blade.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index aff215ae2..ef606e127 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -26,14 +26,14 @@
- + {!! $errors->first('asset_tags', ' :message') !!} {!! $errors->first('asset_tag', ' :message') !!}
@else
- + {!! $errors->first('asset_tags', ' :message') !!} {!! $errors->first('asset_tag', ' :message') !!}
@@ -295,7 +295,7 @@ box_html += ''; box_html += '
'; box_html += '
'; - box_html += ''; + box_html += ''; box_html += '
'; box_html += '
'; box_html += ''; @@ -379,4 +379,4 @@ -@stop \ No newline at end of file +@stop diff --git a/resources/views/partials/forms/edit/status.blade.php b/resources/views/partials/forms/edit/status.blade.php index fe82ebf68..0577e1220 100644 --- a/resources/views/partials/forms/edit/status.blade.php +++ b/resources/views/partials/forms/edit/status.blade.php @@ -2,7 +2,7 @@
- {{ Form::select('status_id', $statuslabel_list , old('status_id', $item->status_id), array('class'=>'select2 status_id', 'style'=>'width:100%','id'=>'status_select_id', 'aria-label'=>'status_id', 'data-validation' => "required")) }} + {{ Form::select('status_id', $statuslabel_list , old('status_id', $item->status_id), array('class'=>'select2 status_id', 'style'=>'width:100%','id'=>'status_select_id', 'aria-label'=>'status_id', 'data-validation' => "required", 'required' => 'required')) }} {!! $errors->first('status_id', '') !!}
From 7098ab650955b47a7c9a9cc229adea115fd5e4be Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Nov 2023 18:54:51 -0800 Subject: [PATCH 03/12] Match styling of existing error messages --- resources/views/layouts/default.blade.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 74da440b1..c16f93d3f 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -966,7 +966,16 @@ }); $('#create-form').validate({ - ignore: 'input[type=hidden]' + ignore: 'input[type=hidden]', + errorClass: 'help-block form-error', + errorElement: 'span', + errorPlacement: function(error, element) { + element.parents('.required').append(error); + }, + highlight: function(inputElement) { + $(inputElement).parent().addClass('has-error'); + $(inputElement).closest('.help-block').remove(); + }, }); From 1a26ea09113d3d941f491cc701cb73b59c8e2154 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Nov 2023 19:18:04 -0800 Subject: [PATCH 04/12] Update a couple more fields for new validation --- resources/views/depreciations/edit.blade.php | 2 +- resources/views/partials/forms/edit/name.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/depreciations/edit.blade.php b/resources/views/depreciations/edit.blade.php index 3d10a221d..a3f5b339b 100755 --- a/resources/views/depreciations/edit.blade.php +++ b/resources/views/depreciations/edit.blade.php @@ -17,7 +17,7 @@
- + {!! $errors->first('months', '') !!}
diff --git a/resources/views/partials/forms/edit/name.blade.php b/resources/views/partials/forms/edit/name.blade.php index 38205f1ac..f4d29e606 100644 --- a/resources/views/partials/forms/edit/name.blade.php +++ b/resources/views/partials/forms/edit/name.blade.php @@ -2,7 +2,7 @@
- + {!! $errors->first('name', '') !!}
From fe0f9743d340a71bdf3dd1dd0c1bb2bd64d7ed5b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 14 Nov 2023 12:07:37 -0800 Subject: [PATCH 05/12] Update additional partials for validation --- resources/views/partials/forms/edit/category-select.blade.php | 2 +- resources/views/partials/forms/edit/location-select.blade.php | 2 +- .../views/partials/forms/edit/manufacturer-select.blade.php | 2 +- resources/views/partials/forms/edit/model-select.blade.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/partials/forms/edit/category-select.blade.php b/resources/views/partials/forms/edit/category-select.blade.php index 684b8d76d..f555c6240 100644 --- a/resources/views/partials/forms/edit/category-select.blade.php +++ b/resources/views/partials/forms/edit/category-select.blade.php @@ -4,7 +4,7 @@ {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
- @if ($category_id = old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))