From accafbf1eb5cf1588f49bb6736a4cc5840957c5c Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 4 Oct 2018 19:28:56 -0700 Subject: [PATCH] Added basic JS to edit blade --- resources/views/hardware/edit.blade.php | 59 ++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 708d296ea..d423968fa 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -16,15 +16,28 @@
-
+ + @if ($item->id) - +
+ +
@else - + +
+ +
+
+ +
@endif {!! $errors->first('asset_tag', ' :message') !!} -
+ @include ('partials.forms.edit.serial', ['translated_serial' => trans('admin/hardware/form.serial')]) + +
+
+ @include ('partials.forms.edit.model-select', ['translated_name' => trans('admin/hardware/form.model'), 'fieldname' => 'model_id', 'required' => 'true']) @@ -56,7 +69,7 @@ @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required' => 'false']) @endif - @include ('partials.forms.edit.serial', ['translated_serial' => trans('admin/hardware/form.serial')]) + @include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')]) @include ('partials.forms.edit.purchase_date') @include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id']) @@ -187,5 +200,41 @@ }); + // Add another asset tag + serial combination if the plus sign is clicked + $(document).ready(function() { + var max_fields = 10; //maximum input boxes allowed + var wrapper = $(".input_fields_wrap"); //Fields wrapper + var add_button = $(".add_field_button"); //Add button ID + var box_html = ''; + + var x = 1; //initial text box count + $(add_button).click(function(e){ //on add input button click + e.preventDefault(); + if(x < max_fields){ //max input box allowed + x++; //text box increment + + box_html += '
'; + box_html += '
'; + box_html += ''; + box_html += '
'; + box_html += ''; + box_html += '
'; + box_html += '
'; + box_html += ''; + box_html += '
'; + box_html += '
'; + box_html += ''; + box_html += '
'; + box_html += '
'; + $(wrapper).append(box_html); + } + }); + + $(wrapper).on("click",".remove_field", function(e){ //user click on remove text + e.preventDefault(); $(this).parent('div').parent('div').remove(); x--; + }) + }); + + @stop