From ca78b3ed7c1363b52d9f7c26305d27e5260cb61b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 23 Aug 2017 13:08:42 -0700 Subject: [PATCH] Fixes models on create asset --- resources/views/hardware/edit.blade.php | 23 +++++++++++-------- .../views/models/custom_fields_form.blade.php | 2 +- .../partials/forms/edit/supplier.blade.php | 2 +- resources/views/partials/modals.blade.php | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 774fe1d753..b994e32f10 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -31,9 +31,9 @@
@if (isset($selected_model)) - {{ Form::select('model_id', $model_list , $selected_model->id, array('class'=>'select2 model', 'style'=>'width:100%','id' =>'model_select_id')) }} + {{ Form::select('model_id', $model_list , $selected_model->id, array('class'=>'select2 model', 'style'=>'width:100%','id' => 'model_select_id', 'id' =>'model_select_id')) }} @else - {{ Form::select('model_id', $model_list , Input::old('model_id', $item->model_id), array('class'=>'select2 model', 'style'=>'width:100%','id' =>'model_select_id')) }} + {{ Form::select('model_id', $model_list , Input::old('model_id', $item->model_id), array('class'=>'select2 model', 'id' => 'model_select_id', 'style'=>'width:100%','id' =>'model_select_id')) }} @endif {!! $errors->first('model_id', ' :message') !!} @@ -86,9 +86,7 @@ {{ Form::select('assigned_asset', $assets_list , Input::old('assigned_asset', $item->assigned_type == 'App\Models\Asset' ? $item->assigned_to : 0), array('class'=>'select2', 'id'=>'assigned_asset', 'style'=>'width:100%')) }} {!! $errors->first('assigned_asset', ' :message') !!}
-
- New -
+ @@ -100,7 +98,7 @@ {!! $errors->first('assigned_location', ' :message') !!}
- New + New
@endif @@ -271,7 +269,7 @@ break; case 'statuslabel': - show_er("#modal-statuslabel_types"); + show_er("#modal-type"); break; case 'supplier': @@ -436,10 +434,16 @@ success: function (result) { var id = result.id; - var name = result.name || (result.first_name + " " + result.last_name); + var name = result.payload.name || (result.payload.first_name + " " + result.payload.last_name); + console.log(name); $('.modal-body input:visible').val(""); $('#createModal').modal('hide'); + + // "select" is the original drop-down menu that someone + // clicked 'add' on to add a new 'thing' + // this code adds the newly created object to that select var selector = document.getElementById(select); + //console.log(document.getElementById(select)); selector.options[selector.length] = new Option(name, id); selector.selectedIndex = selector.length - 1; $(selector).trigger("change"); @@ -447,7 +451,8 @@ }, error: function (result) { - msg = result.responseJSON.error.message || result.responseJSON.error; + // console.log('Error: ' + result.responseJSON.error.message ); + msg = result.responseJSON.messages || result.responseJSON.error; window.alert("Unable to add new " + model + " - error: " + msg); } diff --git a/resources/views/models/custom_fields_form.blade.php b/resources/views/models/custom_fields_form.blade.php index 6191ed4438..6ddbd3ffa1 100644 --- a/resources/views/models/custom_fields_form.blade.php +++ b/resources/views/models/custom_fields_form.blade.php @@ -1,4 +1,4 @@ -@if($model->fieldset) +@if (($model) && ($model->fieldset)) @foreach($model->fieldset->fields AS $field)
diff --git a/resources/views/partials/forms/edit/supplier.blade.php b/resources/views/partials/forms/edit/supplier.blade.php index 3b82bbcb13..8ef1c75c2b 100644 --- a/resources/views/partials/forms/edit/supplier.blade.php +++ b/resources/views/partials/forms/edit/supplier.blade.php @@ -2,7 +2,7 @@
- {{ Form::select('supplier_id', $supplier_list , Input::old('supplier_id', $item->supplier_id), ['class'=>'select2', 'style'=>'min-width:350px']) }} + {{ Form::select('supplier_id', $supplier_list , Input::old('supplier_id', $item->supplier_id), ['class'=>'select2', 'style'=>'min-width:350px', 'id' => 'supplier_select_id']) }} {!! $errors->first('supplier_id', ' :message') !!}
diff --git a/resources/views/partials/modals.blade.php b/resources/views/partials/modals.blade.php index 5a45917c65..c68eeea810 100644 --- a/resources/views/partials/modals.blade.php +++ b/resources/views/partials/modals.blade.php @@ -31,9 +31,9 @@
-