GithubHelp home page GithubHelp logo

dillingham / nova-button Goto Github PK

View Code? Open in Web Editor NEW
265.0 5.0 33.0 1.14 MB

Add buttons on Nova index, detail and lens views.

License: MIT License

Vue 39.02% JavaScript 5.78% PHP 55.21%
laravel laravel-nova laravel-nova-field

nova-button's Introduction

Nova Button

Thanks for everyone who used this package and contributed.

I haven't used Nova in many years so I'm unable to maintain this.

I'm so glad to see active forks though!


Latest Version on Github Total Downloads Twitter Follow

Nova package for rendering buttons on index, detail and lens views.

Use buttons to trigger backend events, navigate nova routes or visit links.

nova-button

Installation

composer require dillingham/nova-button

Usage

use NovaButton\Button;
public function fields(Request $request)
{
    return [
        ID::make('ID', 'id')->sortable(),
        Text::make('Name', 'name'),
        Button::make('Notify'),
    ];
}

Quick links: Button Styles | Event text / style | Navigation | CSS classes | Lens example


Backend events

By default, clicking the button will trigger a backend event via ajax.

Default event: NovaButton\Events\ButtonClick

The event will receive the resource model it was triggered from & the key

  • $event->resource = model
  • $event->key = "notify"

Adding a custom key

Button::make('Notify', 'notify-some-user')

Adding a custom event

Button::make('Notify')->event('App\Events\NotifyRequested')

You register listeners in your EventServiceProvider

Nova Routes

You can also choose to navigate any of the Nova routes

Button::make('Text')->route('vuejs-route-name', ['id' => 1])
Button::make('Text')->index('App\Nova\User')
Button::make('Text')->detail('App\Nova\User', $this->user_id)
Button::make('Text')->create('App\Nova\User')
Button::make('Text')->edit('App\Nova\User', $this->user_id)
Button::make('Text')->lens('App\Nova\User', 'users-without-confirmation')

You can also enable a resource's filters

Button::make('Text')->index('App\Nova\Order')->withFilters([
    'App\Nova\Filters\UserOrders' => $this->user_id,
    'App\Nova\Filters\OrderStatus' => 'active',
])

Links

Button::make('Text')->link('https://nova.laravel.com')
Button::make('Text')->link('https://nova.laravel.com', '_self')

Visiblity

You will likely want to show or hide buttons depending on model values

Button::make('Activate')->visible($this->is_active == false),
Button::make('Deactivate')->visible($this->is_active == true),

Also field authorization via canSee() & showing / hiding fields hideFromIndex(), etc

Reload

After events are triggered, reload the page.

Button::make('Notify')->reload()

If you click many buttons, reloading will wait for all buttons to finish.

If an error occurs, it will not reload the page.

Confirm

You can require a confirmation for descructive actions

Button::make('Cancel Account')->confirm('Are you sure?'),
Button::make('Cancel Account')->confirm('title', 'content'),

Button state

When using events, you want visual feedback for the end user.

This is especially useful for long running listeners.

Button::make('Remind User')->loadingText('Sending..')->successText('Sent!')
Event Text Style
loading loadingText('Loading..') loadingStyle('grey-outline')
success successText('Done!') successStyle('success')
error errorText('Failed') errorStyle('danger')

Defaults defined in the nova-button config. Add methods when you want to change for specific resources

Button styles

This package makes use of tailwind-css classes / default: link

Button::make('Confirm')->style('primary')
Fill Outline Link
primary primary-outline primary-link
success success-outline success-link
danger danger-outline danger-link
warning warning-outline warning-link
info info-outline info-link
grey grey-outline grey-link

Each key adds classes from the nova-button config

'primary' => 'btn btn-default btn-primary'

Style config

Publish the nova-button config to add / edit available styles & defaults

php artisan vendor:publish --tag=nova-button -- force

Button classes

You can also add classes manually

Button::make('Refund')->classes('some-class')

Also able to style the following css classes

.nova-button
.nova-button-{resource-name}
.nova-button-success
.nova-button-error
.nova-button-loading

Example

Use lenses with buttons for a very focused user experience

lens-button

<?php

namespace App\Nova\Lenses;

class UsersWithoutConfirmation extends Lens
{
    public static function query(LensRequest $request, $query)
    {
        return $query
            ->select(['users.id', 'users.name'])
            ->whereNull('email_verified_at');
    }

