Coder Social home page Coder Social logo

dcasia / nova-mega-filter Goto Github PK

View Code? Open in Web Editor NEW
82.0 9.0 17.0 1.32 MB

Allows you to control the columns and filters shown on any Nova resource index

License: MIT License

JavaScript 21.77% Vue 53.66% PHP 24.24% CSS 0.33%
laravel nova filters big-filter friendly-filter

nova-mega-filter's People

Contributors

bocanhcam avatar dependabot[bot] avatar hello-liang-shan avatar keizah7 avatar littlemiaor avatar lorenzosapora avatar milewski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nova-mega-filter's Issues

Computed fields allways appears whether checkbox is checked or is not

Hi,
I have the following problem:

I have a computed field like this:

image

Which its megafilter column is:

image

And whether the checkbox is checked or not, the column is allways visible...

I need that on checked be visible and on unchecked not visible..

Is there anything I'm not doing well, it's a bug or computed fields are allways rendered ( if so, then could be implement a feature that acts like normal attribute ?)

Thanks in advance

When checking columns, filters reset

Steps to reproduce:

    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'settings' => [
                    'columnsWidth' => 'w-1/4',
                    'filtersWidth' => 'w-1/2',
                    'columnsActive' => false,
                    'filtersActive' => true,
                    'actionsActive' => true,
                    'headerLabel' => 'Request Options',
                    'columnsLabel' => 'Columns',
                    'filtersLabel' => 'Filters',
                    'actionsLabel' => 'Actions',
                    'columnsSectionTitle' => 'Add/remove Columns',
                    'filtersSectionTitle' => 'Filters',
                    'actionsSectionTitle' => 'Actions',
                    'columnsResetLinkTitle' => 'Reset Columns',
                    'filtersResetLinkTitle' => 'Reset Filters',

                ],
                'filters' => [
                    (new Filters\GameFilter),
                    (new Filters\Status),
                ],
                'columns' => [
                    Column::make('Game')->checked(),
                    Column::make('Status')->checked(),
                ]
            ])
        ];
    }
  • On resource, use a filter
  • Select a column to show/hide, click
  • Filter resets.

This package and conditional-container in the same class

Can I use those two packages in the same class?
I try to use them and I get the same error as #37

    use HasConditionalContainer;
    use HasMegaFilterTrait;

I try to implement the same workarround, I don't get the error but none of them works.
Is there something that I can do?

Undefined property: Laravel\Nova\ResourceToolElement::$attribute

Hi the card is shown but the index is only loading with this error:

Undefined property: Laravel\Nova\ResourceToolElement::$attribute {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined property: Laravel\Nova\ResourceToolElement::$attribute at C:\laragon\www\invoices\vendor\digital-creative\

All fields is hidden if I add MegaFilter to cards

Hi!

laravel/nova                                     2.12.0
digital-creative/nova-mega-filter                v0.2.8
    use HasMegaFilterTrait;
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'filters' => [
                     // some any filters
                ],
            ]),
        ];
    }

image

Without MegaFilter card all columns is visible.

Actions with showOnTableRow() aren't shown on table row

I have nothing in my filters/actions, they're both moved within MegaFilter. However actions with the method ->showOnTableRow() only appear in the megafilter, and not inline on the row.

This is a relatively new core method. And for the time being, I'm moving my actions back to actions().

Doesn't work:

          'actions' => [
               (new Actions\AcceptKey)->showOnTableRow(),
          ],

Works:

    public function actions(Request $request)
    {
        return [
              (new Actions\AcceptKey)->showOnTableRow(),
        ];
    }

Error: Cannot read property 'concat' of undefined

Hi dcasia
thank you for your great plugin
when using actions if I don't use nova default action the option to select resource rows disappear
and when I click on action button I have below error:

error

Bug: column filtering not working anymore on HasMany relational table

Hi,

I just updated mega-filter to v0.6.0 from v0.2.6 and I realized that column filtering is not working anymore on HasMany relationships table.

An example can be seen here:

This is from version 0.2.6
image

This is from version 0.6.0
image

A you can see from the last image, the scroll is much bigger and it loads all the columns...

Waiting for a feedback.

Thanks in advance!

Undefined array key: 'symbol'

I have this really simple Mega filter to allow toggling of column visibility:
But when loading the page it says: undefined array key "symbol"

It gives that for all table columns, except for "Name" - What could be the reason for this?

<?php

namespace App\Nova;

