enso-ui / select

Select
MIT License
2 stars 3 forks source link

Bug Search #10

Closed heyner29 closed 5 years ago

heyner29 commented 5 years ago

This is a bug.

Prerequisites

Description

When several $queryAttributes are added, the component does not render them even if the backend responds well. This is my select without search without search

This is my option controller option

Actual behavior

When I perform the search by the supplier.name the component does not report results search

proandin is the name of the supplier

aocneanu commented 5 years ago

This is happening because the frontend filters also the matching options, and your label does not contain the supplier.

I just added a disable-filtering option for the FE component, but it would still be preferrable to add an accessor for this situation in your seller model:

public function getLabelAttribute() {
    return $this->first_name.' '.$this->last_name.' - '.$this->supplier->name;
}

don't forget to add the supplier to the query()

public function query() {
    return Seller::with('supplier');
}

and then set the FE components :label="label".

This will ensure a working filter with option highlighting, won't be awkward for the user when you'll have two similar names on different suppliers and you'll search by name, and will avoid n+1 queries.

heyner29 commented 5 years ago

Yes thank you, a similar approach had been done to achieve it. In addition to your instructions you must use protected $appends = ['fullName', 'label']; in the model. Once again, thank you very much for your help.