dcasia / nova-mega-filter Goto Github PK
View Code? Open in Web Editor NEWAllows you to control the columns and filters shown on any Nova resource index
License: MIT License
Allows you to control the columns and filters shown on any Nova resource index
License: MIT License
Hi,
I have the following problem:
I have a computed field like this:
Which its megafilter column is:
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
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(),
]
])
];
}
For example: full
for very big filter and 1/3
for small filters.
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?
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\
I want to make my column field red/green/etc. Or maybe some HTML support.
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(),
];
}
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:
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!
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 [];
}
}
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:
👎
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.
Hi,
Please add support for Nova 4.
Regards
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
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?
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')
)
[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))
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(),
Steps to reproduce:
Tested on firefox/chromium.
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.
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.
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: 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..
Adding use DigitalCreative\MegaFilter\Column;
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:
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'),
],
])
];
}`
Hi, dcasia:
First of all, thanks for your plugin.
When I install it in my nova backend system, I got an error about array_merge_recursive_distinct
function does not exist.
Nova version: 2.7.1
PHP version: 7.2.17
and I try to search this function on https://php.net, the URL is array_merge_recursive_distinct
Here is the error screenshot:
l want like there is an input box, which binded to a field in the table, when I input a value, it filters out the value in the table.
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:
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).
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 :)
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:
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 {
....
}
Clicking filter sometimes requires two clicks, with a refresh in-between
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.
Trait method 'availableFields' will not be applied, because it collides with 'HasResourceNavigationTabTrait'
use HasResourceNavigationTabTrait;
use HasMegaFilterTrait;
When used in a lens, the refresh moves the url back to the base resource.
Steps to reproduce:
resources/users/
from resources/users/lens/user-verification
)If resource firstly loaded Mega filter column doesn't apply, but if change any column all work...
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.
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:
Am not sure if this a generic issue with nova 2.9.2 or some cross incompatibility with other packages
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' => '',
],
])
];
}
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.
I see ?undefined=1
in the url string, but can't seem to find what that refers to. Changing it does nothing.
I think I can see it flicker on when I refresh the page, but it's so brief, it's hard to tell.
Using dummy data and called from the database.
Sparkline::make('Trend')->data('0,0,0,0,1,0,0,0,0')
.
It reappears whenever a column is removed.
Because I don't want to see value, I want to see relation title. Please support it :)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.