From dafe353050db84774b9ef482beafb88d190baa52 Mon Sep 17 00:00:00 2001 From: Achmad Fienan Rahardianto Date: Sat, 23 Apr 2022 14:41:38 +0700 Subject: [PATCH 1/2] Implements #8155 to improve the workflow during asset creation - adding 2 options to hide optional information --- resources/lang/en/admin/hardware/form.php | 2 + resources/views/hardware/edit.blade.php | 165 ++++++++++++++-------- 2 files changed, 110 insertions(+), 57 deletions(-) diff --git a/resources/lang/en/admin/hardware/form.php b/resources/lang/en/admin/hardware/form.php index 0c1a3167be..b2d7bab0fc 100644 --- a/resources/lang/en/admin/hardware/form.php +++ b/resources/lang/en/admin/hardware/form.php @@ -46,4 +46,6 @@ return [ 'asset_not_deployable' => 'That asset status is not deployable. This asset cannot be checked out.', 'asset_deployable' => 'That status is deployable. This asset can be checked out.', 'processing_spinner' => 'Processing...', + 'optional_infos' => 'Optional Information', + 'order_details' => 'Order Related Information' ]; diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 20e93f0677..ac912e1909 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -15,7 +15,6 @@ @include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id']) -
@@ -41,77 +40,103 @@
@endif - @include ('partials.forms.edit.serial', ['fieldname'=> 'serials[1]', 'translated_serial' => trans('admin/hardware/form.serial')]) +
@include ('partials.forms.edit.model-select', ['translated_name' => trans('admin/hardware/form.model'), 'fieldname' => 'model_id', 'field_req' => true]) + @include ('partials.forms.edit.serial', ['fieldname'=> 'serials[1]', 'translated_serial' => trans('admin/hardware/form.serial')]) -
- - @if ($item->model && $item->model->fieldset) - model; ?> - @endif - @if (Request::old('model_id')) - - @elseif (isset($selected_model)) - - @endif - @if (isset($model) && $model) - @include("models/custom_fields_form",["model" => $model]) - @endif -
+ @include ('partials.forms.edit.status', [ 'required' => 'true']) + @if (!$item->id) + @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true', 'style' => 'display:none;']) + @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user', 'style' => 'display:none;', 'required' => 'false']) + @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset', 'style' => 'display:none;', 'required' => 'false']) + @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required' => 'false']) + @elseif (($item->assignedTo) && ($item->deleted_at=='')) + + @include ('partials.forms.edit.datepicker', ['translated_name' => trans('admin/hardware/form.expected_checkin'),'fieldname' => 'expected_checkin']) + @endif - @include ('partials.forms.edit.status', [ 'required' => 'true']) - @if (!$item->id) - @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true', 'style' => 'display:none;']) - @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user', 'style' => 'display:none;', 'required' => 'false']) - @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset', 'style' => 'display:none;', 'required' => 'false']) - @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required' => 'false']) - @elseif (($item->assignedTo) && ($item->deleted_at=='')) - - @include ('partials.forms.edit.datepicker', ['translated_name' => trans('admin/hardware/form.expected_checkin'),'fieldname' => 'expected_checkin']) - @endif + @include ('partials.forms.edit.notes') + @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.default_location'), 'fieldname' => 'rtd_location_id']) + @include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/hardware/general.requestable')]) - @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']) - @include ('partials.forms.edit.order_number') - id && $item->location) { - $currency_type = $item->location->currency; - } - ?> - @include ('partials.forms.edit.purchase_cost', ['currency_type' => $currency_type]) - @include ('partials.forms.edit.warranty') - @include ('partials.forms.edit.notes') + + @if ($item->image) +
+ +
+ +
+ +
+
+
+ @endif - @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.default_location'), 'fieldname' => 'rtd_location_id']) + @include ('partials.forms.edit.image-upload') +
+ + @if ($item->model && $item->model->fieldset) + model; ?> + @endif + @if (Request::old('model_id')) + + @elseif (isset($selected_model)) + + @endif + @if (isset($model) && $model) + @include("models/custom_fields_form",["model" => $model]) + @endif +
- @include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/hardware/general.requestable')]) +
+ +
+ + +
+ +
+ @include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')]) + @include ('partials.forms.edit.warranty') +
+
- - @if ($item->image) -
- -
- -
- -
-
-
- @endif +
+ +
+ + +
-@include ('partials.forms.edit.image-upload') +
+ @include ('partials.forms.edit.order_number') + @include ('partials.forms.edit.purchase_date') + @include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id']) + + id && $item->location) { + $currency_type = $item->location->currency; + } + ?> + @include ('partials.forms.edit.purchase_cost', ['currency_type' => $currency_type]) + +
+
@stop @@ -278,6 +303,32 @@ }) }); + $( document ).ready(function() { + checkOrderDetailOption(); + checkOptionalOption(); + }); + $('#order_info').change(function(){ + checkOrderDetailOption(); + }); + + $('#optional_info').change(function(){ + checkOptionalOption(); + }); + + function checkOptionalOption(){ + if ($("#optional_info").prop('checked')==true) { + $('#optional_details').fadeIn('slow'); + } else { + $('#optional_details').fadeOut('slow'); + } + } + function checkOrderDetailOption(){ + if ($("#order_info").prop('checked')==true) { + $('#order_details').fadeIn('slow'); + } else { + $('#order_details').fadeOut('slow'); + } + } @stop From fe65de1207205d024a8df8185796bd4772fdb47b Mon Sep 17 00:00:00 2001 From: Achmad Fienan Rahardianto Date: Wed, 1 Jun 2022 11:54:05 +0700 Subject: [PATCH 2/2] implements cookie to maintain display preference --- .../Controllers/Assets/AssetsController.php | 21 +++++++- resources/views/hardware/edit.blade.php | 53 +++++++++++-------- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index c5063eb598..ed9f017704 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -20,6 +20,7 @@ use Gate; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Cookie; use Input; use Intervention\Image\Facades\Image; use League\Csv\Reader; @@ -201,18 +202,36 @@ class AssetsController extends Controller } $success = true; + + // $cookie = Cookie::queue(Cookie::make('optional_info', $_POST['options'],$minutes)); + // $data = $request->session()->all(); + + // dd($_POST['options']); + } } if ($success) { // Redirect to the asset listing page + $minutes = 518400; + // dd( $_POST['options']); + // Cookie::queue(Cookie::make('optional_info', json_decode($_POST['options']), $minutes)); return redirect()->route('hardware.index') - ->with('success', trans('admin/hardware/message.create.success')); + ->with('success', trans('admin/hardware/message.create.success')) + ->withCookie(cookie('optional_info',json_encode($_POST['options']),$minutes,null,null,null,false)); + + } return redirect()->back()->withInput()->withErrors($asset->getErrors()); } + public function getOptionCookie(Request $request){ + $value = $request->cookie('optional_info'); + echo $value; + return $value; + } + /** * Returns a view that presents a form to edit an existing asset. * diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index ac912e1909..4cc7f5cddf 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -10,15 +10,16 @@ {{-- Page content --}} - @section('inputFields') @include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id']) + +
- + @if ($item->id)
@@ -101,13 +102,14 @@
- + + >
-
+ @@ -116,13 +118,13 @@
- + >
-
+
@include ('partials.forms.edit.order_number') @include ('partials.forms.edit.purchase_date') @include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id']) @@ -137,7 +139,7 @@
- + @stop @section('moar_scripts') @@ -146,7 +148,6 @@ @stop