From ef38d39ec44260a41d1235f5267ddbcd664ccde7 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Mon, 15 Aug 2022 18:23:39 +0300 Subject: [PATCH] Add "Notes" to Airports (#1467) * Notes for Airports Adds capability of having notes/remarks for airports, includes * New database field * Airport Model change * CSV Import/Export capability for notes * Admin Airports list page change * Admin Airports edit page change * Default Template Airport show page change * Update Airport Tests * Add the new field to source csv * Check if the import works * Update AirportFactory.php Co-authored-by: Nabeel S --- app/Database/factories/AirportFactory.php | 1 + ...022_07_12_142108_add_notes_to_airports.php | 14 +++++++++++++ app/Models/Airport.php | 5 +++-- app/Services/ImportExport/AirportImporter.php | 1 + .../views/admin/airports/fields.blade.php | 13 ++++++++++++ .../views/admin/airports/table.blade.php | 8 +++++++- .../layouts/default/airports/show.blade.php | 11 +++++----- tests/ImporterTest.php | 1 + tests/data/airports.csv | 8 ++++---- tests/data/airports_special_chars.csv | 20 +++++++++---------- 10 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 app/Database/migrations/2022_07_12_142108_add_notes_to_airports.php diff --git a/app/Database/factories/AirportFactory.php b/app/Database/factories/AirportFactory.php index baca7d48..3dfb2d31 100644 --- a/app/Database/factories/AirportFactory.php +++ b/app/Database/factories/AirportFactory.php @@ -63,6 +63,7 @@ class AirportFactory extends Factory 'lat' => $this->faker->latitude, 'lon' => $this->faker->longitude, 'hub' => false, + 'notes' => null, 'ground_handling_cost' => $this->faker->randomFloat(2, 0, 500), 'fuel_100ll_cost' => $this->faker->randomFloat(2, 1, 10), 'fuel_jeta_cost' => $this->faker->randomFloat(2, 1, 10), diff --git a/app/Database/migrations/2022_07_12_142108_add_notes_to_airports.php b/app/Database/migrations/2022_07_12_142108_add_notes_to_airports.php new file mode 100644 index 00000000..f00e4893 --- /dev/null +++ b/app/Database/migrations/2022_07_12_142108_add_notes_to_airports.php @@ -0,0 +1,14 @@ +mediumText('notes')->nullable()->after('hub'); + }); + } +}; diff --git a/app/Models/Airport.php b/app/Models/Airport.php index d159075e..f169261d 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; * @property string location * @property string country * @property string timezone + * @property string notes * @property float ground_handling_cost * @property float fuel_100ll_cost * @property float fuel_jeta_cost @@ -56,6 +57,7 @@ class Airport extends Model 'fuel_100ll_cost', 'fuel_jeta_cost', 'fuel_mogas_cost', + 'notes', ]; protected $casts = [ @@ -81,8 +83,7 @@ class Airport extends Model 'ground_handling_cost' => 'nullable|numeric', 'fuel_100ll_cost' => 'nullable|numeric', 'fuel_jeta_cost' => 'nullable|numeric', - - 'fuel_mogas_cost' => 'nullable|numeric', + 'fuel_mogas_cost' => 'nullable|numeric', ]; /** diff --git a/app/Services/ImportExport/AirportImporter.php b/app/Services/ImportExport/AirportImporter.php index 29f7b5bc..3dc69aa1 100644 --- a/app/Services/ImportExport/AirportImporter.php +++ b/app/Services/ImportExport/AirportImporter.php @@ -30,6 +30,7 @@ class AirportImporter extends ImportExport 'fuel_100ll_cost' => 'nullable|numeric', 'fuel_jeta_cost' => 'nullable|numeric', 'fuel_mogas_cost' => 'nullable|numeric', + 'notes' => 'nullable', ]; /** diff --git a/resources/views/admin/airports/fields.blade.php b/resources/views/admin/airports/fields.blade.php index 55235ac7..bbcbf59b 100644 --- a/resources/views/admin/airports/fields.blade.php +++ b/resources/views/admin/airports/fields.blade.php @@ -100,7 +100,13 @@ This is the cost per {{ config('phpvms.internal_units.fuel') }} @endcomponent + +
+
+ {{ Form::label('notes', 'Remarks / Notes:') }} + {{ Form::textarea('notes', null, ['id' => 'editor', 'class' => 'editor', 'style' => 'padding: 5px']) }} +
@@ -119,3 +125,10 @@
+@section('scripts') + @parent + + +@endsection \ No newline at end of file diff --git a/resources/views/admin/airports/table.blade.php b/resources/views/admin/airports/table.blade.php index a1dd922a..68cbf67f 100644 --- a/resources/views/admin/airports/table.blade.php +++ b/resources/views/admin/airports/table.blade.php @@ -4,7 +4,8 @@ ICAO Name Location - Hub + Hub + Notes GH Cost JetA 100LL @@ -22,6 +23,11 @@ Hub @endif + + @if(filled($airport->notes)) + Notes + @endif + {{ $airport->ground_handling_cost }} diff --git a/resources/views/layouts/default/airports/show.blade.php b/resources/views/layouts/default/airports/show.blade.php index 7874be90..b5efcffb 100644 --- a/resources/views/layouts/default/airports/show.blade.php +++ b/resources/views/layouts/default/airports/show.blade.php @@ -16,12 +16,11 @@ {{-- Show the airspace map in the other column --}}
- {{ Widget::AirspaceMap([ - 'width' => '100%', - 'height' => '400px', - 'lat' => $airport->lat, - 'lon' => $airport->lon, - ]) }} + {{ Widget::AirspaceMap(['width' => '100%', 'height' => '400px', 'lat' => $airport->lat, 'lon' => $airport->lon]) }} + @if(filled($airport->notes)) +
+ {!! $airport->notes !!} + @endif
diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index ae85286b..e7d929ac 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -670,6 +670,7 @@ class ImporterTest extends TestCase $this->assertEquals('-97.6699', $airport->lon); $this->assertEquals(0.0, $airport->ground_handling_cost); $this->assertEquals(setting('airports.default_jet_a_fuel_cost'), $airport->fuel_jeta_cost); + $this->assertEquals('Test Note', $airport->notes); // See if it imported $airport = Airport::where([ diff --git a/tests/data/airports.csv b/tests/data/airports.csv index 4990410f..94633aa7 100644 --- a/tests/data/airports.csv +++ b/tests/data/airports.csv @@ -1,4 +1,4 @@ -icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost -KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,0,,, -KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,1,30.1945,-97.6699,,,0.9, -KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,150,,0.8, +icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes +KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,0,,,,"Test Note" +KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,1,30.1945,-97.6699,,,0.9,, +KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,150,,0.8,,"Busy Airport" diff --git a/tests/data/airports_special_chars.csv b/tests/data/airports_special_chars.csv index 33de991d..c6ae0f0b 100755 --- a/tests/data/airports_special_chars.csv +++ b/tests/data/airports_special_chars.csv @@ -1,10 +1,10 @@ -icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost -EGLL,LHR,"London Heathrow","London, England",,Europe/London,,51.4775,-0.4614,500,0,0,0 -KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA","United States",America/Chicago,1,30.1945,-97.6699,0,0,0,0 -KJFK,JFK,"John F Kennedy","New York, New York, USA","United States",America/New_York,1,40.6399,-73.7787,250,0,0,0 -KPAE,PAE,"Snohomish County (Paine Field) Airport",Everett,"United States",America/Los_Angeles,,47.9063,-122.282,0,0,0,0 -KSEA,SEA,"Seattle Tacoma International Airport",Seattle,"United States",America/Los_Angeles,,47.449,-122.309,0,0,0,0 -LEMD,MAD,"Adolfo Suárez Madrid–Barajas Airport",Madrid,Spain,Europe/Madrid,,40.4719,-3.5626,,0,0,0 -MKJP,KIN,"Norman Manley International Airport","Kingston, Jamaica",,America/Jamaica,,17.9357,-76.7875,50,0,0,0 -MWCR,GCM,"Owen Roberts International Airport",Georgetown,Cayman,America/Cayman,,19.2928,-81.3577,50,0,0,0 -OMDB,DXB,"Dubai International Airport","Dubai, UAE",,Asia/Dubai,,25.2528,55.3644,50,0,0,0 +icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes +EGLL,LHR,"London Heathrow","London, England",,Europe/London,,51.4775,-0.4614,500,0,0,0, +KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA","United States",America/Chicago,1,30.1945,-97.6699,0,0,0,0,"Test Note" +KJFK,JFK,"John F Kennedy","New York, New York, USA","United States",America/New_York,1,40.6399,-73.7787,250,0,0,0,"Busy Airport" +KPAE,PAE,"Snohomish County (Paine Field) Airport",Everett,"United States",America/Los_Angeles,,47.9063,-122.282,0,0,0,0, +KSEA,SEA,"Seattle Tacoma International Airport",Seattle,"United States",America/Los_Angeles,,47.449,-122.309,0,0,0,0, +LEMD,MAD,"Adolfo Suárez Madrid–Barajas Airport",Madrid,Spain,Europe/Madrid,,40.4719,-3.5626,,0,0,0, +MKJP,KIN,"Norman Manley International Airport","Kingston, Jamaica",,America/Jamaica,,17.9357,-76.7875,50,0,0,0, +MWCR,GCM,"Owen Roberts International Airport",Georgetown,Cayman,America/Cayman,,19.2928,-81.3577,50,0,0,0, +OMDB,DXB,"Dubai International Airport","Dubai, UAE",,Asia/Dubai,,25.2528,55.3644,50,0,0,0,