    public function fields(Request $request)
    {
        return [
            ID::make('ID', 'id'),
            Text::make('Name', 'name'),
            Button::make('Mark As Confirmed'),
        ];
    }
}

Register a listener for \NovaButton\Events\ButtonClick in your EventServiceProvider

<?php

namespace App\Listeners;

class ConfirmUser
{
    public function handle($event)
    {
        if ($event->key == 'mark-as-confirmed') {
            $event->resource->email_verified_at = now();
            $event->resource->save();
        }
    }
}

No key check required when you register an event for this listener

Button::make('Confirm')->event('App\Events\ConfirmClick')

Telescope inspection

event-triggered


Author

Hi ๐Ÿ‘‹, Im Brian Dillingham, creator of this Nova package and others

Hope you find it useful. Feel free to reach out with feedback.

Follow me on twitter: @sir_brian_d

nova-button's People

Contributors

4n70w4 avatar ahmedkandel avatar bernhardh avatar dependabot[bot] avatar dillingham avatar dkulyk avatar lorenzosapora avatar lucidlogic avatar maherelgamil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nova-button's Issues

two step confirmation option

Before performing a somewhat dangerous action.
Do a confirmation. Just like the default delete button does.

->confirm('Are you really sure?')

Details when the link has Name-Name

Hello there,
I am not really a IT guy I work as a dancer doing my own website so good in then maybe is a stupid thing.
I have a this a link that make error and I think is because I use a double name.

Button::make($title)->detail( 'App\Nova\CrashCourse', $this->registration_id),

The URL that nova create is /nova/resources/crash-courses/ID and give me an error 404.

Any Idea how I can change that? I did use with other names and works perfect .. is just this link that give me problems.

Thanks for your time and again sorry if is a stupid answer.

Double Click Request Multiple Time

Hello

I found one issue with this button. I don't someone faced this issue before or not.
When we double click on this button it's requesting multiple time.
Below is my sms sending queue button and when I double click this button It is sending SMS multiple time. It's requesting queue multiple time.

Button::make("Send SMS", 'queue')
                ->event('App\Events\QueueSMSPromo')
                ->loadingText('Sending..')
                ->successText('Sent!')
                ->visible(($this->status != 'new') ? false : true)
                ->onlyOnIndex(),

See below image I pressed double click on button and it's calling multiple time.

image

Retain table cells for non-visible buttons

If you set a visibility condition on a button, if there are any rows where no button matches (and, I assume, differing numbers of buttons) the columns become misaligned (See screenshot). Would it be better for non-visible buttons to product an empty cell rather than nothing at all?

image

Currently the workaround is to add additional button with an empty label with a visibility condition that is complimentary.

Button State - How to succeed or fail?

I note the docs make mention of:

Button::make('Remind User')->loadingText('Sending..')->successText('Sent!')

How can I return a failure or success status from the Event / Listener?

Possible to stack/combine "event" and "index" methods

I would like to do this:

Button::make('Run')
                ->event('App\Events\ApplyFiltersEvent')
                ->index('App\Nova\User'),

Basically, navigate to the User index page after firing the event. It seems to be either-or in the current code. Perhaps there is another way?

Thanks.

FR: Prompt option similar to action fields

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'),
        ];
    }),

Feature request: allow change text for confirm cancel button

Hey, great package! Congrats!

I would like to suggest a minor change:

99% or your buttons and text has options to be changed... the button text, the loading/success/fail text, the confirm title and message, etc... but the cancel button text in confirm dialog not...

Please add a option to change this text too.

Great!

Feature Request: Actions Drop-down

A drop down action list would be nice to have.
To get an basic idea on the list:

image

PS: Please ignore the options in the image. My requirement was to add actions like:

Login As
Confirm Email
Resend Confirmation
Refund

Thanks. Great package ๐Ÿ‘

License?

Hey there,
What is the license of this package? I found this very helpful and I really liked how you managed links here and was hoping to use something similar in my own package. Would this be alright?

Let button post a form with hidden fields

I need a button that submits a form with some hidden fields.

<form action="example.org/login" target="_blank" method="post">
    <input type="hidden" name="username" value="my_name">
    <input type="hidden" name="password" value="12345678">
</form>

