Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace form components #913

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/View/Components/Forms/Inputs/Input.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\View\Components\Forms\Inputs;

use BladeUIKit\Components\Forms\Inputs\Input as OriginalInput;

class Input extends OriginalInput
{
public function __construct(string $name, string $id = null, string $type = 'text', ?string $value = '')
{
$this->name = $name;
$this->id = $id ?? $name;
$this->type = $type;

$this->value = old($name, $value ?? '');
}
}
32 changes: 32 additions & 0 deletions app/View/Components/Forms/Label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Support\Str;
use Illuminate\View\Component;
use Illuminate\Contracts\View\View;

class Label extends Component
{
public function __construct(public string $for, public ?string $label = null)
{
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View
{
return view('components.forms.label', [
'for' => $this->for,
'fallback' => $this->fallback(),
]);
}

public function fallback(): string
{
return Str::ucfirst(str_replace('_', ' ', $this->for));
}
}
21 changes: 10 additions & 11 deletions config/blade-ui-kit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use App\View\Components\FlatPickr;
use BladeUIKit\Components;

return [
Expand All @@ -17,7 +16,7 @@
*/

'components' => [
// 'alert' => Components\Alerts\Alert::class,
'alert' => Components\Alerts\Alert::class,
// 'avatar' => Components\Support\Avatar::class,
// 'carbon' => Components\DateTime\Carbon::class,
// 'checkbox' => Components\Forms\Inputs\Checkbox::class,
Expand All @@ -27,20 +26,20 @@
// 'dropdown' => Components\Navigation\Dropdown::class,
// 'easy-mde' => Components\Editors\EasyMDE::class,
// 'email' => Components\Forms\Inputs\Email::class,
// 'error' => Components\Forms\Error::class,
'flat-pickr' => FlatPickr::class,
// 'form' => Components\Forms\Form::class,
// 'form-button' => Components\Buttons\FormButton::class,
// 'html' => Components\Layouts\Html::class,
// 'input' => Components\Forms\Inputs\Input::class,
// 'label' => Components\Forms\Label::class,
// 'logout' => Components\Buttons\Logout::class,
'error' => Components\Forms\Error::class,
'flat-pickr' => App\View\Components\FlatPickr::class,
'form' => Components\Forms\Form::class,
'form-button' => Components\Buttons\FormButton::class,
'html' => Components\Layouts\Html::class,
'input' => App\View\Components\Forms\Inputs\Input::class,
'label' => Components\Forms\Label::class,
'logout' => Components\Buttons\Logout::class,
// 'mapbox' => Components\Maps\Mapbox::class,
// 'markdown' => Components\Markdown\Markdown::class,
// 'password' => Components\Forms\Inputs\Password::class,
// 'pikaday' => Components\Forms\Inputs\Pikaday::class,
// 'social-meta' => Components\Layouts\SocialMeta::class,
// 'textarea' => Components\Forms\Inputs\Textarea::class,
'textarea' => Components\Forms\Inputs\Textarea::class,
// 'toc' => Components\Markdown\ToC::class,
// 'trix' => Components\Editors\Trix::class,
// 'unsplash' => Components\Support\Unsplash::class,
Expand Down
20 changes: 8 additions & 12 deletions resources/views/airport/admin/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@
<div class="card-header">{{ $airport->id ? __('Edit') : __('Add new') }} {{ __('Airport') }}</div>

<div class="card-body">
<x-form
:action="$airport->id ? route('admin.airports.update', $airport) : route('admin.airports.store')"
:method="$airport->id ? 'PATCH' : 'POST'">
<x-form :action="$airport->id ? route('admin.airports.update', $airport) : route('admin.airports.store')" :method="$airport->id ? 'PATCH' : 'POST'">

@bind($airport)
<x-form-input name="icao" :label="__('ICAO')" required maxlength="4" />
<x-form-input name="iata" :label="__('IATA')" required maxlength="3" />
<x-form-input name="name" :label="__('Name')" required />
<x-form-input name="latitude" :label="__('Latitude')" />
<x-form-input name="longitude" :label="__('Longitude')" />
<x-forms.input name="icao" :label="__('ICAO')" :value="$airport->icao" required maxlength="4" />
<x-forms.input name="iata" :label="__('IATA')" :value="$airport->iata" required maxlength="3" />
<x-forms.input name="name" :label="__('Name')" :value="$airport->name" required />
<x-forms.input name="latitude" :value="$airport->latitude" />
<x-forms.input name="longitude" :label="__('Longitude')" :value="$airport->longitude" />

<x-form-submit>
<x-forms.button type="submit">
@if ($airport->id)
<i class="fa fa-check"></i> {{ __('Edit') }}
@else
<i class="fa fa-plus"></i> {{ __('Add') }}
@endif
</x-form-submit>
@endbind
</x-forms.button>
</x-form>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions resources/views/airport/admin/overview.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
</a>
</td>
<td>
@if ($airport->flightsDep->isEmpty() && $airport->flightsArr->isEmpty() && $airport->eventDep->isEmpty() && $airport->eventArr->isEmpty())
@if (
$airport->flightsDep->isEmpty() &&
$airport->flightsArr->isEmpty() &&
$airport->eventDep->isEmpty() &&
$airport->eventArr->isEmpty())
<form action="{{ route('admin.airports.destroy', $airport) }}" method="post">
@method('DELETE')
<button class="btn btn-danger delete-airport"><i class="fa fa-trash"></i> Remove Airport
Expand All @@ -87,6 +91,5 @@
{{ $airports->links() }}
</table>
{{ $airports->links() }}
<x-form :action="route('admin.airports.destroyUnused')" id="delete-unused-airports" method="POST"
style="display: none;"></x-form>
<x-form :action="route('admin.airports.destroyUnused')" id="delete-unused-airports" method="POST" style="display: none;"></x-form>
@endsection
9 changes: 4 additions & 5 deletions resources/views/airport/admin/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
<div class="card-header">{{ $airport->name }} [{{ $airport->icao }} | {{ $airport->iata }}]</div>

<div class="card-body">
@foreach($airport->links as $link)
@foreach ($airport->links as $link)
<div class="form-group row">
<label for="{{ $link->type->name . '-' . $loop->index }}"
class="col-md-4 col-form-label text-md-right">{{ $link->name ?? $link->type->name }}</label>
class="col-md-4 col-form-label text-md-right">{{ $link->name ?? $link->type->name }}</label>

<div class="col-md-6">
<div class="form-control-plaintext"><a
href="{{ $link->url }}"
target="_blank">Link</a></div>
<div class="form-control-plaintext"><a href="{{ $link->url }}" target="_blank">Link</a>
</div>
</div>
</div>
@endforeach
Expand Down
28 changes: 13 additions & 15 deletions resources/views/airportLink/admin/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,31 @@
</div>

<div class="card-body">
<x-form
:action="$airportLink->id ? route('admin.airportLinks.update', $airportLink) : route('admin.airportLinks.store')"
:method="$airportLink->id ? 'PATCH' : 'POST'">
<x-form :action="$airportLink->id
? route('admin.airportLinks.update', $airportLink)
: route('admin.airportLinks.store')" :method="$airportLink->id ? 'PATCH' : 'POST'">

@bind($airportLink)
<x-form-select name="airportLinkType_id" :label="__('Type')" :options="$airportLinkTypes"
:placeholder="__('Choose...')" required />
<x-forms.select name="airportLinkType_id" :label="__('Type')" :options="$airportLinkTypes" :placeholder="__('Choose...')"
required :value="$airportLink->airportLinkType_id" />
@if ($airportLink->id)
<x-form-group :label="__('Airport')">
<x-forms.form-group name="airport_id" label="Airport">
{{ $airportLink->airport->icao }} [{{ $airportLink->airport->name }}
({{ $airportLink->airport->iata }})]
</x-form-group>
</x-forms.form-group>
@else
<x-form-select name="airport_id" :label="__('Airport')" :options="$airports"
:placeholder="__('Choose...')" required />
<x-forms.select name="airport_id" :label="__('Airport')" :options="$airports" :placeholder="__('Choose...')"
required />
@endif
<x-form-input name="name" :label="__('Name')" />
<x-form-input name="url" :label="__('URL')" placeholder="https://example.org" required />
<x-forms.input name="name" :label="__('Name')" :help="__('Leave empty to use the type as name')" />
<x-forms.input name="url" :label="__('URL')" placeholder="https://example.org" required />

<x-form-submit>
<x-forms.button type="submit">
@if ($airportLink->id)
<i class="fa fa-check"></i> {{ __('Edit') }}
@else
<i class="fa fa-plus"></i> {{ __('Add') }}
@endif
</x-form-submit>
@endbind
</x-forms.button>
</x-form>
</div>
</div>
Expand Down
111 changes: 57 additions & 54 deletions resources/views/booking/admin/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,92 +8,95 @@
<div class="card-header">{{ $event->name }} | {{ $bulk ? __('Add Timeslots') : __('Add Slot') }}</div>

<div class="card-body">
<x-form :action="route('admin.bookings.store',$event)" method="POST">
<x-form :action="route('admin.bookings.store', $event)" method="POST">
<input type="hidden" name="id" value="{{ $event->id }}">
<input type="hidden" name="bulk" value="{{ $bulk ? 1 : 0 }}">

<x-form-group :label="__('Event')">
<x-forms.form-group name="event" :label="__('Event')">
{{ $event->name }} [{{ $event->startEvent->format('d-m-Y') }} |
{{ $event->startEvent->format('Hi') }}z -
{{ $event->endEvent->format('Hi') }}z]
</x-form-group>
</x-forms.form-group>

<x-form-group name="is_editable" :label="__('Editable?')" inline>
<x-form-radio name="is_editable" value="0" :label="__('No')" required />
<x-form-radio name="is_editable" value="1" :label="__('Yes')" required />
@slot('help')
<small class="form-text text-muted">
{{ __('Choose if you want the booking to be editable (Callsign and Aircraft Code only) by users. This is useful when using \'import only\', but want to add extra slots') }}
</small>
@endslot
</x-form-group>
<x-forms.form-group name="is_editable" :label="__('Editable?')" inline>
<x-forms.radio name="is_editable" value="0" :label="__('No')" inline required />
<x-forms.radio name="is_editable" value="1" :label="__('Yes')" inline required />
<x-slot:help>
{{ __('Choose if you want the booking to be editable (Callsign and Aircraft Code only) by users. This is useful when using \'import only\', but want to add extra slots') }}
</x-slot:help>
</x-forms.form-group>

@if (!$bulk)
<x-form-input name="callsign" :label="__('Callsign')" maxlength="7" />
<x-form-input name="acType" :label="__('Aircraft code')" minlength="3" maxlength="4" />
<x-forms.input name="callsign" :label="__('Callsign')" maxlength="7" />
<x-forms.input name="acType" :label="__('Aircraft code')" minlength="3" maxlength="4" />
@endif

<x-form-select name="dep" :label="__('Departure airport')" :options="$airports"
:placeholder="__('Choose...')" required :default="$event->dep" />
<x-forms.select name="dep" :label="__('Departure airport')" :options="$airports" :placeholder="__('Choose...')" required
:value="$event->dep" />

<x-form-select name="arr" :label="__('Arrival airport')" :options="$airports"
:placeholder="__('Choose...')" required :default="$event->dep" />
<x-forms.select name="arr" :label="__('Arrival airport')" :options="$airports" :placeholder="__('Choose...')" required
:value="$event->dep" />

@if ($bulk)
<x-form-group inline>
<x-form-input name="start" type="time"
:label="'<i class=\'fa fa-clock\'></i> ' . __('Start')">
@slot('append')
<x-forms.form-group inline>
<x-forms.input name="start" type="time" input-group-class="pr-2">
<x-slot:label>
<i class="fa fa-clock"></i> Start
</x-slot:label>
<x-slot:append>
z
@endslot
</x-form-input>
<x-form-input name="end" type="time" :label="'<i class=\'fa fa-clock\'></i> ' . __('End')">
@slot('append')
</x-slot:append>
</x-forms.input>
<x-forms.input name="end" type="time" input-group-class="pr-2">
<x-slot:label>
<i class="fa fa-clock"></i> End
</x-slot:label>
<x-slot:append>
z
@endslot
</x-form-input>
</x-slot:append>
</x-forms.input>

<x-form-input name="separation" type="number" :label="__('Separation (in minutes)')" />
</x-form-group>
<x-forms.input name="separation" type="number" :label="__('Separation (in minutes)')" />
</x-forms.form-group>
@else
<x-form-group inline>
<x-form-input name="ctot" type="time"
:label="'<i class=\'fa fa-clock\'></i> ' . __('CTOT')">
@slot('append')
<x-forms.form-group inline>
<x-forms.input name="ctot" type="time" input-group-class="pr-2">
<x-slot:label>
<i class="fa fa-clock"></i> CTOT
</x-slot:label>
<x-slot:append>
z
@endslot
</x-form-input>
<x-form-input name="eta" type="time" :label="'<i class=\'fa fa-clock\'></i> ' . __('ETA')">
@slot('append')
</x-slot:append>
</x-forms.input>
<x-forms.input name="eta" type="time">
<x-slot:label>
<i class="fa fa-clock"></i> ETA
</x-slot:label>
<x-slot:append>
z
@endslot
</x-form-input>
</x-slot:append>
</x-forms.input>
</x-forms.form-group>

</x-form-group>
<x-forms.textarea name="route" :label="__('Route')" />

<x-form-textarea name="route" :label="__('Route')" />


<x-form-input name="oceanicFL"
:label="$event->is_oceanic_event ? __('Oceanic Entry Level') : __('Cruise FL')">
@slot('prepend')
<x-forms.input name="oceanicFL" :label="$event->is_oceanic_event ? __('Oceanic Entry Level') : __('Cruise FL')">
<x-slot:prepend>
FL
@endslot
</x-form-input>

</x-slot:prepend>
</x-forms.input>
@endif

<x-form-textarea name="notes" :label="__('Notes')" />
<x-forms.textarea name="notes" :label="__('Notes')" />

<x-form-submit>
<x-forms.button type="submit">
@if ($bulk)
<i class="fa fa-plus"></i> {{ __('Add timeslots') }}
@else
<i class="fa fa-plus"></i> {{ __('Add slot') }}
@endif
</x-form-submit>
</x-forms.button>
</x-form>

</div>
</div>
</div>
Expand Down
Loading
Loading