From 5e990164eed654dc84ee976d241ac821c00c502a Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Wed, 22 Nov 2017 11:52:02 -0600 Subject: [PATCH] updated subfleet admin design --- .idea/php.xml | 8 +-- .../Controllers/Admin/SubfleetController.php | 32 ++++++++---- composer.json | 6 +-- phpvms.iml | 17 +++++++ resources/views/admin/app.blade.php | 6 ++- .../views/admin/subfleets/edit.blade.php | 50 ++++++++----------- .../views/admin/subfleets/fares.blade.php | 22 ++++---- .../views/admin/subfleets/fields.blade.php | 47 ++++++++--------- .../views/admin/subfleets/index.blade.php | 26 ++++------ .../views/admin/subfleets/script.blade.php | 4 ++ .../views/admin/subfleets/table.blade.php | 14 ++++-- tests/FlightTest.php | 2 +- 12 files changed, 131 insertions(+), 103 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index f79a398f..b7849797 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -5,7 +5,6 @@ - @@ -28,7 +27,6 @@ - @@ -58,7 +56,6 @@ - @@ -120,6 +117,11 @@ + + + + + diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php index 8d930ef3..b0437428 100644 --- a/app/Http/Controllers/Admin/SubfleetController.php +++ b/app/Http/Controllers/Admin/SubfleetController.php @@ -20,6 +20,23 @@ class SubfleetController extends BaseController /** @var SubfleetRepository */ private $subfleetRepo, $fareRepo; + /** + * SubfleetController constructor. + * + * @param SubfleetRepository $subfleetRepo + * @param FareRepository $fareRepo + */ + public function __construct( + SubfleetRepository $subfleetRepo, + FareRepository $fareRepo + ) { + $this->subfleetRepo = $subfleetRepo; + $this->fareRepo = $fareRepo; + } + + /** + * @return array + */ protected function getFuelTypes() { $retval = []; @@ -30,6 +47,9 @@ class SubfleetController extends BaseController return $retval; } + /** + * Get all the fares that haven't been assigned to a given subfleet + */ protected function getAvailFares($subfleet) { $retval = []; @@ -45,15 +65,6 @@ class SubfleetController extends BaseController return $retval; } - public function __construct( - SubfleetRepository $subfleetRepo, - FareRepository $fareRepo - ) - { - $this->subfleetRepo = $subfleetRepo; - $this->fareRepo = $fareRepo; - } - /** * Display a listing of the Subfleet. * @@ -214,7 +225,8 @@ class SubfleetController extends BaseController $subfleet = $this->subfleetRepo->findWithoutFail($id); if (empty($subfleet)) { - return view('admin.aircraft.fares', ['fares' => []]); + return $this->return_fares_view($subfleet); + //return view('admin.aircraft.fares', ['fares' => []]); } $fare_svc = app('App\Services\FareService'); diff --git a/composer.json b/composer.json index c23ff2b4..bcfd13f0 100755 --- a/composer.json +++ b/composer.json @@ -37,14 +37,14 @@ "dg/rss-php": "1.2", "makinacorpus/php-bloom": "dev-master", "hashids/hashids": "2.0.*", - "maatwebsite/excel": "2.1.*" + "maatwebsite/excel": "2.1.*", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.3.*" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~6.0", - "symfony/css-selector": "3.1.*", - "symfony/dom-crawler": "3.1.*", "laravel/homestead": "v6.2.2", "scriptfusion/phpunit-immediate-exception-printer": "^1", "filp/whoops": "~2.0" diff --git a/phpvms.iml b/phpvms.iml index 6681fefd..bc4fd4dc 100644 --- a/phpvms.iml +++ b/phpvms.iml @@ -14,12 +14,15 @@ + + + @@ -28,10 +31,12 @@ + + @@ -49,12 +54,15 @@ + + + @@ -63,10 +71,12 @@ + + @@ -82,12 +92,15 @@ + + + @@ -96,10 +109,12 @@ + + @@ -109,10 +124,12 @@ + + diff --git a/resources/views/admin/app.blade.php b/resources/views/admin/app.blade.php index c4534057..1ee2927e 100644 --- a/resources/views/admin/app.blade.php +++ b/resources/views/admin/app.blade.php @@ -101,8 +101,10 @@
- @include('flash::message') - @yield('content') +
+ @include('flash::message') + @yield('content') +
diff --git a/resources/views/admin/subfleets/edit.blade.php b/resources/views/admin/subfleets/edit.blade.php index cd51e7d5..ba715b3f 100644 --- a/resources/views/admin/subfleets/edit.blade.php +++ b/resources/views/admin/subfleets/edit.blade.php @@ -1,36 +1,28 @@ @extends('admin.app') +@section('title', "Edit $subfleet->name") @section('content') -
-

Edit {!! $subfleet->name !!}

-
-
- @include('adminlte-templates::common.errors') -
-
-
- {!! Form::model($subfleet, ['route' => ['admin.subfleets.update', $subfleet->id], 'method' => 'patch']) !!} - - @include('admin.subfleets.fields') - - {!! Form::close() !!} -
-
+ @include('adminlte-templates::common.errors') +
+
+ {!! Form::model($subfleet, ['route' => ['admin.subfleets.update', $subfleet->id], 'method' => 'patch']) !!} + @include('admin.subfleets.fields') + {!! Form::close() !!}
-
-
-
-
-

fares

-
-
-    - Fares assigned to the current subfleet. These can be overridden, - otherwise, the value used is the default, which comes from the fare. -
- @include('admin.subfleets.fares') -
-
+
+
+
+

fares

+

+    + Fares assigned to the current subfleet. These can be overridden, + otherwise, the value used is the default, which comes from the fare. +

+
+
+
+
+ @include('admin.subfleets.fares')
diff --git a/resources/views/admin/subfleets/fares.blade.php b/resources/views/admin/subfleets/fares.blade.php index 74ba2c9e..1baf5dd8 100644 --- a/resources/views/admin/subfleets/fares.blade.php +++ b/resources/views/admin/subfleets/fares.blade.php @@ -1,3 +1,4 @@ +{{--
--}}
@foreach($subfleet->fares as $atf) - + @endforeach @@ -82,3 +85,4 @@ +{{----}} diff --git a/resources/views/admin/subfleets/fields.blade.php b/resources/views/admin/subfleets/fields.blade.php index 486d246b..356f4ce9 100644 --- a/resources/views/admin/subfleets/fields.blade.php +++ b/resources/views/admin/subfleets/fields.blade.php @@ -1,31 +1,28 @@ - -
- {!! Form::label('airline_id', 'Airline:') !!} - {!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!} -
+
+
+ {!! Form::label('airline_id', 'Airline:') !!} + {!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!} +
- -
- {!! Form::label('name', 'Name:') !!} - {!! Form::text('name', null, ['class' => 'form-control']) !!} -
+
+ {!! Form::label('name', 'Name:') !!} + {!! Form::text('name', null, ['class' => 'form-control']) !!} +
- -
- {!! Form::label('type', 'Type:') !!} - {!! Form::text('type', null, ['class' => 'form-control']) !!} -
+
+ {!! Form::label('type', 'Type:') !!} + {!! Form::text('type', null, ['class' => 'form-control']) !!} +
- -
- {!! Form::label('fuel_type', 'Fuel Type:') !!} - {!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!} -
+
+ {!! Form::label('fuel_type', 'Fuel Type:') !!} + {!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!} +
- -
-
- {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} - Cancel +
+
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} + Cancel +
diff --git a/resources/views/admin/subfleets/index.blade.php b/resources/views/admin/subfleets/index.blade.php index bd59a5fd..18d25f7b 100644 --- a/resources/views/admin/subfleets/index.blade.php +++ b/resources/views/admin/subfleets/index.blade.php @@ -1,23 +1,17 @@ @extends('admin.app') +@section('title', 'Subfleets') +@section('actions') +
  • + + Add New +
  • + +@endsection @section('content') -
    -

    Subfleets

    -

    - Add New -

    -
    -
    -
    - +
    @include('flash::message') - -
    -
    -
    - @include('admin.subfleets.table') -
    -
    + @include('admin.subfleets.table')
    @endsection diff --git a/resources/views/admin/subfleets/script.blade.php b/resources/views/admin/subfleets/script.blade.php index 059bf8c5..d8477a21 100644 --- a/resources/views/admin/subfleets/script.blade.php +++ b/resources/views/admin/subfleets/script.blade.php @@ -22,6 +22,10 @@ $(document).ready(function() { event.preventDefault(); $.pjax.submit(event, '#aircraft_fares_wrapper', {push: false}); }); + + $(document).on('pjax:complete', function() { + $(".select2").select2(); + }); }); @endsection diff --git a/resources/views/admin/subfleets/table.blade.php b/resources/views/admin/subfleets/table.blade.php index 19348e8f..460a217c 100644 --- a/resources/views/admin/subfleets/table.blade.php +++ b/resources/views/admin/subfleets/table.blade.php @@ -1,3 +1,4 @@ +
    {!! $atf->name !!} {!! $atf->code !!} {!! $atf->pivot->capacity !!} @@ -46,14 +47,16 @@ {!! $atf->pivot->cost !!} ({!! $atf->cost!!}) -
    - {!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/fares', 'method' => 'delete', 'class' => 'rm_fare']) !!} - {!! Form::hidden('fare_id', $atf->id) !!} - {!! Form::button('', - ['type' => 'submit', - 'class' => 'btn btn-danger btn-s']) !!} - {!! Form::close() !!} -
    + {!! Form::open(['url' => '/admin/subfleets/'.$subfleet->id.'/fares', + 'method' => 'delete', + 'class' => 'rm_fare' + ]) + !!} + {!! Form::hidden('fare_id', $atf->id) !!} + {!! Form::button('', + ['type' => 'submit', + 'class' => 'btn btn-sm btn-danger btn-icon']) !!} + {!! Form::close() !!}
    @@ -25,14 +26,17 @@ @endforeach
    Airline {!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!} -
    - - - {!! Form::button('', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!} -
    + + + + + {!! Form::button('', + ['type' => 'submit', 'class' => 'btn btn-sm btn-danger btn-icon', + 'onclick' => "return confirm('Are you sure?')"]) !!} {!! Form::close() !!}
    +
    diff --git a/tests/FlightTest.php b/tests/FlightTest.php index 6a07045a..cdc26a72 100644 --- a/tests/FlightTest.php +++ b/tests/FlightTest.php @@ -21,7 +21,7 @@ class FlightTest extends TestCase return $flight->id; } - public function XtestGetFlight() + public function testGetFlight() { $flight_id = $this->addFlight(); $response = $this->json('GET', '/api/flight/'.$flight_id);