angauber / nova-select2-filter

A laravel nova filter that implements jquery select2
MIT License
4 stars 0 forks source link

Incorrect styling and filtering not triggered on selection #2

Closed sijones-uk closed 4 years ago

sijones-uk commented 4 years ago

Laravel: v6.4.0 Nova: v2.5.0 nova-select2-filter: v1.0.0

The styling of the select2 box doesn't look like the styling in the README:

image

Selecting an item from the list doesn't result in the filtering being triggered. However, after selecting an item and then clicking the × to delete it, the list is then filtered based on the item that was deleted.

image

This is my filter:

<?php

namespace App\Nova\Filters;

use Illuminate\Http\Request;
use Angauber\NovaSelect2Filter\NovaSelect2Filter;

class UserRoles extends NovaSelect2Filter
{
    public $component = 'nova-select2-filter';

    public function apply(Request $request, $query, $value) {
        return $query->role($value);
    }

    public function options(Request $request) {
        return [
            1 => 'Administrator',
            2 => 'Diagnostics',
            3 => 'Crash Reporter',
            4 => 'Employee',
            5 => 'Vendor Partner',
            6 => 'Contractor',
            7 => 'PA',
        ];
    }

    public function config() : array {
        return [
            'config' => [
                'multiple' => true,
                'allowClear' => true,
                'placeholder' => 'Choose an option',
            ],
        ];
    }
}
angauber commented 4 years ago

Hello, Did you recently update your nova version ? If so, have you rebuild your assets ?

https://nova.laravel.com/docs/2.0/installation.html#updating-nova-s-assets

I am currently using nova v.2.1.0 but It should work with 2.5.0, maybe try do manually delete your vendor folder and run composer install

sijones-uk commented 4 years ago

Yes, I rebuilt the Nova assets. I've also tried it on a fresh Laravel installation and got the same result.

angauber commented 4 years ago

That's interesting. do you have any errors in your logs ? Also what does the role method refers to in your apply method ? the $query variable is an instance of Illuminate\Database\Eloquent\Builder which does not have such method. did you try to only return the query in the apply method ?

angauber commented 4 years ago

@sijones-uk This issue was due to a styling issue that have been fixed in v1.1.0