It might use the resource to fill the fields:

Button::make('Login')
    ->link('example.org/login', '_blank', 'POST')
    ->addHiddenField('username')
    ->addHiddenField('password', 'external_password')
    ->addHiddenField('one_more_field', function () {
        return $this->resource->someMethod();
    }),

Is this something you would consider adding to your package?

Feature: Allow fire of action on resource

Great component! Adding lots of value to my nova apps.

Just thought I would request a possible feature/enhancement - it would be great if I could trigger an action from the button for the selected resource.
So something like:

Button::make('Text')->action('App\Nova\Actions\SendUserMessage', $this->user_id)

It would allow the collection of fields via the normal Action workflow - so essentially a shortcut for selecting the resource and running the action from the Actions dropdown.

How to make a toogle button with visual change

Hello,
First of all thanks for make this project to allow make new buttons to table rows :).

I want to add a "favorite button" with star icon such that when I click on it, marks the resource as favorite in resource favorite relation and visually, the icon must change to represent that is marked as favorite. Also if I click again on favorite icon, It should unmark favorite relation and show initial state button.

I've been looking at the docs but I can't figure out how to do it.

Could someone put an example of how can I make a toggle event that changes the svg icon ( on success ) and call the programed action ?

Thank you in advance!

How to customize button text based on record value

I am going to add "Archive" button to set the status value of the record in resource table. I succeeded in saving status when click "Archive", but need to set the button text to "Archived" and disabled when reload the website.
Is this possible with Nova button?
Thank you.

Add form fields on confirm modal

Hi.
This package is great and got me a long way. But now I unsure about how to create events on input fields in the confirm modal.
I have this on the Button field:

Button::make(__('Send'))->confirm(__('Are you sure?'), view('partials.send-confirmation')->render());

I the blade template I have added a checkbox input field, which I want the user to check before sending. So the Send button should be disabled until it is checked. Please see attached.
Is this possible? I'm not great at Vue. :-)
Screenshot 2019-09-23 at 17 27 18

Button using icon [enhancement]

Would be nice to add the ability to set the button to be an icon (similar to show, edit and delete buttons in nova)

I would imagine it to be configured like so:
Button::make('Download')->icon('fa-download'),

When using icon version it could use text as the buttons tooltip.

Button not showing on index with nova-mega-filter in use

If someone is using the https://novapackages.com/packages/digital-creative/nova-mega-filter package, the button will not show up on index pages, since it has no value for the attribute property.

To fix it, you just can set it:

$btn = Button::make("Preview")
    ->showOnIndex();
$btn->attribute = "preview";

It would be great, if we could set it by a setAttributeName method or even as second make parameter, so that we can use method chaning and don't have to directly manipulate object properties.

[Enhancement] Button as a switch for boolean field

First of all this is an awesome package!

What i would like to see is an option to use it as a switch for a boolean field on the resource, e.g.:

Button::make('is_hidden')
            ->switch()
            ->trueLabel('text or html for an icon or similar')
            ->falseLabel('text or html for an icon or similar')

and in ButtonController maybe something like this:

public function handleSwitch(NovaRequest $request)
    {
        $resource = $request->findModelQuery()->firstOrFail();

        $resource->{$request->requestAttribute} = ! $resource->{$request->requestAttribute};

        if ($resource->save()) {
            return response($resource->{$request->requestAttribute}, 200);
        }

        return response('Something went wrong', 500);
    }

By sending back the new value the frontend than could change without reloading the whole page.

Button not showing on index or detail

I've tried several variations of implementing the button from the documentation and the button just doesn't show. Ever.

For example, Button::make('Text')->index('App\Nova\User'), No button. Nothing.

Not sure what else to provide here, but possibly this is not compatible with my version of Nova? Version: v2.12.0

Custom Fail Event Not Working in Event Listener

I have an API that I am calling when clicking the NovaButton and the Event Listener runs, but im making the API fail and the NovaButton still says the click action was successful. This is happening even when I use a try like this..

try {
               //Break the API here
      }catch (\Exception $e) {
                $this->failed($e);
               //The above is called and works as a fail, but the NovaButton doesn't show its 'failed' state
            }

add loadingText() for long requests

If your listener takes awhile to execute, the button doesn't give much indication currently.

I think it would be nice to add Button::make('Notify')->loadingText('Notifying..')

