Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow developer to configure the behavior of actions buttons dropdown #5667

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Sep 18, 2024

WHY

superseeds: #5568

BEFORE - What was wrong? What was happening before this PR?

The PR #5568 introduces a way for developers to control the behavior of line buttons when displayed as a dropdown.

While reviewing it I noticed that a very much likely use case for line buttons was to "force" some X amount of buttons to display inline and create the dropdown for the remaining.

AFTER - What is happening after this PR?

In addition to what the PR #5568 introduced (the minimum amount of items to drop, eg: less than 2 actions don't create a dropdown), it also introduces a way for developers to force the first X actions to display inline.

image

Docs for it can be found here: Laravel-Backpack/docs#598

HOW

How did you achieve that, in technical terms?

Added a new config: lineButtonsAsDropdownDropAfter in addition to the lineButtonsAsDropdownMinimumToDrop

Is it a breaking change?

No, the same defaults are kept (all buttons display in a dropdown).

@pxpm pxpm changed the title Pr/5568 Allow developer to configure the behavior of actions buttons dropdown Sep 18, 2024
@susanu
Copy link
Contributor

susanu commented Sep 18, 2024

Hi Pedro,

Looks good to me. Great job!

src/config/backpack/operations/list.php Outdated Show resolved Hide resolved
src/config/backpack/operations/list.php Outdated Show resolved Hide resolved
@pxpm pxpm merged commit f76027e into main Sep 18, 2024
8 checks passed
@pxpm pxpm deleted the pr/5568 branch September 18, 2024 14:34
@blondie63
Copy link

blondie63 commented Sep 18, 2024

@pxpm I've updated to v6.7.37 with no other changes and:
Screenshot 2024-09-18 alle 17 52 54

All my cruds have this: $this->crud->setOperationSetting('lineButtonsAsDropdown', true);

@pxpm
Copy link
Contributor Author

pxpm commented Sep 19, 2024

Hey @blondie63 I cannot reproduce your issue.

image

image

You updated from what version ? I don't think this PR has any change that would break that, it could be some other change 🤷

Let me know, cheers.

@blondie63
Copy link

Hi @pxpm here some info:

PHP VERSION:

8.3.11

PHP EXTENSIONS:

Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, FFI, fileinfo, filter, ftp, gd, gettext, gmp, json, iconv, intl, SPL, ldap, mbstring, session, standard, odbc, pcntl, exif, mysqlnd, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, random, readline, Reflection, mysqli, shmop, SimpleXML, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, xdebug, Zend OPcache

LARAVEL VERSION:

11.23.5.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.3.6
backpack/crud: 6.7.37
backpack/devtools: 3.1.6
backpack/editable-columns: 3.0.10
backpack/generators: v4.0.6
backpack/language-switcher: 2.0.0
backpack/pro: 2.2.17
backpack/settings: 3.1.1
backpack/theme-tabler: 1.2.13

After a better check i've seen that only one crud have this problem and this is my code:

protected function setupListOperation()
{

    $this->crud->addButtonFromView('line', 'change_user_password', 'change_user_password', 'beginning');
    $this->crud->addButtonFromView('line', 'switch_user_registered', 'switch_user_registered', 'beginning');

    $this->crud->setOperationSetting('lineButtonsAsDropdown', true);

@pxpm
Copy link
Contributor Author

pxpm commented Sep 19, 2024

Hey @blondie63 most likely your custom button views are missing some attributes that backpack uses to identify the buttons?

const actionButtons = actionCell.find('a.btn.btn-link');

Make sure you have them so that Backpack can properly find and manipulate them 👍

@blondie63
Copy link

Hi @pxpm yes you are right, some our customization create problem and i've just fixed

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants