Add ranks from the subfleet edit page closes #160

This commit is contained in:
Nabeel Shahzad
2018-02-20 21:53:50 -06:00
parent 1c143f3b23
commit 14d04604cb
8 changed files with 165 additions and 18 deletions

View File

@@ -10,6 +10,12 @@
</div>
</div>
<div class="card border-blue-bottom">
<div class="content">
@include('admin.subfleets.ranks')
</div>
</div>
<div class="card border-blue-bottom">
<div class="content">
@include('admin.subfleets.fares')

View File

@@ -10,15 +10,14 @@
</div>
<br />
<table id="aircraft_fares"
class="table table-bordered table-hover dataTable"
role="grid" aria-describedby="aircraft_fares_info">
class="table table-hover dataTable">
<thead>
<tr>
<th>name</th>
<th>code</th>
<th>capacity (default)</th>
<th>price (default)</th>
<th>cost (default)</th>
<th style="text-align: center;">code</th>
<th style="text-align: center;">capacity (default)</th>
<th style="text-align: center;">price (default)</th>
<th style="text-align: center;">cost (default)</th>
<th></th>
</tr>
</thead>
@@ -27,12 +26,15 @@
<tr>
<td class="sorting_1">{!! $atf->name !!}</td>
<td style="text-align: center;">{!! $atf->code !!}</td>
<td><a href="#" data-pk="{!! $atf->id !!}" data-name="capacity">{!! $atf->pivot->capacity !!}</a>
<td style="text-align: center;">
<a href="#" data-pk="{!! $atf->id !!}" data-name="capacity">{!! $atf->pivot->capacity !!}</a>
<span class="small background-color-grey-light">({!! $atf->capacity !!})</span>
</td>
<td><a href="#" data-pk="{!! $atf->id !!}" data-name="price">{!! $atf->pivot->price !!}</a>
<td style="text-align: center;">
<a href="#" data-pk="{!! $atf->id !!}" data-name="price">{!! $atf->pivot->price !!}</a>
<span class="small background-color-grey-light">({!! $atf->price !!})</span></td>
<td><a href="#" data-pk="{!! $atf->id !!}" data-name="cost">{!! $atf->pivot->cost !!}</a>
<td style="text-align: center;">
<a href="#" data-pk="{!! $atf->id !!}" data-name="cost">{!! $atf->pivot->cost !!}</a>
<span class="small background-color-grey-light">({!! $atf->cost!!})</span></td>
<td style="text-align: right; width:3%;">
{!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/fares',

View File

@@ -1,9 +1,4 @@
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline:') !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
@@ -17,6 +12,12 @@
<p class="text-danger">{{ $errors->first('type') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline:') !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('fuel_type', 'Fuel Type:') !!}
{!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!}

View File

@@ -0,0 +1,58 @@
<div id="subfleet_ranks_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
<div class="header">
<h3>ranks</h3>
<p class="category">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
These ranks are allowed to fly aircraft in this subfleet
</p>
</div>
<br />
<table id="subfleet_ranks" class="table table-hover dataTable">
<thead>
<tr>
<th>name</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($subfleet->ranks as $rank)
<tr>
<td class="sorting_1">{!! $rank->name !!}</td>
<td style="text-align: right; width:3%;">
{!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/ranks',
'method' => 'delete',
'class' => 'modify_rank'])
!!}
{!! Form::hidden('rank_id', $rank->id) !!}
{!! Form::button('<i class="fa fa-times"></i>',
['type' => 'submit',
'class' => 'btn btn-sm btn-danger btn-icon']) !!}
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
<hr />
<div class="row">
<div class="col-xs-12">
<div class="text-right">
{!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/ranks',
'method' => 'post',
'class' => 'modify_rank form-inline'])
!!}
{!! Form::select('rank_id', $avail_ranks, null, [
'placeholder' => 'Select Rank',
'class' => 'ac-fare-dropdown form-control input-lg select2',
])
!!}
{!! Form::button('<i class="glyphicon glyphicon-plus"></i> add',
['type' => 'submit',
'class' => 'btn btn-success btn-s']) !!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
{{--</div></div>--}}

View File

@@ -29,6 +29,12 @@ $(document).ready(function() {
setEditable();
});
$(document).on('submit', 'form.modify_rank', function (event) {
event.preventDefault();
console.log(event);
$.pjax.submit(event, '#subfleet_ranks_wrapper', {push: false});
});
$(document).on('pjax:complete', function() {
$(".select2").select2();
setEditable();