And with ->reload() it might be smart to setTimeout 200ms to avoid flashing text for quick listeners

Add parameter to event

Hi, can i add parameter to custom event that i call for example: $this->id
so in listener i can access that resource and modify or do my actions?
Thanks a lot :) awesome package

My code

Button::make('Activate')
->event('App\Events\ActivateUser', $this->id)
->visible($this->status == 0)
->confirm('Are you sure?')
->style('success-outline'),

Button::make('Deactivate')
->event(new DeactivateUser($this->id))
->visible($this->status == 1)
->confirm('Are you sure?')
->style('danger-outline'),

Feature Request: Trigger Nova Action with Resource

Hey! Great package - fits really well into my Nova client interface.

Would love to have a way to have the button trigger a Nova Action and pass the resource through to that Action (so it would be the same as if I selected the single resource checkbox, and picked an Action from the select box.)
Screen Shot 2019-08-26 at 9 35 41 PM

With Nova Actions, I'm able to create a pop-up with extra custom fields that I can populate before initiating the Action.
Screen Shot 2019-08-26 at 9 39 11 PM

Being able to initiate this popup (or any Nova Action) with just a button rather than the 3-step process would be very helpful. (something like Button::make('Text')->action('App\Nova\Actions\SendText'))

Navigation to filter

Hi Brian,

As an enhancement to the navigation links routing to index with a filter may be as following:

In User resource a button to navigate to Order resource with UserOrders filter:

Button::make($this->orders->count() . ' Orders')->index('App\Nova\Order')->filter('App\Nova\Filters\UserOrders', $this->id)

then do json_encode and base64_encode to generate the filter URI.

Thanks

need unique id for queue

When multiple buttons are on a row & ->reload() is set, the id of the row may be treated as complete even though it was for a different button on that row, if simultaneous.
Solution queue.add(attribute + '-' + resourceId) to make unique.

Placeholder text for not visible buttons

Hi.
It would be great if it was possible to have a placeholder text or icon that could sit in those rows where the button->visible = false. Or maybe even show the button as disabled. It looks so empty. :-)
nova-button

Event not working with default and custom events

My code for custom event

EventServiceProvider.php

'App\Events\ActivateUser' => [ 'App\Listeners\ActivateUserListener', ], 'App\Events\DeactivateUser' => [ 'App\Listeners\DeactivateUserListener', ], '\NovaButton\Events\ButtonClick' => [ 'App\Listeners\NovaButtonListener', ],

App\Nova\User.php

`
Button::make('Activate')
->event('App\Events\ActivateUser')
->visible($this->status == 0)
->confirm('Are you sure?')
->style('success-outline'),

Button::make('Deactivate')
->event('App\Events\DeactivateUser')
->visible($this->status == 1)
->confirm('Are you sure?')
->style('danger-outline'),
`


App\Events\ActivateUser.php

`<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class ActivateUser
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct()
{
    //
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return \Illuminate\Broadcasting\Channel|array
 */
public function broadcastOn()
{
    return new PrivateChannel('channel-name');
}

}
`


App\Events\DeactivateUser.php

`<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class DeactivateUser
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct()
{
    //
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return \Illuminate\Broadcasting\Channel|array
 */
public function broadcastOn()
{
    return new PrivateChannel('channel-name');
}

}
`


App\Listeneres\ActivateUserListener.php

`<?php

namespace App\Listeners;

use App\Events\ActivateUser;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class ActivateUserListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}

/**
 * Handle the event.
 *
 * @param  ActivateUser  $event
 * @return void
 */
public function handle(ActivateUser $event)
{
    $event->resource->status = 1;
    $event->resource->save();
}

}
`


App\Listeneres\ActivateUserListener.php

`<?php

namespace App\Listeners;

use App\Events\DeactivateUser;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class DeactivateUserListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}

/**
 * Handle the event.
 *
 * @param  DeactivateUser  $event
 * @return void
 */
public function handle(DeactivateUser $event)
{
    $event->resource->status = 0;
    $event->resource->save();
}

}
`


App\Listeneres\NovaButtonListener.php

