Skip to content

Commit

Permalink
Merge pull request #83 from ECFMP/flowmeasure-ui
Browse files Browse the repository at this point in the history
Flowmeasure UI improvements
  • Loading branch information
AndyTWF authored Jun 10, 2022
2 parents 9ee4b08 + e1799ff commit b16d840
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Enums/FlowMeasureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
9 changes: 5 additions & 4 deletions app/Filament/Resources/FlowMeasureResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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')
Expand All @@ -104,6 +103,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())
Expand All @@ -117,6 +117,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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Discord/FlowMeasure/Field/RestrictionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testItCanBePerHour()
$field = $this->getField($measure);

$this->assertEquals(
'Per hour',
'Rate Per Hour',
$field->name()
);

Expand Down

0 comments on commit b16d840

Please sign in to comment.