Power-Components/livewire-powergrid

[6.x] can method not working in bulk action buttons inside header

eafarooqi opened this issue · 10 comments

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes - I didn't work.

Is there an error in the console?

No

PHP Version

8.2.9

PowerGrid

6.1.1

Laravel

11.31

Livewire

3.5.12

Alpine JS

3.12.0

Theme

Bootstrap

Describe the bug.

Can method not working in bulk action buttons inside header. I am trying to add conditional bulk actions. Rules are also not working on buttons inside header.

To Reproduce...

public function header(): array
    {
        return [
            Button::add('bulk-delete')
                ->slot('Bulk delete')
                ->class('pg-btn-white')
                ->can(false)
                ->dispatch('bulkDelete.' . $this->tableName, []),
        ];
    }

Extra information

No response

In 6.1.2 with livewire 3.5.12, showToggleColumns() only hides row data but not header data.

In 6.1.2 with livewire 3.5.12, showToggleColumns() only hides row data but not header data.

same problem here, its just in 6.1.2 and not in 6.1.1.

The problem is in the cols.blade.php, dont know why the semicolon should be outside the string. Line 44 has to be:

style="{{ data_get($column, 'hidden') === true ? 'display:none;' : '' }} width: max-content !important; @if (data_get($column, 'enableSort')) cursor:pointer; @endif {{ data_get($column, 'headerStyle') }}"

I'm still not sure about this issue.

Maybe need 6.1.3 to fix this problem. If my website using bootstrap5, can livewire-powergrid use Tailwind?

I do not know why in 6.1.2, they bring this bug back. I have seen someone have reported this bug before.

In 6.1.2 with livewire 3.5.12, showToggleColumns() only hides row data but not header data.

same problem here, its just in 6.1.2 and not in 6.1.1.

The problem is in the cols.blade.php, dont know why the semicolon should be outside the string. Line 44 has to be:

style="{{ data_get($column, 'hidden') === true ? 'display:none;' : '' }} width: max-content !important; @if (data_get($column, 'enableSort')) cursor:pointer; @endif {{ data_get($column, 'headerStyle') }}"

I do not know why in 6.1.2, they bring this bug back. I have seen someone have reported this bug before.

In 6.1.2 with livewire 3.5.12, showToggleColumns() only hides row data but not header data.

same problem here, its just in 6.1.2 and not in 6.1.1.
The problem is in the cols.blade.php, dont know why the semicolon should be outside the string. Line 44 has to be:

style="{{ data_get($column, 'hidden') === true ? 'display:none;' : '' }} width: max-content !important; @if (data_get($column, 'enableSort')) cursor:pointer; @endif {{ data_get($column, 'headerStyle') }}"

#1716

@luanfreitasdev you dont have to revert the hole branch, the bug is just in one file. I have tested and fixed it: #1768

@ALL: my suggestion is, please work in good PHP IDEs like phpstorm. The error was shown in the blade file while opening.

Hi,
i think we have merged two issues here. This toggle column only hides is another issue from what i have mentioned. Yes this toggle column issue needs to be fixed with the following line. The semicolon should be at the right place.

style="{{ data_get($column, 'hidden') === true ? 'display:none' : ''; }} width: max-content !important; @if (data_get($column, 'enableSort')) cursor:pointer; @endif {{ data_get($column, 'headerStyle') }}"

The issue i have mentioned is that i want to have conditional actions in the header. In the headers we are creating actions using Button Class and when we pass false to can method is still showing the action in the header.

I did a test with cypress and changed the logic

Screen.Recording.2024-11-15.at.09.23.07.mov

#1770