use Carbon\Carbon;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use DigitalCreative\MegaFilter\MegaFilter;
use Laravel\Nova\Http\Requests\NovaRequest;
use DigitalCreative\MegaFilter\HasMegaFilterTrait;
use DigitalCreative\MegaFilter\Column;
class Post extends Resource
{
    use HasMegaFilterTrait;

    public static $model = \App\Models\Post::class;
    public static $title = 'symbol';
    public static $tableStyle = 'tight';
    public static $showColumnBorders = true;

    public static $search = ['id',
        'symbol',
        'name',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            Text::make('Name')->sortable(),
            Text::make('Symbol')->sortable(),

        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'columns' => [
                    Column::make('Name', 'name'),
                    Column::make('Symbol', 'symbol'),
                ]
            ])
        ];
    }

    /**
     * Get the filters available for the resource.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function filters(Request $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function lenses(Request $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function actions(Request $request)
    {
        return [];
    }
}

Adding width to card breaks megafilter

When adding the nova core method ->width('') to the megafilter, it breaks. This is purely a CSS problem. It adds card-panel to the second div.

It breaks:

  • Dropdowns
  • Alignment
  • Padding
  • Margin

👎

image

With ->width():

<div class="flex flex-wrap -mx-3 mb-3"><div class="px-3 mb-6 w-3/4"><div class="card mega-filter flex flex-col p-6 card-panel" lens="">

Without ->width():

<div class="flex flex-wrap -mx-3 mb-3"><div class="px-3 mb-6 w-full"><div class="card mega-filter flex flex-col p-6" lens="">

Manually removing it, fixes all issues.

I'm trying to think of a way of fixing this, so I can make a PR for it.

[ REQUEST ] Able customize the Index.vue component

Hello.
I need to customize the resource index, to add some different buttons and alter a bit the custom index toolbox.

Since this component is a wrapper component for original Index.vue, I cannot alter the Index.vue to take effect.

So, there's something you can do to enhance the mega filter so we can customize the inner Index.vue ?

Thanks in advance

Checking/Unchecking columns without effect

I just wanted to try out this package and filters works like expected => great! :-)

But I don't get columns running properly. This is my current configuration:

MegaFilter::make(
                [
                    'filters' => [
                        new KnowledgeBaseStatusFilter(),
                        new KnowledgeBaseTagFilter(),
                    ],
                    'columns'=>[
                        Column::make('Status')->checked(),
                        Column::make('Tags')->checked(),
                        Column::make('Created At')->checked(),
                        Column::make('Updated At')->checked(),
                    ]
                ]
            )

Checkboxes for columns do show up. On Checking/Unchecking the list reloads, but there is no visible effect on the columns. Tried Nova 3.4.0 and 3.2.1

Did I miss something?

Fields with closures not attached to Column

I have some purely informational columns, example

Text::make('User Status', function() { return $this->user->status; })

Adding the field name into Column doesn't appear to attach them.

    public function fields(Request $request)
    {
        return [
            Text::make('Status', function () {
                return $this->user->status;
            }),
        ];
    }
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'columns' => [
                    Column::make('Status')->checked(),
                ]
            ])
        ];
    }

Is this a bug, or is it looking for the attribute (i.e. Text::make('Status', 'userStatus'))

Trying to access array offset on value of type null

[2022-03-09 16:39:25] local.ERROR: Trying to access array offset on value of type null {"userId":1,"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /Users/arturas/code/Artme/wil/vendor/digital-creative/nova-mega-filter/src/HasMegaFilterTrait.php:127)
[stacktrace]
#0 /Users/arturas/code/Artme/wil/vendor/digital-creative/nova-mega-filter/src/HasMegaFilterTrait.php(127): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Trying to acces...', '/Users/arturas/...', 127)
#1 /Users/arturas/code/Artme/wil/vendor/digital-creative/nova-mega-filter/src/HasMegaFilterTrait.php(69): App\Nova\User->getFilterState(Object(Laravel\Nova\Http\Requests\ResourceIndexRequest), Object(DigitalCreative\MegaFilter\MegaFilter))
#2 /Users/arturas/code/Artme/wil/nova/src/ResolvesFields.php(32): App\Nova\User->availableFields(Object(Laravel\Nova\Http\Requests\ResourceIndexRequest))

How I can add computed column to Mega columns?

Number::make('Match conversion', fn ($offer) => $offer->match_conversion_percent . '%'),

Column::make('Match conversion', ??????)->checked(),

instead of

Number::make('Match conversion %', 'match_conversion_percent')->sortable(),

Column::make('Match conversion %', 'match_conversion_percent')->checked(),

Bug when using pagination

Steps to reproduce:

  • open filters
  • scroll the the bottom, and click next page
  • on reload, filters will "re-roll" out, over columns
  • height is not changed, so it looks very odd
  • this only happens to filters, and not columns.

Tested on firefox/chromium.

Save columns in session

When i check some columns it shows everything right, bet when i reload resource, those checks are still checked, bet the columns are not shown, you need to uncheck and check again to make it work.

Error when moving between resources

Hello Team,
I having an issue when moving between different resources that have megafilters with different columns.
Is there a way to store the column in the session per resource?

Regards.

Adding the trait breaks belongsTo

Relating possibly to my last issue (#10), adding use DigitalCreative\MegaFilter\Column; and removing use HasMegaFilterTrait; in the class, solves the issue.

I'll investigate after work.

Nova trying to import wrong Column

Nova: 2.9.3
Laravel: 5.8.*


Adding your package to a resource

<?php

namespace App\Nova;
[...]
use DigitalCreative\MegaFilter\MegaFilter;
use DigitalCreative\MegaFilter\HasMegaFilterTrait;

class User extends Resource
{
    use HasMegaFilterTrait;
[...]
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'filters' => [
                    (new RankFilter),
                    (new Statusfilter),
                ],
                'columns' => [
                    Column::make('Customer Name', 'user'),
                ]
            ])
        ];
    }

Nova throws an error saying it cannot find App\Nova\Column.

I feel like I'm missing something..

Temporary fix:

Adding use DigitalCreative\MegaFilter\Column;

Error, when reloading the page

Thank you for this great nova tool, but I found an error:

When you select (or deselect) any of the columns and the url gets updated to, for example

l/nova/resources/articles?articles_page=3&mega_filter=eyJwb3J0YWxfYmVyZWljaCI6dHJ1ZSwicGFyZW50Ijp0cnVlfQ%3D%3D

and you then reload the page (CTRL+R or hit the browser button) the list will not load and you get the following error:

image

Checkboxes of columns are "remembered" when I navigate back to list, but wrong columns are shown

I have many columns in list, and of them some are checked/displayed by default. I check/uncheck some checkboxes of columns, navigate to another resource, and then I navigate back to resource with MegaFilter (not using back button in browser, but simply clicking on resource link in Nova menu). Checkboxes of columns are "remembered", but default columns are being shown then , and that's wrong. How can I fix that?

`public function cards(Request $request)
{
return [
MegaFilter::make([
'filters' => [
new Filters\LegalStatusFilter(),
new Filters\ClientTypeFilter(),
new Filters\AccountingAppFilter(),
new Filters\UsersFilterForClients(),
new Filters\ClientSignedContractAt(),
new Filters\ClientTerminatedContractAt(),
],
'columns' => [
Column::make(('Pavadinimas'), 'title')->checked(),
Column::make(
('Telefonas'), 'telephone'),
Column::make(('Pagrindinis el. paštas'), 'email'),
Column::make(
('Įmonės kodas'), 'company_code'),
Column::make(('Draudėjo kodas'), 'insurer_code'),
Column::make(
('Duombazė'), 'database'),
Column::make(('Sutarties pasirašymo data'), 'contract_signed_at'),
Column::make(
('Sutarties nutraukimo data'), 'contract_terminated_at'),
Column::make(('PVM mokėtojo kodas'), 'vat_code'),
Column::make(
('Tipas'), 'client_types_string'),
Column::make(__('Buhalteris'), 'accountants'),
],
'settings' => [
'columnsLabel' => __('Kolonos'),
'filtersLabel' => __('Filtrai'),
'actionsLabel' => __('Veiksmai'),
'columnsSectionTitle' => __('Papildomos kolonos'),
'filtersSectionTitle' => __('Filtrai'),
'actionsSectionTitle' => __('Veiksmai'),
'columnsResetLinkTitle' => __('Nustatyti standartines kolonas'),
'filtersResetLinkTitle' => __('Nustatyti standartines filtrų reikšmes'),

            ],
        ])
    ];
}`

[Question] How to apply the same filter twice?

Hey man, great work.

I only have one question: How to apply the same filter twice?

Let's say I have a post model that has categories, for example:

  • First post with categories: laravel, php
  • Second post with categories: laravel, php, javascript
  • Third post with categories: laravel, php, vuejs
  • Fourth post with categories: tailwind, css

What I need to do is a filter that shows me the posts that contain the laravel category (it shows me three) but I also want to re-filter the results with the posts that contain both the laravel and javascript categories (it shows me one).

Feature: column counter

Visually, when the filter is closed, it's not immediately obvious that columns are unchecked/checked. Especially with the 'saved' status in vue, clicking on another resource, then coming back, an end-user might assume something's wrong, or be unaware they have column filters active.

I'll add this to the list of things I want to work on, so expect a PR at some point in the future. Of course, some pointers would always be helpful if you know how you'd do that in your code base at the moment :)

Feature request: Add id's to the html

Could you please add classes or ID's to the html code of the vue component? Something like:

<template>
    <card class="flex flex-col p-6" @dblclick.native.self="toggleAllSections" id="nova-mega-filter">
    ....

The reason why I am asking: I wanna change the style of it to look like this:

image

image

And this is much easer, when I can write my css vs an exact id or css class like

#nova-mega-filter {
    ....
}

and don't have to write hacks like

[component="index-view"] >div >div >div {
    ....
}

Custom Field not showing

Hello. First of all thanks for this packge, it is very useful.

I have the following problem: previously, before apply the mega filter, I had a field which is a Nova Button field (https://github.com/dillingham/nova-button) that allows to render a button like a custom field. However when I have to apply the mega filter, the button does not show anymore.

Is it possible make something to show again the button field in junction with mega filter?

Thanks in advance.

Megafilter doesn't work on lenses

When used in a lens, the refresh moves the url back to the base resource.

Steps to reproduce:

  • Create user lens
  • Add lens to user resource
  • Add MegaFilter to lens
  • Attempt to check/uncheck any column
  • Router moves to original resource (i.e. resources/users/ from resources/users/lens/user-verification)

How to hide card headers?

Case: only filters are displayed and there is no need to show these headers and buttons.

They take up a lot of screen space.

image

Feature: filter groups

This is a feature requested in nova core at the moment. But as we're not using the filters(), it wouldn't matter anyway.

It would be nice to have the ability to separate filters into groups, especially when dealing with large filter lists.

I wouldn't know where to start on something like this, but I'm happy to help, if you'd think this would be a good feature for this repo.

index view not loading on nova 2.9.2

Thanks again for your greate packages - took me some time to resolve an issue, where the index view (and filters) just stays on loading / empty without any warning, check out:

laravel/nova-issues#2228

Am not sure if this a generic issue with nova 2.9.2 or some cross incompatibility with other packages

Filter not working in user resource

image

    public function cards(Request $request)
    {
        return [
            (new Metrics\UserApplications)->onlyOnDetail(),

            MegaFilter::make([
                'filters' => [
                    new SkillFilter,
                    new FieldOfWorkFilter,
                    new ResidenceCountryFilter,
                    new LanguageFilter,
                    new LanguageLevelFilter,
                    new EducationFilter,
                    new ContractTypeFilter,
                    new SeniorityFilter,
                    new RatingFilter,
                    new CheckFilter,
                ],
                'columns' => [
                    Column::make('Title')->checked(),
                    Column::make('Residence country', 'residence')->checked(),
                    Column::make('Nationality')->checked(),
                    Column::make('Newsletter')->checked(false),
                    Column::make('Share data')->checked(),
                    Column::make('Rating', 'rating')->checked(false),
                    Column::make('Profile completed rate', 'cv_completion')->checked(),
                    Column::make('Applies', 'applies_count')->checked(),
                    Column::make('User activities', 'authentications_count')->checked(),
                    Column::make('Matched', 'matched_offers_count'),
                    Column::make('Registered At', 'created_at')->checked(),
                    Column::make('Updated At')->checked(false),
                    Column::make('Rating')->checked(false),
                ],
                'settings' => [
                    'filtersWidth' => 'w-1/3',
                    'filtersActive' => false,
                    'headerLabel' => '',
                ],
            ])
        ];
    }

[Suggestion] option to save the columns settings

Hello, this package is awesome, if you could add more options to be like the WordPress "screen options" so we can toggle any columns we need and the settings will be saved until we need to change them again this will be very cool.

Undefined in the url string

I see ?undefined=1 in the url string, but can't seem to find what that refers to. Changing it does nothing.

Feature: save filters, as well as columns

I don't think this should be a default option, but something thrown into settings, as clearing filters every time isn't optimal. But, there are use-cases for such a feature. I'd love to hear your thoughts on the matter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.