mokhosh / filament-kanban

Add kanban boards to your Filament pages
https://filamentphp.com/plugins/mokhosh-kanban
MIT License
228 stars 32 forks source link

[Bug]: 2 last status can't be moved #12

Closed ronylicha closed 5 months ago

ronylicha commented 5 months ago

What happened?

Hi,

Thx for the awesome plugin, the title say everything, when i have more than two status, the last (if there three) or the two last (if there four or more) don't allow to move what inside or move from other status to those who are blocked.

the only thing i change is the design of the kaban-record.blade.php:


<div
    id="{{ $record['id'] }}" class="kanban"
    wire:click="recordClicked('{{ $record['id'] }}', {{ @json_encode($record) }})"
    {{--class="record transition bg-white dark:bg-gray-700 rounded-lg px-4 py-2 cursor-grab font-medium text-gray-600 dark:text-gray-200"--}}
    @if($record['just_updated'])
        x-data
    x-init="
            $el.classList.add('animate-pulse-twice', 'bg-primary-100', 'dark:bg-primary-800')
            $el.classList.remove('bg-white', 'dark:bg-gray-700')
            setTimeout(() => {
                $el.classList.remove('bg-primary-100', 'dark:bg-primary-800')
                $el.classList.add('bg-white', 'dark:bg-gray-700')
            }, 3000)
        "
    @endif
>
    <x-filament::section>
        <table class="bg-re">
            <tr>
                <td rowspan="2">

                    <x-filament::dropdown>
                        <x-slot name="trigger">
                            <x-filament::icon-button
                                icon="heroicon-o-phone"
                            />
                        </x-slot>

                        <x-filament::dropdown.list>
                            @foreach($record["phones"] as $tel)
                                <x-filament::dropdown.list.item
                                    href="tel:{{ $tel->phone_number}}"
                                    tag="a">
                                    {{ $tel->phone_number}}
                                    <br>
                                    <span class="text-xs text-gray-900 italic">
                                        {{ $tel->phone_type}}
                                    </span>

                                </x-filament::dropdown.list.item>
                            @endforeach

                        </x-filament::dropdown.list>
                    </x-filament::dropdown>
                    <x-filament::dropdown>
                        <x-slot name="trigger">
                            <x-filament::icon-button
                                icon="fluentui-mail-add-20-o"
                            />
                        </x-slot>

                        <x-filament::dropdown.list>
                            @foreach($record["emails"] as $mail)
                                <x-filament::dropdown.list.item
                                    href="mailto:{{ $mail->email}}"
                                    tag="a">
                                    {{ $mail->email}}
                                </x-filament::dropdown.list.item>
                            @endforeach

                        </x-filament::dropdown.list>
                    </x-filament::dropdown>
                    <x-filament::dropdown>
                        <x-slot name="trigger">
                            <x-filament::icon-button
                                icon="mdi-google-maps"
                            />
                        </x-slot>

                        <x-filament::dropdown.list>
                            @foreach($record["adresses"] as $adresse)
                                @if(!empty($adresse->adresse_ligne_2) && !is_null($adresse->adresse_ligne_2))
                                    @php($adresseToLink = $adresse->adresse_ligne_1."+".$adresse->adresse_ligne_2."+".$adresse->adresse_cp."+".$adresse->adresse_ville."+".$adresse->adresse_pays)
                                @else
                                    @php($adresseToLink = $adresse->adresse_ligne_1."+".$adresse->adresse_cp."+".$adresse->adresse_ville."+".$adresse->adresse_pays)
                                @endif
                                <x-filament::dropdown.list.item
                                    href="https://www.google.fr/maps/place/{{ $adresseToLink }}"
                                    target="_blank"
                                    tag="a">
                                    {{ $adresse->adresse_ligne_1}}
                                    <br>
                                    @if(!empty($adresse->adresse_ligne_2) && !is_null($adresse->adresse_ligne_2))
                                        {{ $adresse->adresse_ligne_2}}
                                        <br>
                                    @endif
                                    {{ $adresse->adresse_cp }} {{$adresse->adresse_ville}}
                                    <br>
                                    {{$adresse->adresse_pays}}
                                </x-filament::dropdown.list.item>
                            @endforeach

                        </x-filament::dropdown.list>
                    </x-filament::dropdown>
                    <x-filament::dropdown>
                        <x-slot name="trigger">
                            <x-filament::icon-button
                                icon="heroicon-o-ellipsis-vertical"
                            />
                        </x-slot>

                        <x-filament::dropdown.list>

                            <x-filament::dropdown.list.item icon="heroicon-s-eye"
                                href="{{route('filament.admin.resources.leads.view',['record'=>$record['id']])}}"
                                target="_blank"
                                tag="a">
                                    {{__("View")}}
                            </x-filament::dropdown.list.item>
                            <x-filament::dropdown.list.item icon="heroicon-o-pencil-square"
                                href="{{route('filament.admin.resources.leads.edit',['record'=>$record['id']])}}"
                                target="_blank"
                                tag="a">
                                {{__("Edit")}}
                            </x-filament::dropdown.list.item>

                        </x-filament::dropdown.list>
                    </x-filament::dropdown>
                </td>
                <td>
        <span class="text-gray-600 text-left">
            {{ ucfirst($record['title']) }}
        </span>
                </td>
            </tr>
            <tr>
                <td>
        <span class="text-sm text-gray-900 text-left italic">
            {!! $record["leads_description"] !!}
        </span>
                </td>
            </tr>
        </table>

    </x-filament::section>

</div>

If you need i can provide an access to my online production test server to test it.

How to reproduce the bug

Just add more than two status to your application

Package Version

1.11.0

PHP Version

8.3.0

Laravel Version

10.45.0

Which operating systems does with happen with?

macOS, Windows, Linux

Which browsers does with happen with?

Chrome

Notes

No response

mokhosh commented 5 months ago

I copy pasted your code, and everything worked as expected. You can create a replication repo and share the link so I can check it out. You can also check the dev tools to see if there are any other javascript errors that break the page.

mokhosh commented 5 months ago

@ronylicha any updates? should i go ahead and close this?

mokhosh commented 5 months ago

Should be fixed in https://github.com/mokhosh/filament-kanban/releases/tag/v2.4.0 Let me know if there are still issues.

envolute commented 5 months ago

Just to let you know...

Regarding this problem, I think I managed to find the problem.

See, I customized the "kanban-status.blade.php" view and implemented a condition to not load one of the statuses @if($status['id'] != 4) As this status can only be changed by an admin...

This way, the statuses that come after this one have drag disabled. In other words, if one of the statuses is removed from the view and not from the Enum, the others after it will not work correctly.

In this case, I created a custom StatusEnum with just the statuses i want to show.

mokhosh commented 5 months ago

@envolute The issue in your case is, you have that status everywhere in the logic except the kanban-status.blade.php view. So, when other parts of the code try to reference that status they don't find it in the view, and they stop working as expected.

If you want to not include some of the cases in your board there is a simpler official way of doing it: https://github.com/mokhosh/filament-kanban?tab=readme-ov-file#customizing-the-status-enum

Just override the kanbanCases method, and you will have a subset of your enum cases without any issues.