Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added defaultFilters to Livewire Datatables #527

Merged
merged 6 commits into from
Nov 27, 2022

Conversation

Cosnavel
Copy link
Contributor

Added defaultFilters. The defaultFilters should be an Array of column names and the default filter value to use for.
When a persisted filter ($this->persistFilters is true and session values are available) is available, it will override the default filters.

Example Usage:
 
<?php

use App\Models\User;
use Illuminate\Support\Carbon;
use Mediconesystems\LivewireDatatables\BooleanColumn;
use Mediconesystems\LivewireDatatables\Column;
use Mediconesystems\LivewireDatatables\Http\Livewire\LivewireDatatable;
use Mediconesystems\LivewireDatatables\NumberColumn;

class UsersTable extends LivewireDatatable
{
    public $defaultFilters = [
        'deleted_at' => '0',
    ];

    public function builder()
    {
        return User::query()->withTrashed();
    }

    public function columns()
    {
        $columns = [
            NumberColumn::name('ID'),
            BooleanColumn::name('deleted_at')->filterable()->label(__('Deleted')),
        ];

        return $columns;
    }
}

In Action:

CleanShot.2022-11-25.at.3.02.52.mp4

Refs & Closes #78

@Cosnavel
Copy link
Contributor Author

Would love any feedback and review on it 😊

@thyseus
Copy link
Collaborator

thyseus commented Nov 26, 2022

Looks good to me. Could you please add a line to CHANGELOG.md and a small documentation block/example into README.md and i will merge it. And do a new release.

Thanks a lot !

@Cosnavel
Copy link
Contributor Author

@thyseus added some documentation for the Readme. Does this work for you? What do you expect for the Changelog? Currently, there's not much into there 😛

@thyseus thyseus merged commit c13a4d0 into MedicOneSystems:master Nov 27, 2022
@thyseus
Copy link
Collaborator

thyseus commented Nov 27, 2022

Very good. Thanks a lot for your contribution !

@Cosnavel Cosnavel deleted the feature/set-default-filters branch November 27, 2022 12:34
@Cosnavel
Copy link
Contributor Author

@thyseus when do you plan to release the next tag?

@thyseus
Copy link
Collaborator

thyseus commented Nov 27, 2022

https://github.com/MedicOneSystems/livewire-datatables/releases/tag/v0.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: set default values to filters
2 participants