inspheric / nova-indicator-field

A colour-coded indicator field for Laravel Nova

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change key => value order around to match Nova defaults

lasseeee opened this issue · comments

commented

The Database field => Display field pairs used in this package should be switched around to match Novas default (used in filters etc.) which is Display field => Database field.

I know what you mean, but what Nova does is completely counterintuitive and actually prevents you from using the same display value for multiple database values. And in our case it would prevent you from using the same colour for multiple database values.

Take a contrived example of how this field currently works:

Indicator::make('Status')
    ->colors([
        'failed' => 'red',
        'inactive' => 'red',
        'success' => 'green',
        'active' => 'green',
    ])

This would be impossible if you switched the order around, because you can see the keys are no longer unique:

Indicator::make('Status')
    ->colors([
        'red' => 'failed',
        'red' => 'inactive',
        'green' => 'success',
        'green' => 'active',
    ])

Apart from the fact that this would be a breaking change, it is also not a good idea. Thanks for the suggestion though and I do appreciate trying to make things consistent! :-)