Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] Quick button implementation #770

Closed not82 closed 10 months ago

not82 commented 10 months ago

Bug report

What I did

I tried to implement a quick button, as it's a new feature : ( I'm from 4.1 )

https://backpackforlaravel.com/docs/6.x/release-notes#quick-buttons-now-one-line https://backpackforlaravel.com/docs/6.x/crud-buttons#creating-a-quick-button-1

What I expected to happen

I expect it to work as documented

What happened

Button doesn't appear

What I've already tried to fix it

In fact, at minimum, has to add : ->meta(['access' => true])

I don't know if it's an expected behaviour, in this case documentation isn't up to date, or maybe it's a bug ( it's strange to have to add this line while the philosophy seams to add quickly a new button, so default should be visible )

For documentation issues, now I go to demo project to try to guess how to implement things.. Globally, it's a pain each time I try to use new features : while they are great , there is a lack of documentation, or simply bugged. I have decided to pay since 4.1 upgrades, because the products are great, but really, theses bugs and documentation lacks are hard to understand for a paid service while it was fluid in "free" 4.1

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Yes..

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.1.26 (cli) (built: Nov 22 2023 10:01:32) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.26, Copyright (c) Zend Technologies with Zend OPcache v8.1.26, Copyright (c), by Zend Technologies with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

LARAVEL VERSION:

10.33.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2 backpack/crud: 6.3.2 backpack/editable-columns: 3.0.2 backpack/generators: v4.0.2 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.18 backpack/theme-coreuiv2: 1.2.2 backpack/theme-tabler: 1.1.1

pxpm commented 10 months ago

Hello @not82 thanks for the feedback.

I totally feel your pain finding bugs/inconsistencies and really appreciate the time you take to come here and report them.

I think in this case is a "bad communication" / bad docs in a whole.

In the docs ( https://backpackforlaravel.com/docs/6.x/crud-buttons#creating-a-quick-button-1 ) we can read:

Most of the times, the buttons you want to create aren't complex at all. They're just an element, with a href and class that is show if the admin has access to that particular operation.

There is a key factor here, that we are not doing a good job highlighting if the admin has access to that particular operation.

I think we are not doing a good job here explaining how usually buttons are tied to the operations. For example the create button will only be displayed if you have access to the create operation. So to create "quick button for that operation", one would do: CRUD::button('create')->stack('top')->view('crud::buttons.quick');

We clearly need to communicate better that the button name is used as the "operation access", and that developer can always show it with access => true.

I will assign my college @karandatwani92 for him to take over here and do the required documentation changes to make this more clear.

Thanks again, and sorry for the bad experience. I think your pain will help other to avoid it. 🙏

Cheers

not82 commented 10 months ago

Hi @pxpm ok I see, it's not explained at all in fact, and the example don't help at all too.

So the name have many responsabilities :

Many responsabilies = less fluid comprehension, even more if not explained. Good luck for all that.

karandatwani92 commented 10 months ago

PR https://github.com/Laravel-Backpack/docs/pull/526

pxpm commented 10 months ago

Hi @pxpm ok I see, it's not explained at all in fact, and the example don't help at all too.

So the name have many responsabilities :

  • it's the name of the view if we want to have a specific view for the button
  • it's the name of the operation we want it to appear
  • it's a unique name that will overwrite another button with same name ? ( as column logic )

Many responsabilies = less fluid comprehension, even more if not explained. Good luck for all that.

Hey, @not82 thanks for the feedback. We can call it "responsabilities", or inference, because most of the times we are just repeating common stuff, and that's what the "quick" button wants to help solve.

I think a lot of operations use the same approach, like Email a user, Remind a pending invoice, Publishing an article and all the core ones:

// PublishOperation trait, Publish the operation name
CRUD::button('publish')->stack('line')->view('crud::buttons.quick');
// RemindUserOperation, RemindUser the operation name
CRUD::button('RemindUser')->stack('line')->view('crud::buttons.quick');
etc ... 

I've just merged @karandatwani92 suggestions plus some of mine to try to make the docs more clear and give more examples of what can be quickly achieved, without having to create custom views for each button, etc.

Let me know if you have any suggestion of your own to add, feel free to submit a PR if you feel to 🙏

Cheers