`<?php

namespace App\Listeners;

class NovaButtonListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}

/**
 * Handle the event.
 *
 * @param  ActivateUser  $event
 * @return void
 */
public function handle($event)
{
    if ($event->key == 'activate-user') {
        $event->resource->status = 1;
        $event->resource->save();
    }

    if ($event->key == 'deactivate-user') {
        $event->resource->status = 0;
        $event->resource->save();
    }
}

}
`


Text

I have tried with both my custom events and default events
But i get always failed, i also cleared config, cache, view, run key generate,
in log file i see something like this:

[2019-01-25 20:49:39] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:44)
[stacktrace]
#0 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Support\helpers.php(1027): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(NULL)
#1 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(48): tap(NULL, Object(Closure))
#2 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(24): Illuminate\Encryption\EncryptionServiceProvider->key(Array)
#3 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(776): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#4 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(658): Illuminate\Container\Container->build(Object(Closure))
#5 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(609): Illuminate\Container\Container->resolve('encrypter', Array)
#6 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(735): Illuminate\Container\Container->make('encrypter', Array)
#7 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(912): Illuminate\Foundation\Application->make('encrypter')
#8 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(840): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#9 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(807): Illuminate\Container\Container->resolveDependencies(Array)
#10 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(658): Illuminate\Container\Container->build('App\\Http\\Middle...')
#11 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Container\Container.php(609): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array)
#12 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(735): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)
#13 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(215): Illuminate\Foundation\Application->make('App\\Http\\Middle...')
#14 C:\xampp\htdocs\parkingbadge\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(189): Illuminate\Foundation\Http\Kernel->terminateMiddleware(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
#15 C:\xampp\htdocs\parkingbadge\public\index.php(60): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
#16 {main}
"}

Please help me solve this issue, thanks

Capturing User ID in the Event?

Is it possible to send the current user to the event?

We'd like to track who clicked the button but I note the event payload doesn't contain the user, likewise, if we queue then we can't use auth().

Add ->reload() for page refresh

Currently you manually have to refresh the page to see if any changes took place during a ajax button event. Adding a window.reload would be one approach or something with vue router

Run Nova action on button click

NovaButton can be a very nice shortcut way to use Nova actions. Instead of selecting a row and selecting an action from the drop-down menu, just click on a NovaButton. So is it possible to run a pre-defined action by clicking a NovaButton?

Error on Safari

Hello,
buttons with external links don't seem to work on safari.

this is my example:
Button::make('Guardalo')
->link('https://www.google.com', '_blank')
->style('info'),

thanks,Marco,

Modal css on Responsive Theme

I installed nova-button as well as the ResponsiveTheme package. But I'm having problem with the css of the modal. Locally I changed the components IndexField.vue and DetailField.vue to add manually the width: 100% !important (and also added some margin top), as I saw in the css file of the ResponsiveTheme, and it worked perfectly.

But, obviously, when I deploy my app, it will be installed from nova-button git and not get my changes.

Should I do some config to reflect the Responsive css to the modal? Or is it an issue with nova-button package?

image

Trying to figure out custom event listner

I added to my event service provider:

'\NovaButton\Events\ButtonClick' => [ 'App\Listeners\CloseFeedbackRequest', ]

I have the following listener:

`
namespace App\Listeners;

use \NovaButton\Events\ButtonClick;

class CloseFeedbackRequest
{

/**
 * Create the event listener.
 *
 * @return void
 */
public function __construct()
{
    //
}

/**
 * Handle the event.
 *
 * @param  ButtonClick  $event
 * @return void
 */
public function handle(ButtonClick $event)
{
    //
    if ($event->key == 'close-request') {
        $event->resource->closed_at = now();
        $event->resource->save();
    }
}

}
`

And the following event:

`

namespace App\Events;

use Illuminate\Foundation\Events\Dispatchable;

class CloseFeedbackRequest
{
use Dispatchable;

public $resource;
public $key;

/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct($resource, $key)
{
    $this->$resource = $resource;
    $this->$key = $key;
}

}
My button is Button::make('Close', 'close-request')
->event('App\Events\CloseFeedbackRequest')
->visible($this->closed_at == null)
->confirm('Are you sure you want to close this request?')
->style('primary-outline'),`

My model is not getting updated what am I missing?

405 Method Not Allowed Http Exception

click on the button returns

at first:

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

than

405 Method Not Allowed Http Exception

i tried to use the NovaButton\Events\ButtonClick and also a custom event, but seems not to work.. what could be the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.