Skip to content

Commit

Permalink
Merge pull request #59 from lara-zeus/filters
Browse files Browse the repository at this point in the history
Filters
  • Loading branch information
atmonshi authored Jun 13, 2023
2 parents 8bb2ec0 + 642cced commit c008198
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 70 deletions.
12 changes: 9 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
indent_size = 2

[*.json]
indent_size = 4

[docker-compose.yml]
indent_size = 4
24 changes: 5 additions & 19 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/public/storage
/storage/*.key
/vendor
/build
/vendor/.idea
/bootstrap/cache
.env
.env.backup
.phpunit.result.cache
Expand All @@ -12,4 +13,8 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/database/database.sqlite
/.idea
/.vscode
/pkg
/build
.DS_Store
4 changes: 0 additions & 4 deletions .styleci.yml

This file was deleted.

59 changes: 29 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions src/Filament/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Str;
use LaraZeus\Bolt\Filament\Resources\CategoryResource\Pages\CreateCategory;
use LaraZeus\Bolt\Filament\Resources\CategoryResource\Pages\EditCategory;
Expand Down Expand Up @@ -75,12 +77,23 @@ public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('logo')->disk(config('zeus-bolt.uploads.disk', 'public'))->label(__('Logo')),
TextColumn::make('name')->label(__('Name'))->sortable()->searchable(),
TextColumn::make('description')->label(__('Description')),
ImageColumn::make('logo')
->disk(config('zeus-bolt.uploads.disk', 'public'))
->toggleable()
->label(__('Logo')),
TextColumn::make('name')
->label(__('Name'))
->sortable()
->toggleable()
->searchable(),
TextColumn::make('description')
->label(__('Description'))
->toggleable()
->searchable(),
IconColumn::make('is_active')
->boolean()
->sortable()
->toggleable()
->label(__('Is Active')),
])
->reorderable('ordering')
Expand All @@ -91,6 +104,16 @@ public static function table(Table $table): Table
DeleteAction::make(),
]),
])
->filters([
Filter::make('is_active')
->label(__('is active'))
->toggle()
->query(fn (Builder $query): Builder => $query->where('is_active', true)),
Filter::make('not_active')
->label(__('not active'))
->toggle()
->query(fn (Builder $query): Builder => $query->where('is_active', false)),
])
->bulkActions([
DeleteBulkAction::make(),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->label(__('Collections Name'))->searchable(),
TextColumn::make('values-list')->html()->label(__('Collections Values'))->searchable(['values']),
TextColumn::make('name')->label(__('Collections Name'))->searchable()->sortable()->toggleable(),
TextColumn::make('values-list')->html()->label(__('Collections Values'))->searchable(['values'])->sortable()->toggleable(),
])
->actions([
ActionGroup::make([
Expand Down
13 changes: 11 additions & 2 deletions src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Database\Eloquent\Builder;
use LaraZeus\Bolt\Filament\Resources\FormResource\Pages;
use LaraZeus\Bolt\Filament\Resources\FormResource\Schemata;
Expand Down Expand Up @@ -71,7 +72,7 @@ public static function table(Table $table): Table
return $table
->columns([
TextColumn::make('name')->searchable()->sortable()->label(__('Form Name'))->toggleable(),
TextColumn::make('category.name')->label(__('Category'))->sortable()->toggleable(),
TextColumn::make('category.name')->searchable()->label(__('Category'))->sortable()->toggleable(),
IconColumn::make('is_active')->boolean()->label(__('Is Active'))->sortable()->toggleable(),
TextColumn::make('start_date')->dateTime()->searchable()->sortable()->label(__('Start Date'))->toggleable(),
TextColumn::make('end_date')->dateTime()->searchable()->sortable()->label(__('End Date'))->toggleable(),
Expand All @@ -95,7 +96,6 @@ public static function table(Table $table): Table
->tooltip(__('view form'))
->url(fn (ZeusForm $record): string => route('bolt.form.show', $record))
->openUrlInNewTab(),

ReplicateAction::make()
->label(__('Replicate'))
->excludeAttributes(['name', 'slug'])
Expand Down Expand Up @@ -124,6 +124,15 @@ public static function table(Table $table): Table
->toggle()
->query(fn (Builder $query): Builder => $query->where('is_active', true))
->label(__('Is Active')),

Filter::make('not_active')
->toggle()
->query(fn (Builder $query): Builder => $query->where('is_active', false))
->label(__('Inactive')),

SelectFilter::make('category_id')
->options(config('zeus-bolt.models.Category')::pluck('name', 'id'))
->label(__('Category')),
]);
}

Expand Down
8 changes: 7 additions & 1 deletion src/Filament/Resources/ResponseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use LaraZeus\Bolt\Filament\Resources\ResponseResource\Pages;
use LaraZeus\Bolt\Models\FormsStatus;

class ResponseResource extends BoltResource
{
Expand Down Expand Up @@ -99,7 +100,12 @@ public static function table(Table $table): Table
])
->defaultSort('created_at', 'description')
->filters([
SelectFilter::make('form')->relationship('form', 'name')->default(request('form_id', null)),
SelectFilter::make('status')
->options(FormsStatus::query()->pluck('label', 'key'))
->label(__('Status')),
SelectFilter::make('form')
->relationship('form', 'name')
->default(request('form_id', null)),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ protected function getTableFilters(): array
SelectFilter::make('form')
->relationship('form', 'name')
->default($this->form_id),
SelectFilter::make('status')
->options(FormsStatus::query()->pluck('label', 'key'))
->label(__('Status')),
];
}

Expand Down
Loading

0 comments on commit c008198

Please sign in to comment.