Set hours to read-only once they've changed away from PENDING #167
This commit is contained in:
@@ -21,6 +21,12 @@
|
||||
|
||||
<style type="text/css">
|
||||
@yield('css')
|
||||
|
||||
label {
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
<table class="">
|
||||
<tr>
|
||||
<td>
|
||||
@if($pirep->state === PirepState::PENDING
|
||||
|| $pirep->state === PirepState::REJECTED)
|
||||
{!! Form::open(['url' => route('admin.pirep.status', ['id'=>$pirep->id]),
|
||||
@if($pirep->state === PirepState::PENDING || $pirep->state === PirepState::REJECTED)
|
||||
{!! Form::open(['url' => route('admin.pirep.status', ['id' => $pirep->id]),
|
||||
'method' => 'post',
|
||||
'name' => 'accept_'.$pirep->id,
|
||||
'id' => $pirep->id.'_accept',
|
||||
'pirep_id' => $pirep->id,
|
||||
'new_status' => PirepState::ACCEPTED,
|
||||
'class' => 'pirep_submit_status']) !!}
|
||||
'class' => $on_edit_page ? 'pirep_change_status': 'pirep_submit_status']) !!}
|
||||
{!! Form::button('Accept', ['type' => 'submit', 'class' => 'btn btn-info']) !!}
|
||||
{!! Form::close() !!}
|
||||
@endif
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
@if($pirep->state === PirepState::PENDING
|
||||
|| $pirep->state === PirepState::ACCEPTED)
|
||||
{!! Form::open(['url' => route('admin.pirep.status', ['id'=>$pirep->id]),
|
||||
@if($pirep->state === PirepState::PENDING || $pirep->state === PirepState::ACCEPTED)
|
||||
{!! Form::open(['url' => route('admin.pirep.status', ['id' => $pirep->id]),
|
||||
'method' => 'post',
|
||||
'name' => 'reject_'.$pirep->id,
|
||||
'id' => $pirep->id.'_reject',
|
||||
'pirep_id' => $pirep->id,
|
||||
'new_status' => PirepState::REJECTED,
|
||||
'class' => 'pirep_submit_status']) !!}
|
||||
'class' => $on_edit_page ? 'pirep_change_status': 'pirep_submit_status']) !!}
|
||||
{!! Form::button('Reject', ['type' => 'submit', 'class' => 'btn btn-danger']) !!}
|
||||
{!! Form::close() !!}
|
||||
@endif
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
@extends('admin.app')
|
||||
@section('title', 'Create PIREP')
|
||||
|
||||
@section('content')
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
$MODEL_NAME_HUMAN$
|
||||
</h1>
|
||||
</section>
|
||||
<div class="content">
|
||||
<div class="box box-primary">
|
||||
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
{!! Form::open(['route' => 'admin.pireps.store']) !!}
|
||||
|
||||
@include('admin.pireps.fields')
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
{!! Form::open(['route' => 'admin.pireps.store']) !!}
|
||||
@include('admin.pireps.fields')
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@include('admin.pireps.scripts')
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
@extends('admin.app')
|
||||
|
||||
@section('title', 'Edit ' . $pirep->ident )
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
|
||||
{{-- pulled out to here otherwise the form::close() within a form undo it --}}
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h5 style="margin-top: 0px;">
|
||||
Filed By: <a href="{!! route('admin.users.edit', [$pirep->user_id]) !!}" target="_blank">
|
||||
{!! $pirep->user->pilot_id !!} {!! $pirep->user->name !!}
|
||||
</a>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="pull-right">
|
||||
@include('admin.pireps.actions', ['pirep' => $pirep, 'on_edit_page' => true])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! Form::model($pirep, ['route' => ['admin.pireps.update', $pirep->id], 'method' => 'patch']) !!}
|
||||
@include('admin.pireps.fields')
|
||||
{!! Form::close() !!}
|
||||
@@ -26,4 +43,5 @@
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('admin.pireps.scripts')
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
{{--<div class="avatar">
|
||||
<img src="{!! $pirep->pilot->gravatar() !!}" />
|
||||
</div>--}}
|
||||
Filed By: <a href="{!! route('admin.users.edit', [$pirep->pilot->id]) !!}" target="_blank">
|
||||
{!! $pirep->pilot->pilot_id !!} {!! $pirep->pilot->name !!}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
{!! Form::label('flight_number', 'Flight Number/Route Code/Leg') !!}
|
||||
@@ -60,10 +50,10 @@
|
||||
{!! Form::label('flight_time', 'Flight Time (hours & minutes):') !!}
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
{!! Form::number('hours', null, ['class' => 'form-control', 'placeholder' => 'hours']) !!}
|
||||
{!! Form::number('hours', null, ['class' => 'form-control', 'placeholder' => 'hours', 'readonly' => $read_only]) !!}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{!! Form::number('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes']) !!}
|
||||
{!! Form::number('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes', 'readonly' => $read_only]) !!}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('hours') }}</p>
|
||||
<p class="text-danger">{{ $errors->first('minutes') }}</p>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div id="pirep_{!! $pirep->id !!}_actionbar" class="pull-right">
|
||||
@include('admin.pireps.actions')
|
||||
@include('admin.pireps.actions', ['pirep' => $pirep, 'on_edit_page' => false])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
function changeStatus(values) {
|
||||
const destContainer = '#pirep_' + values.pirep_id + '_actionbar';
|
||||
const changeStatus = (values, fn) => {
|
||||
console.log('Changing PIREP ' + values.pirep_id + ' to state ' + values.new_status);
|
||||
$.ajax({
|
||||
url: BASE_URL + '/admin/pireps/' + values.pirep_id + '/status',
|
||||
data: values,
|
||||
@@ -10,11 +10,10 @@ function changeStatus(values) {
|
||||
'x-api-key': PHPVMS_USER_API_KEY
|
||||
},
|
||||
success: function (data) {
|
||||
// console.log(data);
|
||||
$(destContainer).html(data);
|
||||
fn(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
@@ -36,11 +35,22 @@ $(document).ready(function() {
|
||||
new_status: $(this).attr('new_status')
|
||||
};
|
||||
|
||||
console.log(values);
|
||||
console.log('Changing PIREP ' + values.pirep_id + ' to state ' + values.new_status);
|
||||
|
||||
changeStatus(values);
|
||||
changeStatus(values, (data) => {
|
||||
const destContainer = '#pirep_' + values.pirep_id + '_actionbar';
|
||||
$(destContainer).html(data);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('submit', 'form.pirep_change_status', function(event) {
|
||||
event.preventDefault();
|
||||
changeStatus({
|
||||
pirep_id: $(this).attr('pirep_id'),
|
||||
new_status: $(this).attr('new_status')
|
||||
}, (data) => {
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user