Muetze42 / nova-radio-field

A Radio Buttons field for Laravel Nova.
https://novapackages.com/packages/norman-huth/nova-radio-field
MIT License
5 stars 2 forks source link

When used in action, the radio field is displayed as Select #16

Closed wamesro closed 1 year ago

wamesro commented 1 year ago

laravel/nova: 4.24.3 norman-huth/nova-radio-field: 1.1.6

When used in action, the radio field is displayed as Select Snímka obrazovky 2023-05-19 o 15 06 41

Muetze42 commented 1 year ago

https://github.com/Muetze42/nova-radio-field/releases

wamesro commented 1 year ago

It still doesn't work. Is there a proven procedure?

Muetze42 commented 1 year ago

Have You installed the current Version?

Action Code:
https://github.com/Muetze42/laravel-nova-demo-app/blob/main/app/Nova/Actions/RadioAction.php

Action on index: https://nova-demo.huth.it/resources/nova-radio-field-radios

Action on detail: https://nova-demo.huth.it/resources/nova-radio-field-radios/1

wamesro commented 1 year ago

I have already discovered the problem

This is how it works

public function actions(NovaRequest $request): array
{
    return [
        new ProductVariantExpedition()
    ];
}

and when using Inline Actions it shows as Select https://nova.laravel.com/docs/4.0/actions/registering-actions.html#inline-actions

public function actions(NovaRequest $request): array
{
    return [
        (new ProductVariantExpedition())->showInline()
    ];
}
Muetze42 commented 1 year ago

Strange. For me it also works with showInline()

Can you test what happens when you add this method to the package file src/Radio.php ?

class Radio extends Select
{
    // ...

    protected function isAction(): bool
    {
        if (!isset($this->isAction)) {
            $this->isAction = str_ends_with($this->getRequest()->path(), '/actions') || str_ends_with($this->getRequest()->path(), 'nova-api/nova-radio-field-radios');
        }

        return $this->isAction;
    }

    // ...
}
wamesro commented 1 year ago

It only works for bulk actions after checking the checkbox on the left, but after clicking on the 3 dots it is still Select

It works the same way in your demo https://nova-demo.huth.it/resources/nova-radio-field-radios

https://github.com/Muetze42/nova-radio-field/assets/5340873/c2662187-6682-41f4-928d-ac413776479a

Muetze42 commented 1 year ago

Ah. I see. The action path is not used there at all.

I'll have to think of something else. I guess I'll have to rewrite it so that the select is not used for detail & index.

But will be something only tonight.

wamesro commented 1 year ago

Alright, good luck ;-) but it's a great package

Muetze42 commented 1 year ago

I was surprised that there is no radio field. Then I thought to myself, that is quickly done. But first that with dependsOn, then with the filters. If I had known that before. 😂

https://github.com/Muetze42/nova-radio-field/releases

wamesro commented 1 year ago

Great, now it works in action as well