Skip to content

Commit

Permalink
Merge pull request #314 from ECFMP/fix-member-event-filters
Browse files Browse the repository at this point in the history
Fix member event filters
AndyTWF authored Nov 12, 2022
2 parents 0a7b340 + aa2323b commit eff61da
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/Filament/Resources/FlowMeasureResource.php
Original file line number Diff line number Diff line change
@@ -217,7 +217,8 @@ public static function form(Form $form): Form
self::filters($events),
Forms\Components\Fieldset::make('FAO')
->schema([
Forms\Components\BelongsToManyMultiSelect::make('notified_flight_information_regions')
Forms\Components\Select::make('notified_flight_information_regions')
->multiple()
->columnSpan('full')
->required()
->helperText(__('The selected FIRs will receive a tag in discord and be visible in the API'))
Original file line number Diff line number Diff line change
@@ -152,6 +152,12 @@ protected function handleRecordUpdate(Model $record, array $data): Model
$newFlowMeasure->identifier = FlowMeasureIdentifierGenerator::generateIdentifier($newFlowMeasure->start_time, $newFlowMeasure->flightInformationRegion);
$newFlowMeasure->push();

/*
* Because relationships are saved by the Select component for FAO and happen before this point, they
* end up being set for the previous model. Copy the FAO's across to the new model here.
*/
$newFlowMeasure->notifiedFlightInformationRegions()->sync($record->notifiedFlightInformationRegions->pluck('id')->toArray());

$record->delete();

$this->record = $newFlowMeasure;
6 changes: 4 additions & 2 deletions app/Filament/Resources/FlowMeasureResource/Traits/Filters.php
Original file line number Diff line number Diff line change
@@ -137,10 +137,11 @@ public static function filters(Collection $events): Fieldset
Block::make('member_event')
->icon('heroicon-o-calendar')
->schema([
Forms\Components\Select::make('member_event')
Forms\Components\Select::make('value')
->label(__('Event'))
->hintIcon('heroicon-o-calendar')
->hintIcon('heroicon-o-calendar')
->required()
->searchable()
->options(
$events->mapWithKeys(fn (Event $event) => [$event->id => $event->name_date])
@@ -149,10 +150,11 @@ public static function filters(Collection $events): Fieldset
Block::make('member_not_event')
->icon('heroicon-o-calendar')
->schema([
Forms\Components\Select::make('member_not_event')
Forms\Components\Select::make('value')
->hintIcon('heroicon-o-calendar')
->label(__('Event'))
->hintIcon('heroicon-o-calendar')
->required()
->searchable()
->options(
$events->mapWithKeys(fn (Event $event) => [$event->id => $event->name_date])

0 comments on commit eff61da

Please sign in to comment.