rainlab / location-plugin

Adds location based features, such as Country and State.
Other
21 stars 44 forks source link

Add enabled/disabled in states #82

Closed LucasZdv closed 3 years ago

LucasZdv commented 3 years ago

Hello, I am pleased to make this small contribution.

screenshot-dev-integrity gotech link-2020 11 20-12_18_36

LucasZdv commented 3 years ago

@LukeTowers Thanks for everything.

I want to add this in the states, any idea how i can it? -

   public function listInjectRowClass($record, $definition = null)
    {
        if (!$record->is_enabled) {
            return 'safe disabled';
        }
    }

This adds a css class to the disabled countries, I want to do the same in the states to make it verbose.

LukeTowers commented 3 years ago

@LucasZdv you'd have to extend the relation view widget and bind into the list.injectRowClass event. Something like

public function relatedExtendViewWidget($widget)
{
    $widget->bindEvent('list.injectRowClass', function ($record) {
        return !$record->is_enabled ? 'safe disabled';
    });
}
LukeTowers commented 3 years ago

@LucasZdv are you still wanting to add the styling to the states lists widget?

LucasZdv commented 3 years ago

@LucasZdv are you still wanting to add the styling to the states lists widget?

Yes, but it hasn't worked for me. Where should I do the extension? I added this to the controller, but not sure where it goes.

LukeTowers commented 3 years ago

In the Country controller. Do some debugging to see if the variables you're getting are what you expect.

LucasZdv commented 3 years ago

Works now! https://github.com/rainlab/location-plugin/pull/82/commits/cde059db97e739bdb9a6e01b7655c9a77fffee10

    public function relationExtendViewWidget($widget)
    {
        $widget->bindEvent('list.injectRowClass', function ($record) {

            if(!$record->is_enabled) {
                return  'safe disabled';
            }
        });
    }

locations

LucasZdv commented 3 years ago

Hello, is it possible to go to master?