Refactoring of PIREP submission and field code #146

This commit is contained in:
Nabeel Shahzad
2018-01-23 15:48:30 -06:00
parent 341424ad7e
commit f9efa81bb4
19 changed files with 191 additions and 147 deletions

View File

@@ -2,16 +2,9 @@
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/
/**
* Validation Language Lines
*/
'accepted' => 'The :attribute must be accepted.',
'active_url' => 'The :attribute is not a valid URL.',
@@ -39,7 +32,7 @@ return [
'email' => 'The :attribute must be a valid email address.',
'exists' => 'The selected :attribute is invalid.',
'file' => 'The :attribute must be a file.',
'filled' => 'The :attribute field is required.',
'filled' => 'The ":attribute" is required.',
'image' => 'The :attribute must be an image.',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
@@ -63,7 +56,7 @@ return [
'numeric' => 'The :attribute must be a number.',
'present' => 'The :attribute field must be present.',
'regex' => 'The :attribute format is invalid.',
'required' => 'The :attribute field is required.',
'required' => 'The ":attribute" field is required.',
'required_if' => 'The :attribute field is required when :other is :value.',
'required_unless' => 'The :attribute field is required unless :other is in :values.',
'required_with' => 'The :attribute field is required when :values is present.',
@@ -82,33 +75,38 @@ return [
'unique' => 'The :attribute has already been taken.',
'url' => 'The :attribute format is invalid.',
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
/**
* Custom Validation Language Lines
*/
'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
'airline_id' => [
'required' => 'An airline is required',
'exists' => 'The airline doesn\'t exist',
],
'aircraft_id' => [
'required' => 'An aircraft is required',
'exists' => 'The aircraft doesn\'t exist',
],
'arr_airport_id' => [
'required' => 'An arrival airport is required',
],
'dpt_airport_id' => [
'required' => 'A departure airport is required',
],
'flight_time' => [
'required' => 'Flight time, in minutes, is required',
'integer' => 'Flight time, in minutes, is required',
],
'planned_flight_time' => [
'required' => 'Flight time, in minutes, is required',
'integer' => 'Flight time, in minutes, is required',
],
],
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
/**
* Custom Validation Attributes
*/
'attributes' => [],

View File

@@ -1,4 +1,12 @@
<div class="content table-responsive table-full-width">
<div class="header">
<p class="category">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
PIREP fields are only shown for manual PIREPs.
</p>
</div>
<table class="table table-hover table-responsive" id="pirepFields-table">
<thead>
<th>Name</th>

View File

@@ -13,7 +13,7 @@
<td>
<a class="inline" href="#" data-pk="{!! $field->id !!}" data-name="{!! $field->name !!}">{!! $field->value !!}</a>
</td>
<td>{!! $field->source !!}</td>
<td>{!! PirepSource::label($field->source) !!}</td>
<td style="width: 10%; text-align: right;" class="form-inline">
{!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/fields',
'method' => 'delete',

View File

@@ -5,7 +5,7 @@
<div class="col-sm-2 text-center">
<h5>
<a class="text-c"
href="{!! route('admin.pireps.show', [$pirep->id]) !!}">
href="{!! route('admin.pireps.edit', [$pirep->id]) !!}">
{!! $pirep->ident !!}
</a>
</h5>

View File

@@ -12,6 +12,7 @@
<div class="input-group form-group">
{!! Form::select('airline_id', $airlines, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
</td>
</tr>
@@ -23,6 +24,9 @@
{!! Form::text('route_code', null, ['placeholder' => 'Code (optional)', 'class' => 'form-control']) !!}
{!! Form::text('route_leg', null, ['placeholder' => 'Leg (optional)', 'class' => 'form-control']) !!}
</div>
<p class="text-danger">{{ $errors->first('flight_number') }}</p>
<p class="text-danger">{{ $errors->first('route_code') }}</p>
<p class="text-danger">{{ $errors->first('route_leg') }}</p>
</td>
</tr>
@@ -32,6 +36,7 @@
<div class="input-group form-group">
{!! Form::select('aircraft_id', $aircraft, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="text-danger">{{ $errors->first('aircraft_id') }}</p>
</td>
</tr>
@@ -41,6 +46,7 @@
<div class="input-group form-group">
{!! Form::select('dpt_airport_id', $airports, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="text-danger">{{ $errors->first('dpt_airport_id') }}</p>
</td>
</tr>
@@ -50,6 +56,7 @@
<div class="input-group form-group">
{!! Form::select('arr_airport_id', $airports, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="text-danger">{{ $errors->first('arr_airport_id') }}</p>
</td>
</tr>
@@ -60,46 +67,50 @@
{!! Form::number('hours', null, ['class' => 'form-control', 'placeholder' => 'hours']) !!}
{!! Form::number('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes']) !!}
</div>
<p class="text-danger">{{ $errors->first('hours') }}</p>
<p class="text-danger">{{ $errors->first('minutes') }}</p>
</td>
</tr>
{{--
Write out the custom fields, and label if they're required
--}}
@foreach($pirep_fields as $field)
<tr>
<td>
{!! $field->name !!}
@if($field->required === true)
<span class="text-danger">*</span>
@endif
</td>
<td>
<div class="input-group form-group">
{!! Form::text($field->slug, null, [
'class' => 'form-control'
]) !!}
</div>
<p class="text-danger">{{ $errors->first($field->slug) }}</p>
</td>
</tr>
@endforeach
<tr>
<td class="align-text-top">Route</td>
<td>
<div class="input-group form-group">
{!! Form::textarea('route', null, ['class' => 'form-control', 'placeholder' => 'Route']) !!}
</div>
<p class="text-danger">{{ $errors->first('route') }}</p>
</td>
</tr>
{{--
Write out the custom fields, and label if they're required
--}}
@foreach($pirepfields as $field)
<tr>
<td>
{!! $field->name !!}
<span class="label label-danger">required</span>
</td>
<td>
<div class="input-group form-group">
<!--<span class="input-group-addon">
<i class="now-ui-icons users_single-02"></i>
</span>-->
{!! Form::text('field_'.$field->id, null, [
'class' => 'form-control'
]) !!}
</div>
</td>
</tr>
@endforeach
<tr>
<td class="align-text-top"><p class="">Notes</p></td>
<td>
<div class="input-group form-group">
{!! Form::textarea('notes', null, ['class' => 'form-control', 'placeholder' => 'Notes']) !!}
</div>
<p class="text-danger">{{ $errors->first('notes') }}</p>
</td>
</tr>
</tbody>

View File

@@ -4,12 +4,7 @@
<div class="col-sm-2 text-center">
<h5>
<a class="text-c" href="{!! route('frontend.pireps.show', [$pirep->id]) !!}">
{!! $pirep->airline->code !!}
@if($pirep->flight_id)
{!! $pirep->flight->flight_number !!}
@else
{!! $pirep->flight_number !!}
@endif
{!! $pirep->ident !!}
</a>
</h5>
<div>

View File

@@ -77,16 +77,14 @@
<h3 class="description">fields</h3>
<table class="table">
<thead>
<th>Name</th>
<th>Value</th>
<th>Source</th>
<th>Name</th>
<th>Value</th>
</thead>
<tbody>
@foreach($pirep->fields as $field)
<tr>
<td>{!! $field->name !!}</td>
<td>{!! $field->value !!}</td>
<td>{!! $field->source !!}</td>
</tr>
@endforeach
</tbody>