nova-button icon indicating copy to clipboard operation
nova-button copied to clipboard

FR: Prompt option similar to action fields

Open FrittenKeeZ opened this issue 6 years ago • 6 comments

Like the native javascript prompt, it would be awesome to have this option, where you can supply any fields in a callback like action fields. If no callback is defined (or empty), a default text field should be provided.

Button::make('Cancel Account')
    ->prompt('Are you sure?', 'Please write CANCEL below to confirm', function () {
        return [
            Text::make('Confirm')->rules('required', 'in:CANCEL'),
            Text::make('Reason'),
        ];
    }),

FrittenKeeZ avatar Feb 22 '19 10:02 FrittenKeeZ

Personally i think this would be waaay better:

Button::make('Cancel Account')
    ->ask('Are you sure?')
    ->cancel('Nope')
    ->confirm('Yes i do!')
    ->addFields(function() {
        return [
            Text::make('Reason'),
        ];
    }),

niladam avatar Feb 22 '19 11:02 niladam

Nice idea! Yeah I can definitely see the usefulness of being able to add fields for the button. It is almost like actions in that ability.

I was planning on adding action support to this package and this may overlap and provide identical functionality.

Button::make(‘Text’)->action(ActionWithFields::class),

I’m going to think on this a bit But thank you for pitching the idea :)

dillingham avatar Feb 22 '19 12:02 dillingham

My problem with this is that vue portal is used in nova for each index row to render delete modals. Adding all this markup per row of a table seems irresponsible lol 25 rows with 25 action modals with 5 fields and of course not just text fields turns into ALOT

dillingham avatar Apr 17 '19 03:04 dillingham

its a serious problem then

SerjoA avatar Apr 17 '19 03:04 SerjoA

@dillingham

It's not possible to execute the action with javascript trigger ?

  • Uncheck all checkbox
  • Check the checkbox of that row
  • Select the action and launch him ?

YannikFirre avatar Jul 01 '19 09:07 YannikFirre

Button triggering an action would be useful on the Detail page as well.

There would be no "flooding the markup" problem on the detail page.

Maybe that could be implemented first? 🙏

scottgrayson avatar Apr 29 '20 18:04 scottgrayson