accept/reject pireps in admin; cleanup and refactoring
This commit is contained in:
@@ -123,12 +123,29 @@
|
||||
<script src="/vendor/select2/dist/js/select2.js"></script>
|
||||
<script src="/vendor/pjax/jquery.pjax.js"></script>
|
||||
<script src="/vendor/icheck/icheck.js"></script>
|
||||
<script src="/vendor/rivets/dist/rivets.bundled.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
|
||||
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
|
||||
|
||||
<script src="/js/admin/admin.js"></script>
|
||||
|
||||
<script>
|
||||
rivets.configure({
|
||||
prefix: 'rv',
|
||||
preloadData: true,
|
||||
rootInterface: '.',
|
||||
templateDelimiters: ['{', '}'],
|
||||
iterationAlias: function (modelName) {
|
||||
return '%' + modelName + '%';
|
||||
},
|
||||
// Augment the event handler of the on-* binder
|
||||
handler: function (target, event, binding) {
|
||||
this.call(target, event, binding.view.models)
|
||||
},
|
||||
executeFunctions: false
|
||||
|
||||
});
|
||||
|
||||
var getStorage = function(key) {
|
||||
var st = window.localStorage.getItem(key);
|
||||
console.log('storage: ', key, st);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
@extends('admin.app')
|
||||
|
||||
@section('title', 'Pilot Reports')
|
||||
|
||||
@section('actions')
|
||||
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>View All</a></li>
|
||||
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>Pending</a></li>
|
||||
@endsection
|
||||
@section('content')
|
||||
@include('admin.pireps.table')
|
||||
|
||||
@@ -11,4 +14,4 @@
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('admin.pireps.script')
|
||||
|
||||
94
resources/views/admin/pireps/pirep_card.blade.php
Normal file
94
resources/views/admin/pireps/pirep_card.blade.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<div id="pirep_{!! $pirep->id !!}_container">
|
||||
<div class="card border-blue-bottom pirep_card_container">
|
||||
<div class="card-block" style="min-height: 0px">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 text-center">
|
||||
<h5>
|
||||
<a class="text-c"
|
||||
href="{!! route('admin.pireps.show', [$pirep->id]) !!}">
|
||||
{!! $pirep->airline->code !!}
|
||||
@if($pirep->flight_id)
|
||||
{!! $pirep->flight->flight_number !!}
|
||||
@else
|
||||
{!! $pirep->flight_number !!}
|
||||
@endif
|
||||
</a>
|
||||
</h5>
|
||||
<div>
|
||||
@if($pirep->status == config('enums.pirep_status.PENDING'))
|
||||
<div class="badge badge-warning">Pending</div>
|
||||
@elseif($pirep->status == config('enums.pirep_status.ACCEPTED'))
|
||||
<div class="badge badge-success">Accepted</div>
|
||||
@else
|
||||
<div class="badge badge-danger">Rejected</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div>
|
||||
<span class="description">DEP </span>
|
||||
{!! $pirep->dpt_airport->icao !!}
|
||||
<span class="description">ARR </span>
|
||||
{!! $pirep->arr_airport->icao !!}
|
||||
</div>
|
||||
<div><span class="description">Flight Time </span>
|
||||
{!! Utils::secondsToTime($pirep->flight_time) !!}
|
||||
</div>
|
||||
<div><span class="description">Aircraft </span>
|
||||
{!! $pirep->aircraft->registration !!}
|
||||
({!! $pirep->aircraft->name !!})
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">Flight Level </span>
|
||||
{!! $pirep->level !!}
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">File Date </span>
|
||||
{!! $pirep->created_at !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 ">
|
||||
<table class="pull-right">
|
||||
<tr><td>
|
||||
@if($pirep->status == config('enums.pirep_status.PENDING')
|
||||
|| $pirep->status == config('enums.pirep_status.REJECTED'))
|
||||
{!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/status', 'method' => 'post',
|
||||
'name' => 'accept_'.$pirep->id,
|
||||
'id' => $pirep->id.'_accept',
|
||||
'pirep_id' => $pirep->id,
|
||||
'new_status' => config('enums.pirep_status.ACCEPTED'),
|
||||
'class' => 'pirep_submit_status']) !!}
|
||||
{!! Form::button('Accept', ['type' => 'submit', 'class' => 'btn btn-info']) !!}
|
||||
{!! Form::close() !!}
|
||||
@endif
|
||||
</td><td> </td><td>
|
||||
@if($pirep->status == config('enums.pirep_status.PENDING')
|
||||
|| $pirep->status == config('enums.pirep_status.ACCEPTED'))
|
||||
{!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/status', 'method' => 'post',
|
||||
'name' => 'reject_'.$pirep->id,
|
||||
'id' => $pirep->id.'_reject',
|
||||
'pirep_id' => $pirep->id,
|
||||
'new_status' => config('enums.pirep_status.REJECTED'),
|
||||
'class' => 'pirep_submit_status']) !!}
|
||||
{!! Form::button('Reject', ['type' => 'submit', 'class' => 'btn btn-danger']) !!}
|
||||
{!! Form::close() !!}
|
||||
@endif
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
36
resources/views/admin/pireps/script.blade.php
Normal file
36
resources/views/admin/pireps/script.blade.php
Normal file
@@ -0,0 +1,36 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
function changeStatus(values) {
|
||||
var destContainer = '#pirep_' + values.pirep_id + '_container';
|
||||
$.ajax({
|
||||
url: '/admin/pireps/' + values.pirep_id + '/status',
|
||||
data: values,
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
// console.log(data);
|
||||
$(destContainer).replaceWith(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//$(document).ready(function() {
|
||||
$(document).on('submit', 'form.pirep_submit_status', function (event) {
|
||||
console.log(event);
|
||||
|
||||
event.preventDefault();
|
||||
var values = {
|
||||
pirep_id: $(this).attr('pirep_id'),
|
||||
new_status: $(this).attr('new_status')
|
||||
};
|
||||
|
||||
console.log(values);
|
||||
console.log('Changing PIREP ' + values.pirep_id + ' to state ' + values.new_status);
|
||||
|
||||
//var destContainer = '#pirep_' + pirep_id + '_container';
|
||||
//$.pjax.submit(event, destContainer, { push: false, maxCacheLength: 0 });
|
||||
|
||||
changeStatus(values);
|
||||
});
|
||||
//});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -1,116 +1 @@
|
||||
@foreach($pireps as $pirep)
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="card-block" style="min-height: 0px">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 text-center">
|
||||
<h5>
|
||||
<a class="text-c"
|
||||
href="{!! route('admin.pireps.show', [$pirep->id]) !!}">
|
||||
{!! $pirep->airline->code !!}
|
||||
@if($pirep->flight_id)
|
||||
{!! $pirep->flight->flight_number !!}
|
||||
@else
|
||||
{!! $pirep->flight_number !!}
|
||||
@endif
|
||||
</a>
|
||||
</h5>
|
||||
<div>
|
||||
@if($pirep->status == config('enums.pirep_status.PENDING'))
|
||||
<div class="badge badge-warning">Pending</div>
|
||||
@elseif($pirep->status == config('enums.pirep_status.ACCEPTED'))
|
||||
<div class="badge badge-success">Accepted</div>
|
||||
@else
|
||||
<div class="badge badge-danger">Rejected</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div>
|
||||
<span class="description">DEP </span>
|
||||
{!! $pirep->dpt_airport->icao !!}
|
||||
<span class="description">ARR </span>
|
||||
{!! $pirep->arr_airport->icao !!}
|
||||
</div>
|
||||
<div><span class="description">Flight Time </span>
|
||||
{!! Utils::secondsToTime($pirep->flight_time) !!}
|
||||
</div>
|
||||
<div><span class="description">Aircraft </span>
|
||||
{!! $pirep->aircraft->registration !!}
|
||||
({!! $pirep->aircraft->name !!})
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">Flight Level </span>
|
||||
{!! $pirep->level !!}
|
||||
</div>
|
||||
<div>
|
||||
<span class="description">File Date </span>
|
||||
{!! $pirep->created_at !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="description">more data </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-right">
|
||||
<button href="#" class="btn btn-info">Accept</button>
|
||||
<button href="#" class="btn btn-danger">Reject</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
{{--
|
||||
<table class="table table-hover table-responsive" id="pireps-table">
|
||||
<thead>
|
||||
<th>Pilot</th>
|
||||
<th>Flight</th>
|
||||
<th>Aircraft</th>
|
||||
<th>Flight Time</th>
|
||||
<th>Level</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($pireps as $pirep)
|
||||
<tr>
|
||||
<td>{!! $pirep->user->name !!}</td>
|
||||
<td>
|
||||
@if($pirep->flight)
|
||||
<a href="{!! route('admin.flights.show', ['id' => $pirep->flight_id]) !!}">
|
||||
{!! $pirep->flight->airline->code !!}{!! $pirep->flight->flight_number !!}
|
||||
</a>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>{!! $pirep->aircraft->registration !!} ({!! $pirep->aircraft->name !!})</td>
|
||||
<td>{!! Utils::secondsToTime($pirep->flight_time) !!}</td>
|
||||
<td>{!! $pirep->level !!}</td>
|
||||
<td style="text-align: right;">
|
||||
{!! Form::open(['route' => ['admin.pireps.destroy', $pirep->id], 'method' => 'delete']) !!}
|
||||
<div class='btn-group'>
|
||||
<a href="{!! route('admin.pireps.show', [$pirep->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
|
||||
<a href="{!! route('admin.pireps.edit', [$pirep->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</td>
|
||||
</tr>
|
||||
@if($pirep->notes)
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="8"><strong>Notes:</strong> {!! $pirep->notes !!}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
--}}
|
||||
@each('admin.pireps.pirep_card', $pireps, 'pirep')
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<a href="{!! route('admin.subfleets.create') !!}">
|
||||
<i class="ti-plus"></i>Add New</a>
|
||||
</li>
|
||||
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@@ -14,4 +13,3 @@
|
||||
@include('admin.subfleets.table')
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user