Skip to content

Commit

Permalink
add import template and styling
Browse files Browse the repository at this point in the history
  • Loading branch information
roelgonzalez committed Aug 16, 2020
1 parent 1323819 commit 5dfa9f2
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 14 deletions.
13 changes: 13 additions & 0 deletions app/Http/Controllers/TemplateDownloadController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Storage;

class TemplateDownloadController extends Controller
{
public function flightTemplate()
{
return Storage::disk('central-local')->download('flights-template.csv');
}
}
5 changes: 5 additions & 0 deletions config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
'root' => storage_path('app'),
],

'central-local' => [
'driver' => 'local',
'root' => storage_path('app'),
],

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
Expand Down
24 changes: 22 additions & 2 deletions resources/views/livewire/bookable-flight-import.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
<div>
<div class="px-6 py-4 my-4 font-light rounded bg-white border-2 border-blue-200">
An easier way to add flights to your event is to import them from a spreadsheet. comma separated values files (csv) are supported for import.
<br>
You can download the template of the spreadsheet below.
<br>
Each row will represent one flight. Make sure to follow the format given in the template.
<br>
When you have populated the spreadsheet with your flights, you can upload the file here and have them imported.
<br><br>
<span class="font-bold">Important Notes:</span>
<br>
All times are given in zulu format and should only contain digits! E.g. 0300 or 1500 and <span class="font-semibold">NOT</span> 12:00pm or 14:30am.
<br>
If you leave the date columns empty, the date for the booking will be the same as the event date!
<br>
All dates are given in the following format: yyyy-mm-dd e.g 2020-12-31
</div>
<div class="w-full">
<a class="btn btn-blue-secondary block" href="{{ route('download-flight-template') }}">Download Template</a>
</div>
<form wire:submit.prevent="import">
<input wire:model="file" type="file">
<button>Upload</button>
<input wire:model="file" class="mt-4 w-full" type="file">
<button class="btn btn-blue mt-4 w-full">Upload</button>
@error('file')
<div class="text-red-800">
{{ $message }}
Expand Down
27 changes: 15 additions & 12 deletions resources/views/office-events/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,23 @@ class="px-4">
<h2 class="text-lg">Bookables actions</h2>
<hr class="mt-2">
</div>
<div>
@livewire('bookable-flight-import', ['event' => $event])
</div>
<div x-data="{ bookable: 'none'}">
<div x-show="bookable === 'none'" class="mt-4 px-4 md:px-4 w-1/2">
<button class="btn btn-blue w-full " @click="bookable = 'flight'">Add flight</button>
<div x-data="{ openBookableAction: 'none'}">
<div class="flex">
<div x-show="openBookableAction === 'none'" class="mt-4 px-4 md:px-4 w-1/2">
<button class="btn btn-blue w-full" @click="openBookableAction = 'addFlight'">Add flight</button>
</div>
<div x-show="openBookableAction === 'none'" class="mt-4 px-4 md:px-4 w-1/2">
<button class="btn btn-blue-secondary w-full" @click="openBookableAction = 'importFlights'">Import Flights</button>
</div>
</div>
<div x-show="bookable !== 'none'" class="mt-4 px-4 md:px-4 w-full">
<button class="btn btn-blue-secondary w-full " @click="bookable = 'none'">Cancel</button>
<div x-show="openBookableAction !== 'none'" class="mt-4 px-4 md:px-4 w-full">
<button class="btn btn-blue-secondary w-full " @click="openBookableAction = 'none'">Cancel</button>
</div>
<div class="mt-4 px-4">
<div x-show.transition.duration.300ms="bookable === 'flight'">
@livewire('add-bookable-flight', ['event' => $event])
</div>
<div x-show.transition.duration.300ms="openBookableAction === 'addFlight'" class="mt-4 px-4">
@livewire('add-bookable-flight', ['event' => $event])
</div>
<div x-show.transition.duration.300ms="openBookableAction === 'importFlights'" class="mt-4 px-4">
@livewire('bookable-flight-import', ['event' => $event])
</div>
</div>
<div class="mt-4 px-4">
Expand Down
2 changes: 2 additions & 0 deletions routes/tenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

Route::get('/home', 'HomeController@index')->name('home');

Route::get('templates/flight-template')->uses(TemplateDownloadController::class . '@flightTemplate')->name('download-flight-template');

Route::get('office')->uses(OfficeController::class. '@index')->name('office.index');
Route::get('office/events/create')->uses(OfficeEventController::class . '@create')->name('office-events.create');
Route::get('office/events')->uses(OfficeEventController::class . '@index')->name('office-events.index');
Expand Down
1 change: 1 addition & 0 deletions storage/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!public/
!.gitignore
!flights-template.csv
3 changes: 3 additions & 0 deletions storage/app/flights-template.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Departure Date,Departure Time,Arrival Date,Arrival Time,Origin Airport ICAO,Destination Airport ICAO,Callsign
2020-12-31,1300,2020-12-31,1900,KJFK,EGLL,AAL123
,2300,,0200,EHAM,GTCS,RYR12AB

0 comments on commit 5dfa9f2

Please sign in to comment.