Multiple 'rowsConditionalClasses' entries don't work
PaulMcRoar opened this issue · 1 comments
PaulMcRoar commented
Hi,
If you want, for example, to check a set of statuses for a model and add a css class to the row accordingly, using repeated calls to 'rowsConditionalClasses' doesn't work, and I think it's supposed to.
The addClassesToRow method of HasClasses blitzes the $model->conditionnal_classes array if the closure returns a false value, and will empty the array. I think it should really be merging the $row['classes'] into the $model->conditionnal_classes array
Propose changing to
protected function addClassesToRow(Model $model): void
{
$model->conditionnal_classes = [];
$this->getRowsConditionalClasses()->each(
fn($row) => ($row['closure'])($model) ? $model->conditionnal_classes = array_merge($model->conditionnal_classes,$row['classes']) : null
);
}
I'm going to fork this project and add this in (as i need this working now), and I'll do a pull request.
Okipa commented
Hi @PaulMcRoar, thanks for reporting this !
This has been fixed in #69.