Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Proposal: customize ignore button classes #2

Open
emilianotisato opened this issue Dec 8, 2019 · 1 comment
Open

Proposal: customize ignore button classes #2

emilianotisato opened this issue Dec 8, 2019 · 1 comment

Comments

@emilianotisato
Copy link

emilianotisato commented Dec 8, 2019

Excelente package!

Would you be interested in a PR to allow user customizing other options to ignore other than the ones you established? (links, inputs, etc)

The reason is that I had to integrate https://github.com/dillingham/nova-button and this package does not use either <button> or <a> but a simple <span> with a class nova-button.

I made a version of your packet where I parse the span class and ignore the click listener to, but is hardcoded in my project.

I was thinking about the best way for the user to indicate that other items to ignore:
Option 1: using dotenv (https://www.npmjs.com/package/dotenv) we could give the user the option to include. in his .env

CLICKABLE_ROW_IGNORE_CLASES = nova-button, other-class
CLICKABLE_ROW_IGNORE_IDS = some-id, other-id

Option 2: Have the tool inject some meta element into the header, and can the file too.js read it from there?

Option 3: any better ideas?

@emilianotisato emilianotisato changed the title Proposal Proposal custom ignore button classes Dec 8, 2019
@emilianotisato emilianotisato changed the title Proposal custom ignore button classes Proposal: customize ignore button classes Dec 8, 2019
@milewski
Copy link
Member

milewski commented Dec 8, 2019

Hi @emilianotisato, PR is always welcome!

I think the Option 1 is a bit strange given that this package does something so simple, I think a better and easy option to solve this problem would be following the default convention for setting up a tool in Nova, for example, we could do something like this:

In NovaServiceProvider.php

/**
 * Get the tools that should be listed in the Nova sidebar.
 *
 * @return array
 */
public function tools()
{

    return [
        new ClickableTableRow([          
            'ignoreElements' => [
                '.nova-button',
                '.other-class',
                '#some-id .some-class'
            ]
        ])      
    ];

}

And from within the ClickableTableRow we can pass any arbitrary data to the tool.js by calling:

Nova::provideToScript([
    'clickableTableRow' => $data
]);

and then we can retrieve this info back in tool.js by calling Nova.config.clickableTableRow

I believe this would be a cleaner solution to accept config options, and also this would open doors for a future feature I am planning to do soon where I need this package not to be applied to certain table resources

So it would be just a matter of including another option on the options array:

new ClickableTableRow([
    'ignoreResources' => [
        \App\Nova\User::class
    ],
    'ignoreElements' => [...]
]),

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants