Skip to content

Commit

Permalink
Merge pull request #100 from bcgov/dev
Browse files Browse the repository at this point in the history
Merge Dev into Main
  • Loading branch information
brysonjbest authored Feb 4, 2025
2 parents 3f99ba9 + 201f13a commit 824e389
Show file tree
Hide file tree
Showing 15 changed files with 948 additions and 22 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ sail artisan permissions:sync
```

### Enable Local Exports

Certain views offer the ability to export a list of entries in the form of a CSV or Excel File. To enable this in local development run

```
sail artisan queue:work
```

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
Expand Down
162 changes: 148 additions & 14 deletions app/Filament/Bre/Resources/FieldResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use App\Models\BREDataValidation;
use App\Models\BREField;
use App\Models\ICMCDWField;
use App\Models\SiebelBusinessObject;
use App\Filament\Fodig\Resources\SiebelBusinessObjectResource;
use App\Filament\Fodig\Resources\SiebelBusinessComponentResource;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Infolists\Infolist;
Expand All @@ -19,6 +22,10 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\HtmlString;
use App\Filament\Exports\BREFieldExporter;
use Filament\Tables\Actions\ExportAction;
use Filament\Actions\Exports\Models\Export;
use Filament\Support\Colors\Color;

class FieldResource extends Resource
{
Expand All @@ -40,8 +47,6 @@ private static function formatBadge(string $url, string $text): string
return sprintf(static::$badgeTemplate, $url, e($text));
}

// protected static ?string $navigationGroup = 'Rule Building';

public static function form(Form $form): Form
{
$dataTypeIdsForChildFields = BREDataType::where('name', 'LIKE', '%array%')
Expand All @@ -59,7 +64,7 @@ public static function form(Form $form): Form
Forms\Components\Select::make('data_type_id')
->relationship('breDataType', 'name')
->required()
->reactive() // This makes the field listen for changes
->reactive()
->afterStateUpdated(function (callable $set) {
$set('child_fields', null);
}),
Expand Down Expand Up @@ -91,7 +96,25 @@ public static function form(Form $form): Form
modifyQueryUsing: fn(Builder $query) => $query->orderBy('name')->orderBy('field')->orderBy('panel_type')->orderBy('entity')->orderBy('subject_area')
)
->getOptionLabelFromRecordUsing(fn(Model $record) => "{$record->name} - {$record->field} - {$record->panel_type} - {$record->entity} - {$record->subject_area}")
->searchable(['name', 'field', 'panel_type', 'entity', 'subject_area'])
->searchable(['name', 'field', 'panel_type', 'entity', 'subject_area']),
Forms\Components\Select::make('siebelBusinessObjectField')
->label('Related Siebel Business Objects:')
->multiple()
->relationship(
name: 'siebelBusinessObjects',
modifyQueryUsing: fn(Builder $query) => $query->orderBy('name')
)
->getOptionLabelFromRecordUsing(fn(Model $record) => "{$record->name}")
->searchable(['name', 'repository_name', 'comments']),
Forms\Components\Select::make('siebelBusinessComponentField')
->label('Related Siebel Business Components:')
->multiple()
->relationship(
name: 'siebelBusinessComponents',
modifyQueryUsing: fn(Builder $query) => $query->orderBy('name')
)
->getOptionLabelFromRecordUsing(fn(Model $record) => "{$record->name}")
->searchable(['name', 'repository_name', 'comments'])
]);
}

Expand Down Expand Up @@ -119,6 +142,19 @@ public static function infolist(Infolist $infolist): Infolist
})
->html()
->label('Data Validation'),
TextEntry::make('childFields')
->label('Child Rule Fields')
->formatStateUsing(function ($state, $record) {
return new HtmlString(
$record->childFields->map(function ($field) {
return static::formatBadge(
static::getUrl('view', ['record' => $field->name]),
$field->name
);
})->join('')
);
})
->html(),
TextEntry::make('breFieldGroups.name')
->label('Field Groups'),
TextEntry::make('description')
Expand Down Expand Up @@ -163,6 +199,32 @@ public static function infolist(Infolist $infolist): Infolist
->html()
->label('Related ICM CDW Fields')
->columnSpanFull(),
TextEntry::make('siebelBusinessObjects.name')
->formatStateUsing(function ($state, $record) {
return new HtmlString(
$record->siebelBusinessObjects->map(function ($field) {
return static::formatBadge(
"/fodig/siebel-business-objects/{$field->id}",
$field->name
);
})->join('')
);
})
->html()
->label('Related Siebel Business Objects'),
TextEntry::make('siebelBusinessComponents.name')
->formatStateUsing(function ($state, $record) {
return new HtmlString(
$record->siebelBusinessComponents->map(function ($field) {
return static::formatBadge(
"/fodig/siebel-business-components/{$field->id}",
$field->name
);
})->join('')
);
})
->html()
->label('Related Siebel Business Components')
]);
}

Expand All @@ -189,14 +251,11 @@ public static function table(Table $table): Table
->label('Data Validations')
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('childFields')
->label('Child Fields')
->formatStateUsing(function ($record) {
if ($record->childFields && $record->childFields->isNotEmpty()) {
return $record->childFields->pluck('name')->join(', ');
}
return '';
})
Tables\Columns\TextColumn::make('childFields.name')
->label('Child Rule Fields')
->badge()
->color('success')
->searchable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('fieldGroupNames')
->label('Field Groups')
Expand All @@ -206,19 +265,42 @@ public static function table(Table $table): Table
->default(function ($record) {
return $record->getInputOutputType();
})
->badge()
->color(fn(string $state): string => match ($state) {
'input' => 'primary',
'output' => 'danger',
'input/output' => 'warning',
})
->toggleable(isToggledHiddenByDefault: false),
Tables\Columns\TextColumn::make('breInputs.name')
->label('Rules: Inputs')
->searchable()
->badge()
->color('primary')
->toggleable(isToggledHiddenByDefault: false),
Tables\Columns\TextColumn::make('breOutputs.name')
->label('Rules: Outputs')
->searchable()
->badge()
->color('danger')
->toggleable(isToggledHiddenByDefault: false),
Tables\Columns\TextColumn::make('icmcdwFields.name')
->label('Related ICM CDW Fields')
->sortable()
->searchable()
->badge()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('siebelBusinessObjects.name')
->label('Related Siebel Business Objects')
->searchable()
->badge()
->color(Color::hex('#E9C46A'))
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('siebelBusinessComponents.name')
->label('Related Siebel Business Components')
->searchable()
->badge()
->color(Color::hex('#397367'))
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
Expand All @@ -229,7 +311,8 @@ public static function table(Table $table): Table
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('name')
// disabled to enable exports
// ->defaultSort('name')
->filters([
Tables\Filters\SelectFilter::make('data_type_id')
->label('Data Type')
Expand Down Expand Up @@ -302,12 +385,63 @@ public static function table(Table $table): Table
->preload()
->attribute(('icmcdwFields.name'))
->relationship('icmcdwFields', 'name'),
//
Tables\Filters\SelectFilter::make('siebel_business_objects')
->label('Related Siebel Business Objects:')
->multiple()
->searchable()
->preload()
->attribute(('siebelBusinessObjects.name'))
->relationship('siebelBusinessObjects', 'name'),
Tables\Filters\SelectFilter::make('siebel_business_components')
->label('Related Siebel Business Components:')
->multiple()
->searchable()
->preload()
->attribute(('siebelBusinessComponents.name'))
->relationship('siebelBusinessComponents', 'name'),
Tables\Filters\SelectFilter::make('siebel_business_objects_existence')
->label('Siebel Business Objects Status')
->options([
'with' => 'Has Siebel Business Objects',
'without' => 'No Siebel Business Objects',
])
->query(function (Builder $query, array $data) {
if (empty($data['value'])) {
return $query;
}
return match ($data['value']) {
'with' => $query->whereHas('siebelBusinessObjects'),
'without' => $query->whereDoesntHave('siebelBusinessObjects'),
default => $query,
};
}),
Tables\Filters\SelectFilter::make('siebel_business_components_existence')
->label('Siebel Business Components Status')
->options([
'with' => 'Has Siebel Business Components',
'without' => 'No Siebel Business Components',
])
->query(function (Builder $query, array $data) {
if (empty($data['value'])) {
return $query;
}
return match ($data['value']) {
'with' => $query->whereHas('siebelBusinessComponents'),
'without' => $query->whereDoesntHave('siebelBusinessComponents'),
default => $query,
};
}),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->headerActions([
ExportAction::make()
->label('Export BRE Rule Fields')
->exporter(BREFieldExporter::class)
->fileName(fn(Export $export): string => "BRE-Rule-Fields-{$export->getKey()}"),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Expand Down
Loading

0 comments on commit 824e389

Please sign in to comment.