Airport lookup from vaCentral API; changes to Airports tables

This commit is contained in:
Nabeel Shahzad
2017-12-07 17:22:15 -06:00
parent ec8b2e8242
commit ddb8a6f5e9
19 changed files with 429 additions and 65 deletions

View File

@@ -1,12 +1,13 @@
@extends('admin.app')
@section('title', "Add Airport")
@section('title', 'Add Airport')
@section('content')
<div class="card border-blue-bottom">
<div class="content">
@include('adminlte-templates::common.errors')
{!! Form::open(['route' => 'admin.airports.store']) !!}
{!! Form::open(['route' => 'admin.airports.store', 'id' => 'airportForm']) !!}
@include('admin.airports.fields')
{!! Form::close() !!}
</div>
</div>
@endsection
@include('admin.airports.script')

View File

@@ -4,9 +4,10 @@
<div class="card border-blue-bottom">
<div class="content">
@include('adminlte-templates::common.errors')
{!! Form::model($airport, ['route' => ['admin.airports.update', $airport->id], 'method' => 'patch']) !!}
{!! Form::model($airport, ['route' => ['admin.airports.update', $airport->id], 'method' => 'patch', 'id' => 'airportForm']) !!}
@include('admin.airports.fields')
{!! Form::close() !!}
</div>
</div>
@endsection
@include('admin.airports.script')

View File

@@ -1,40 +1,66 @@
<div class="row">
<!-- Icao Field -->
<div class="form-group col-sm-6">
{!! Form::label('icao', 'ICAO:') !!}
{!! Form::text('icao', null, ['class' => 'form-control']) !!}
</div>
<div class="col-lg-12">
<!-- Icao Field -->
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('icao', 'ICAO:') !!}
<a href="#" class="airport_data_lookup">Lookup</a>
{!! Form::text('icao', null, [
'id' => 'airport_icao', 'class' => 'form-control',
'rv-value' => 'airport.icao'
]) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('iata', 'IATA:') !!}
{!! Form::text('iata', null, ['class' => 'form-control', 'rv-value' => 'airport.iata']) !!}
</div>
</div>
<div class="form-group col-sm-6">
{!! Form::label('location', 'Location:') !!}
{!! Form::text('location', null, ['class' => 'form-control']) !!}
</div>
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control', 'rv-value' => 'airport.name']) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('lat', 'Latitude:') !!}
{!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001']) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('location', 'Location:') !!}
{!! Form::text('location', null, ['class' => 'form-control', 'rv-value' => 'airport.city']) !!}
</div>
</div>
<div class="form-group col-sm-6">
{!! Form::label('lon', 'Longitude:') !!}
{!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001']) !!}
</div>
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('country', 'Country:') !!}
{!! Form::text('country', null, ['class' => 'form-control', 'rv-value' => 'airport.country']) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('timezone', 'Timezone:') !!}
{!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('tz', 'Timezone:') !!}
{!! Form::select('tz', $timezones, null, ['class' => 'select2']); !!}
</div>
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.airports.index') !!}" class="btn btn-default">Cancel</a>
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('lat', 'Latitude:') !!}
{!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lat']) !!}
</div>
<div class="form-group col-sm-6">
{!! Form::label('lon', 'Longitude:') !!}
{!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lon']) !!}
</div>
</div>
<div class="row">
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.airports.index') !!}" class="btn btn-default">Cancel</a>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,6 +1,8 @@
@section('scripts')
<script>
$(document).ready(function() {
$('#airports-table a.inline').editable({
type: 'text',
mode: 'inline',
@@ -16,6 +18,29 @@ $(document).ready(function() {
}
}
});
$('a.airport_data_lookup').click(function(e) {
e.preventDefault();
var icao = $("input#airport_icao").val();
if(icao === '') {
return;
}
phpvms_vacentral_airport_lookup(icao, function(data) {
console.log('lookup data', data);
_.forEach(data, function(value, key) {
if(key === 'city') {
key = 'location';
}
$("#" + key).val(value);
if(key === 'tz') {
$("#tz").trigger('change');
}
});
});
});
});
</script>
@endsection