Add flight fields for templated fields on edit flight #213
This commit is contained in:
11
resources/views/admin/flightfields/create.blade.php
Normal file
11
resources/views/admin/flightfields/create.blade.php
Normal file
@@ -0,0 +1,11 @@
|
||||
@extends('admin.app')
|
||||
@section('title', 'Adding Field')
|
||||
@section('content')
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
{{ Form::open(['route' => 'admin.flightfields.store']) }}
|
||||
@include('admin.flightfields.fields')
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
11
resources/views/admin/flightfields/edit.blade.php
Normal file
11
resources/views/admin/flightfields/edit.blade.php
Normal file
@@ -0,0 +1,11 @@
|
||||
@extends('admin.app')
|
||||
@section('title', 'Editing ' . $field->name)
|
||||
@section('content')
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
{{ Form::model($field, ['route' => ['admin.flightfields.update', $field->id], 'method' => 'patch']) }}
|
||||
@include('admin.flightfields.fields')
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
14
resources/views/admin/flightfields/fields.blade.php
Normal file
14
resources/views/admin/flightfields/fields.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
{{ Form::label('name', 'Name:') }} <span class="required">*</span>
|
||||
{{ Form::text('name', null, ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('name') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- Submit Field -->
|
||||
<div class="form-group col-sm-12">
|
||||
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
|
||||
<a href="{{ route('admin.flightfields.index') }}" class="btn btn-default">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
18
resources/views/admin/flightfields/index.blade.php
Normal file
18
resources/views/admin/flightfields/index.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
@extends('admin.app')
|
||||
@section('title', 'Flight Fields')
|
||||
@section('actions')
|
||||
<li><a href="{{ route('admin.flightfields.create') }}"><i class="ti-plus"></i>Add Field</a></li>
|
||||
<li>
|
||||
<a href="{{ route('admin.flights.create') }}">
|
||||
<i class="ti-plus"></i>
|
||||
Add Flight</a>
|
||||
</li>
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="content">
|
||||
@include('admin.flightfields.table')
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
34
resources/views/admin/flightfields/table.blade.php
Normal file
34
resources/views/admin/flightfields/table.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="content table-responsive table-full-width">
|
||||
|
||||
<div class="header">
|
||||
@component('admin.components.info')
|
||||
Flights fields that can be filled out. You can still add other custom fields
|
||||
directly in the flight, but this provides a template for all flights.
|
||||
@endcomponent
|
||||
</div>
|
||||
|
||||
<table class="table table-hover table-responsive" id="pirepFields-table">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($fields as $field)
|
||||
<tr>
|
||||
<td>{{ $field->name }}</td>
|
||||
<td class="text-right">
|
||||
{{ Form::open(['route' => ['admin.flightfields.destroy', $field->id], 'method' => 'delete']) }}
|
||||
<a href="{{ route('admin.flightfields.edit', [$field->id]) }}"
|
||||
class='btn btn-sm btn-success btn-icon'>
|
||||
<i class="fas fa-pencil-alt"></i></a>
|
||||
|
||||
{{ Form::button('<i class="fa fa-times"></i>',
|
||||
['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon',
|
||||
'onclick' => "return confirm('Are you sure?')"]) }}
|
||||
{{ Form::close() }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -9,23 +9,27 @@
|
||||
</thead>
|
||||
@endif
|
||||
<tbody>
|
||||
@foreach($flight->field_values as $field)
|
||||
@foreach($flight_fields as $field)
|
||||
@php
|
||||
$val_field = $flight->field_values->where('name', $field->name)->first();
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $field->name }}</td>
|
||||
<td>
|
||||
<a class="inline" href="#" data-pk="{{ $field->id }}" data-name="{{ $field->name }}">{{ $field->value }}</a>
|
||||
<a class="inline" href="#" data-pk="{{ $val_field['id'] ?? '' }}" data-name="{{ $field->name }}">
|
||||
{{ $val_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 pjax_flight_fields'
|
||||
]) }}
|
||||
{{ Form::hidden('field_id', $field->id) }}
|
||||
{{ Form::hidden('field_id', $val_field['id'] ?? null) }}
|
||||
<div class='btn-group'>
|
||||
{{ Form::button('<i class="fa fa-times"></i>',
|
||||
['type' => 'submit',
|
||||
'class' => 'btn btn-danger btn-xs'])
|
||||
}}
|
||||
['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon',
|
||||
'onclick' => "return confirm('Are you sure?')"]) }}
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</td>
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
@section('title', 'Flights')
|
||||
@section('actions')
|
||||
<li><a href="{{ route('admin.flightfields.index') }}"><i class="ti-plus"></i>Fields</a></li>
|
||||
<li>
|
||||
<a href="{{ route('admin.flights.create') }}">
|
||||
<i class="ti-plus"></i>
|
||||
Add New</a>
|
||||
Add Flight</a>
|
||||
</li>
|
||||
@endsection
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
|
||||
function setEditable() {
|
||||
|
||||
const setEditable = () =>
|
||||
{
|
||||
const api_key = $('meta[name="api-key"]').attr('content');
|
||||
const csrf_token = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
@@ -28,19 +28,17 @@ function setEditable() {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
const csrf_token = $('meta[name="csrf-token"]').attr('content');
|
||||
const setFieldsEditable = () =>
|
||||
{
|
||||
const api_key = $('meta[name="api-key"]').attr('content');
|
||||
|
||||
setEditable();
|
||||
const csrf_token = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
$('#flight_fields_wrapper a.inline').editable({
|
||||
type: 'text',
|
||||
mode: 'inline',
|
||||
emptytext: '0',
|
||||
emptytext: 'no value',
|
||||
url: '{{ url('/admin/flights/'.$flight->id.'/fields') }}',
|
||||
ajaxOptions: {
|
||||
type: 'post',
|
||||
@@ -58,29 +56,32 @@ $(document).ready(function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
setEditable();
|
||||
setFieldsEditable();
|
||||
|
||||
$(document).on('submit', 'form.pjax_flight_fields', function (event) {
|
||||
event.preventDefault();
|
||||
$.pjax.submit(event, '#flight_fields_wrapper', {push: false});
|
||||
setEditable();
|
||||
});
|
||||
|
||||
$(document).on('submit', 'form.pjax_subfleet_form', function (event) {
|
||||
event.preventDefault();
|
||||
$.pjax.submit(event, '#subfleet_flight_wrapper', {push: false});
|
||||
setEditable();
|
||||
});
|
||||
|
||||
$(document).on('submit', 'form.pjax_fares_form', function (event) {
|
||||
event.preventDefault();
|
||||
console.log(event);
|
||||
$.pjax.submit(event, '#flight_fares_wrapper', {push: false});
|
||||
setEditable();
|
||||
});
|
||||
|
||||
$(document).on('pjax:complete', function () {
|
||||
$(".select2").select2();
|
||||
setEditable();
|
||||
setFieldsEditable();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user