From c69e2c0cc88065761511d987bfe962605e26e71b Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 7 Jan 2018 08:58:57 -0600 Subject: [PATCH] Fix for subfleet add/remove on flight page #124 --- .../Controllers/Admin/FlightController.php | 5 +- .../views/admin/flights/create.blade.php | 1 + resources/views/admin/flights/edit.blade.php | 33 +------ .../admin/flights/flight_fields.blade.php | 44 ++++----- resources/views/admin/flights/index.blade.php | 2 +- .../views/admin/flights/scripts.blade.php | 35 +++++++ .../views/admin/flights/subfleets.blade.php | 95 ++++++++++--------- 7 files changed, 112 insertions(+), 103 deletions(-) create mode 100644 resources/views/admin/flights/scripts.blade.php diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index 3a1a00fa..3ed98236 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -246,13 +246,12 @@ class FlightController extends BaseController } /** + * @param $id * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ - public function subfleets(Request $request) + public function subfleets($id, Request $request) { - $id = $request->id; - $flight = $this->flightRepo->findWithoutFail($id); if (empty($flight)) { Flash::error('Flight not found'); diff --git a/resources/views/admin/flights/create.blade.php b/resources/views/admin/flights/create.blade.php index d3b041c8..a106c46c 100644 --- a/resources/views/admin/flights/create.blade.php +++ b/resources/views/admin/flights/create.blade.php @@ -10,3 +10,4 @@ @endsection +@include('admin.flights.scripts') diff --git a/resources/views/admin/flights/edit.blade.php b/resources/views/admin/flights/edit.blade.php index 7a8aeaae..e5440f79 100644 --- a/resources/views/admin/flights/edit.blade.php +++ b/resources/views/admin/flights/edit.blade.php @@ -11,47 +11,16 @@ -

custom fields

@include('admin.flights.flight_fields')
-

assigned subfleets

@include('admin.flights.subfleets')
@endsection -@section('scripts') - -@endsection +@include('admin.flights.scripts') diff --git a/resources/views/admin/flights/flight_fields.blade.php b/resources/views/admin/flights/flight_fields.blade.php index 7f9f3a70..c2253f95 100644 --- a/resources/views/admin/flights/flight_fields.blade.php +++ b/resources/views/admin/flights/flight_fields.blade.php @@ -1,5 +1,5 @@ -
+

custom fields


@@ -16,7 +16,7 @@
Name {!! Form::open(['url' => '/admin/flights/'.$flight->id.'/fields', 'method' => 'delete', - 'class' => 'pjax_form flight_fields' + 'class' => 'pjax_form pjax_flight_fields' ]) !!} {!! Form::hidden('field_id', $field->id) !!}
@@ -32,27 +32,27 @@

-
- {!! Form::open([ - 'url' => '/admin/flights/'.$flight->id.'/fields', - 'method' => 'post', - 'class' => 'pjax_form form-inline' - ]) - !!} +
+
+
+ {!! Form::open([ + 'url' => '/admin/flights/'.$flight->id.'/fields', + 'method' => 'post', + 'class' => 'pjax_form form-inline pjax_flight_fields' + ]) + !!} -
- - {!! Form::label('name', 'Name:') !!} - {!! Form::text('name', null, ['class' => 'form-control']) !!} -    - {!! Form::label('value', 'Value:') !!} - {!! Form::text('value', null, ['class' => 'form-control']) !!} -    - {!! Form::button(' add', - ['type' => 'submit', - 'class' => 'btn btn-success btn-s']) !!} + {!! Form::label('name', 'Name:') !!} + {!! Form::text('name', null, ['class' => 'form-control']) !!} +    + {!! Form::label('value', 'Value:') !!} + {!! Form::text('value', null, ['class' => 'form-control']) !!} +    + {!! Form::button(' add', + ['type' => 'submit', + 'class' => 'btn btn-success btn-s']) !!} + {!! Form::close() !!} +
- {!! Form::close() !!}
-
diff --git a/resources/views/admin/flights/index.blade.php b/resources/views/admin/flights/index.blade.php index 99e49302..86663280 100644 --- a/resources/views/admin/flights/index.blade.php +++ b/resources/views/admin/flights/index.blade.php @@ -24,4 +24,4 @@
@endsection - +@include('admin.flights.scripts') diff --git a/resources/views/admin/flights/scripts.blade.php b/resources/views/admin/flights/scripts.blade.php new file mode 100644 index 00000000..21fdb8ac --- /dev/null +++ b/resources/views/admin/flights/scripts.blade.php @@ -0,0 +1,35 @@ +@section('scripts') + +@endsection diff --git a/resources/views/admin/flights/subfleets.blade.php b/resources/views/admin/flights/subfleets.blade.php index f09ccb08..589fb819 100644 --- a/resources/views/admin/flights/subfleets.blade.php +++ b/resources/views/admin/flights/subfleets.blade.php @@ -1,50 +1,55 @@
- - - - - - - - @foreach($flight->subfleets as $sf) - - - - - - @endforeach - -
TypeNameActions
{!! $sf->type !!}{!! $sf->name !!} - {!! Form::open(['url' => '/admin/flights/'.$flight->id.'/subfleets', 'method' => 'delete', 'class' => 'flight_subfleet']) !!} - {!! Form::hidden('subfleet_id', $sf->id) !!} -
- {!! Form::button('', - ['type' => 'submit', - 'class' => 'btn btn-danger btn-xs']) - !!} -
+

assigned subfleets

+
+ + + + + + + + + @foreach($flight->subfleets as $sf) + + + + + + @endforeach + +
TypeNameActions
{!! $sf->type !!}{!! $sf->name !!} + {!! Form::open(['url' => '/admin/flights/'.$flight->id.'/subfleets', + 'method' => 'delete', + 'class' => 'pjax_subfleet_form']) !!} + {!! Form::hidden('subfleet_id', $sf->id) !!} +
+ {!! Form::button('', + ['type' => 'submit', + 'class' => 'btn btn-danger btn-xs']) + !!} +
+ {!! Form::close() !!} +
+
+
+
+
+ {!! Form::open([ + 'url' => '/admin/flights/'.$flight->id.'/subfleets', + 'method' => 'post', + 'class' => 'pjax_form form-inline pjax_subfleet_form' + ]) + !!} + {!! Form::select('subfleet_id', $avail_subfleets, null, [ + 'placeholder' => 'Select Subfleet', + 'class' => 'select2_dropdown form-control input-lg', + ]) + !!} + {!! Form::button(' add', + ['type' => 'submit', + 'class' => 'btn btn-success btn-s']) !!} {!! Form::close() !!} -
-
-
-
-
- {!! Form::open([ - 'url' => '/admin/flights/'.$flight->id.'/subfleets', - 'method' => 'post', - 'class' => 'pjax_form form-inline' - ]) - !!} - {!! Form::select('subfleet_id', $avail_subfleets, null, [ - 'placeholder' => 'Select Subfleet', - 'class' => 'select2_dropdown form-control input-lg', - ]) - !!} - {!! Form::button(' add', - ['type' => 'submit', - 'class' => 'btn btn-success btn-s']) !!} - {!! Form::close() !!} +
-