From 28f624eaa40b687d24e549f28bd4b312cef0dc00 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Mon, 6 Jun 2022 22:19:37 +0200 Subject: [PATCH 1/3] fix: add utc to labels --- app/Filament/Resources/EventResource.php | 4 ++-- app/Filament/Resources/FlowMeasureResource.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/EventResource.php b/app/Filament/Resources/EventResource.php index b116932a..105bd9f9 100644 --- a/app/Filament/Resources/EventResource.php +++ b/app/Filament/Resources/EventResource.php @@ -61,12 +61,12 @@ public static function form(Form $form): Form ) ->required(), Forms\Components\DateTimePicker::make('date_start') - ->label('Start (UTC)') + ->label('Start [UTC]') ->default(now()->addWeek()->startOfHour()) ->withoutSeconds() ->required(), Forms\Components\DateTimePicker::make('date_end') - ->label('End (UTC)') + ->label('End [UTC]') ->default(now()->addWeek()->addHours(4)->startOfHour()) ->withoutSeconds() ->after('date_start') diff --git a/app/Filament/Resources/FlowMeasureResource.php b/app/Filament/Resources/FlowMeasureResource.php index 4a96fc3e..d41e5323 100644 --- a/app/Filament/Resources/FlowMeasureResource.php +++ b/app/Filament/Resources/FlowMeasureResource.php @@ -104,6 +104,7 @@ public static function form(Form $form): Form }) ->visible(fn (Page $livewire) => !$livewire instanceof CreateRecord), Forms\Components\DateTimePicker::make('start_time') + ->label(__('Start time [UTC]')) ->default(now()->addMinutes(5)) ->withoutSeconds() ->afterOrEqual(now()) @@ -117,6 +118,7 @@ public static function form(Form $form): Form }) ->required(), Forms\Components\DateTimePicker::make('end_time') + ->label(__('End time [UTC]')) ->default(now()->addHours(2)->addMinutes(5)) ->withoutSeconds() ->after('start_time') From 8160d48e1f6a8cc20ead9ed77217b06dd31178b1 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Mon, 6 Jun 2022 22:20:39 +0200 Subject: [PATCH 2/3] fix(FlowMeasureType): change per hour formatted name --- app/Enums/FlowMeasureType.php | 2 +- tests/Discord/FlowMeasure/Field/RestrictionTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Enums/FlowMeasureType.php b/app/Enums/FlowMeasureType.php index 817d2417..106e3b70 100644 --- a/app/Enums/FlowMeasureType.php +++ b/app/Enums/FlowMeasureType.php @@ -20,7 +20,7 @@ public function getFormattedName(): string return match ($this) { self::MINIMUM_DEPARTURE_INTERVAL => 'Minimum Departure Interval [MDI]', self::AVERAGE_DEPARTURE_INTERVAL => 'Average Departure Interval [ADI]', - self::PER_HOUR => 'Per hour', + self::PER_HOUR => 'Rate Per Hour', self::MILES_IN_TRAIL => 'Miles In Trail [MIT]', self::MAX_IAS => 'Max IAS', self::MAX_MACH => 'Max Mach', diff --git a/tests/Discord/FlowMeasure/Field/RestrictionTest.php b/tests/Discord/FlowMeasure/Field/RestrictionTest.php index aa25ac91..7dd94045 100644 --- a/tests/Discord/FlowMeasure/Field/RestrictionTest.php +++ b/tests/Discord/FlowMeasure/Field/RestrictionTest.php @@ -156,7 +156,7 @@ public function testItCanBePerHour() $field = $this->getField($measure); $this->assertEquals( - 'Per hour', + 'Rate Per Hour', $field->name() ); From e1799ff7f0338e02f90fe2694a7b6e3e04e5402b Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Mon, 6 Jun 2022 22:28:55 +0200 Subject: [PATCH 3/3] feat(FlowMeasureResource): always require fir to be selected --- app/Filament/Resources/FlowMeasureResource.php | 7 +++---- .../FlowMeasureResource/Pages/CreateFlowMeasure.php | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Filament/Resources/FlowMeasureResource.php b/app/Filament/Resources/FlowMeasureResource.php index d41e5323..db0dac5c 100644 --- a/app/Filament/Resources/FlowMeasureResource.php +++ b/app/Filament/Resources/FlowMeasureResource.php @@ -65,13 +65,13 @@ public static function form(Form $form): Form ->disabled(fn (Page $livewire) => !$livewire instanceof CreateRecord) ->dehydrated(fn (Page $livewire) => $livewire instanceof CreateRecord) ->visible(fn (Page $livewire) => $livewire instanceof CreateRecord) - ->required(fn (Closure $get) => $get('event_id') == null), + ->required(), Forms\Components\TextInput::make('flight_information_region_name') ->label('Flight Information Region') ->hintIcon('heroicon-o-folder') ->disabled(true) ->dehydrated(false) - ->afterStateHydrated(function (TextInput $component, Closure $get, $state) { + ->afterStateHydrated(function (TextInput $component, Closure $get) { $component->state(FlightInformationRegion::find($get('flight_information_region_id'))?->identifier_name ?? null); }) ->visible(fn (Page $livewire) => !$livewire instanceof CreateRecord), @@ -92,8 +92,7 @@ public static function form(Form $form): Form ->disabled(fn (Page $livewire) => !$livewire instanceof CreateRecord) ->dehydrated(fn (Page $livewire) => $livewire instanceof CreateRecord) ->reactive() - ->visible(fn (Page $livewire) => $livewire instanceof CreateRecord) - ->required(fn (Closure $get) => $get('flight_information_region_id') == null), + ->visible(fn (Page $livewire) => $livewire instanceof CreateRecord), Forms\Components\TextInput::make('event_name') ->label(__('Event')) ->hintIcon('heroicon-o-calendar') diff --git a/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php b/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php index 1b098fee..6093b1ff 100644 --- a/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php +++ b/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php @@ -19,12 +19,7 @@ class CreateFlowMeasure extends CreateRecord protected function mutateFormDataBeforeCreate(array $data): array { - if (!$data['event_id']) { - $fir = FlightInformationRegion::find($data['flight_information_region_id']); - } else { - $fir = Event::find($data['event_id'])->flightInformationRegion; - $data['flight_information_region_id'] ??= $fir->id; - } + $fir = FlightInformationRegion::find($data['flight_information_region_id']); $startTime = Carbon::parse($data['start_time']); $data['identifier'] = FlowMeasureIdentifierGenerator::generateIdentifier($startTime, $fir);