#48 add custom fields/values to flights

This commit is contained in:
Nabeel Shahzad
2017-07-11 17:44:12 -05:00
parent 35133fe0e6
commit 5ffd152a43
8 changed files with 189 additions and 47 deletions

View File

@@ -2,7 +2,7 @@
@section('content')
<section class="content-header">
<h1>Edit {!! $flight->airline->name !!}{!! $flight->number !!}</h1>
<h1>Edit {!! $flight->airline->code !!}{!! $flight->flight_number !!}</h1>
</section>
<div class="content">
@include('adminlte-templates::common.errors')
@@ -17,6 +17,20 @@
</div>
</div>
</div>
<div class="box box-primary">
<div class="box-body">
<div class="row">
<div class="col-xs-12">
<h3>custom fields</h3>
<div class="box-body">
@include('admin.flights.flight_fields')
</div>
</div>
</div>
</div>
</div>
<div class="box box-primary">
<div class="box-body">
<div class="row">
@@ -33,17 +47,33 @@
@endsection
@section('scripts')
<script>
$(document).ready(function () {
$(".select2_dropdown").select2();
$(document).ready(function () {
$(document).on('submit', 'form.pjax_form', function (event) {
event.preventDefault();
$.pjax.submit(event, '#subfleet_flight_wrapper', {push: false});
});
$(document).on('pjax:complete', function() {
$(".select2_dropdown").select2();
});
$('#flight_fields_wrapper a.inline').editable({
type: 'text',
mode: 'inline',
emptytext: '0',
url: '/admin/flights/{!! $flight->id !!}/fields',
ajaxOptions: {'type': 'put'},
params: function(params) {
return {
field_id: params.pk,
name: params.name,
value: params.value
}
}
});
$(".select2_dropdown").select2();
$(document).on('submit', 'form.pjax_form', function (event) {
event.preventDefault();
$.pjax.submit(event, '#flight_fields_wrapper', {push: false});
});
$(document).on('pjax:complete', function() {
$(".select2_dropdown").select2();
});
});
</script>
@endsection

View File

@@ -1,15 +1,21 @@
<!-- Airline Id Field -->
<div class="form-group col-sm-6">
<div class="form-group col-sm-5">
{!! Form::label('airline_id', 'Airline:') !!}
{!! Form::text('airline_id', null, ['class' => 'form-control']) !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
</div>
<!-- Flight Number Field -->
<div class="form-group col-sm-6">
<div class="form-group col-sm-5">
{!! Form::label('flight_number', 'Flight Number:') !!}
{!! Form::text('flight_number', null, ['class' => 'form-control']) !!}
</div>
<!-- Active Field -->
<div class="form-group col-sm-2">
{!! Form::label('active', 'Active:') !!}
{!! Form::checkbox('active', $flight->active, ['class' => 'form-control']) !!}
</div>
<!-- Route Code Field -->
<div class="form-group col-sm-6">
{!! Form::label('route_code', 'Route Code:') !!}
@@ -22,22 +28,42 @@
{!! Form::text('route_leg', null, ['class' => 'form-control']) !!}
</div>
<!--
SAME ROW
-->
<!-- Dpt Airport Id Field -->
<div class="form-group col-sm-6">
{!! Form::label('dpt_airport_id', 'Dpt Airport Id:') !!}
{!! Form::text('dpt_airport_id', null, ['class' => 'form-control']) !!}
<div class="form-group col-sm-4">
{!! Form::label('dpt_airport_id', 'Departure Airport:') !!}
{!! Form::select('dpt_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
</div>
<!-- Arr Airport Id Field -->
<div class="form-group col-sm-6">
{!! Form::label('arr_airport_id', 'Arr Airport Id:') !!}
{!! Form::text('arr_airport_id', null, ['class' => 'form-control']) !!}
<div class="form-group col-sm-4">
{!! Form::label('arr_airport_id', 'Arrival Airport:') !!}
{!! Form::select('arr_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
</div>
<!-- Alt Airport Id Field -->
<div class="form-group col-sm-4">
{!! Form::label('alt_airport_id', 'Alt Airport:') !!}
{!! Form::select('alt_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
</div>
<!--
END SAME ROW
-->
<!-- Dpt Time Field -->
<div class="form-group col-sm-6">
{!! Form::label('alt_airport_id', 'Alt Airport Id:') !!}
{!! Form::text('alt_airport_id', null, ['class' => 'form-control']) !!}
{!! Form::label('dpt_time', 'Departure Time:') !!}
{!! Form::text('dpt_time', null, ['class' => 'form-control']) !!}
</div>
<!-- Arr Time Field -->
<div class="form-group col-sm-6">
{!! Form::label('arr_time', 'Arrival Time:') !!}
{!! Form::text('arr_time', null, ['class' => 'form-control']) !!}
</div>
<!-- Route Field -->
@@ -46,30 +72,12 @@
{!! Form::text('route', null, ['class' => 'form-control']) !!}
</div>
<!-- Dpt Time Field -->
<div class="form-group col-sm-6">
{!! Form::label('dpt_time', 'Dpt Time:') !!}
{!! Form::text('dpt_time', null, ['class' => 'form-control']) !!}
</div>
<!-- Arr Time Field -->
<div class="form-group col-sm-6">
{!! Form::label('arr_time', 'Arr Time:') !!}
{!! Form::text('arr_time', null, ['class' => 'form-control']) !!}
</div>
<!-- Notes Field -->
<div class="form-group col-sm-6">
{!! Form::label('notes', 'Notes:') !!}
{!! Form::text('notes', null, ['class' => 'form-control']) !!}
</div>
<!-- Active Field -->
<div class="form-group col-sm-6">
{!! Form::label('active', 'Active:') !!}
{!! Form::text('active', null, ['class' => 'form-control']) !!}
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}

View File

@@ -0,0 +1,56 @@
<div id="flight_fields_wrapper">
<table class="table table-responsive" id="flight-fields-table">
<thead>
<th>Name</th>
<th>Value</th>
<th style="text-align: center;">Actions</th>
</thead>
<tbody>
@foreach($flight->fields as $field)
<tr>
<td>{!! $field->name !!}</td>
<td>
<a class="inline" href="#" data-pk="{!! $field->id !!}" data-name="{!! $field->name !!}">{!! $field->value !!}</a>
</td>
<td style="width: 10%; text-align: center;" class="form-inline">
{!! Form::open(['url' => '/admin/flights/'.$flight->id.'/fields',
'method' => 'delete',
'class' => 'pjax_form flight_fields'
]) !!}
{!! Form::hidden('field_id', $field->id) !!}
<div class='btn-group'>
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>',
['type' => 'submit',
'class' => 'btn btn-danger btn-xs'])
!!}
</div>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
<hr/>
<div class="row pull-right">
{!! Form::open([
'url' => '/admin/flights/'.$flight->id.'/fields',
'method' => 'post',
'class' => 'pjax_form form-inline'
])
!!}
<div class="form-group col-xs-12 form-inline">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
&nbsp;&nbsp;
{!! Form::label('value', 'Value:') !!}
{!! Form::text('value', null, ['class' => 'form-control']) !!}
&nbsp;&nbsp;
{!! Form::button('<i class="glyphicon glyphicon-plus"></i> add',
['type' => 'submit',
'class' => 'btn btn-success btn-s']) !!}
</div>
{!! Form::close() !!}
</div>
</div>

View File

@@ -1,6 +1,6 @@
<!-- Airline Id Field -->
<div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline Id:') !!}
{!! Form::label('airline_id', 'Airline:') !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
</div>