Skip to content

Introduce the methods to fetch resources from the livewire component …#216

Open
felahdab wants to merge 1 commit intosaade:3.xfrom
felahdab:florianthecoder-introduce-methods-to-use-resources
Open

Introduce the methods to fetch resources from the livewire component …#216
felahdab wants to merge 1 commit intosaade:3.xfrom
felahdab:florianthecoder-introduce-methods-to-use-resources

Conversation

@felahdab
Copy link

Hi,

Since PR #66 , the resource time line plugin is readily available.
However, there is no way to make the calendar load the resources from the Livewire component while it seems like a logical way of using this.

This PR introduces slight changes to allow that.

First, the javascript part introduces the resources method which calls the livewire backend to retrieve the resources.
It also sets the refetchResourcesOnNavigate to true to make sure that the calendar gets an updated list of resources to display when the user navigates the calendar.
An it also make sure that a filament-fullcalendar--refresh event will refresh both the events and the resources.

Then, it introduces the fetchResources method in the livewire part. This method is called by the resources method, and must return an array of resources. An empty array is returned by default.

The config method can be used to pass some aditionnal settings for the resource timeline like so:

public function config(): array
    {
        return [
            'initialView' => 'resourceTimelineMonth',

            'headerToolbar' => [
                'left' => 'resourceTimelineMonth,resourceTimelineYear',
                'center' => 'title',
                'right' => 'prev,next today',
            ],
            'resourceAreaHeaderContent' => 'Resource Header',
            'resourceAreaWidth' => '10%'
        ];
    }

I suppose this PR requires some non regression tests to be sure that the other plugins are not affected by those changes.

Hope that helps.

Regards.
Florian.

@felahdab
Copy link
Author

felahdab commented Sep 8, 2024

@saade any comment on this ?

Regards.
Florian

@felahdab
Copy link
Author

@saade Hi again. No news from you since one month. Can you have a look at my PR ?
Regards.

@oxyac
Copy link

oxyac commented Oct 3, 2024

@saade This pull request makes the resource timeline usable. It contains only a few lines of code, please check it out.

@saade
Copy link
Owner

saade commented Oct 3, 2024

@felahdab @oxyac
I'm not familiar with Resources or the Resource Timeline plugin. Could one of you explain to me like I'm five what a Resource is and how it differs from a regular Event?

@oxyac
Copy link

oxyac commented Oct 3, 2024

Based on the docs, to display events in the calendar in Resource timeline mode, we need to use a different parameter in the JS object:

resources: [
    // your resource list
  ]

When switching to resourceTimeline, possible only after #66 PR, we can see resource tab but it cannot be filled with data until we merge this.

@saade Hope this makes sense

FullCalendar docs

@felahdab
Copy link
Author

felahdab commented Oct 3, 2024

@saade

Ressources are a way to group events in the resourcetimeline view. The fullcalendar component can load ressources either statically or thru a dynamic method.

This pull request makes it possible to load the resources from the livewire backend.

@saade
Copy link
Owner

saade commented Oct 3, 2024

A group of events, got it. Ty guys

@felahdab
Copy link
Author

felahdab commented Oct 5, 2024

@saade Can you give us your sentiment about this ? Do you intend to merge ? Do you need something more from us before merging ?

Regards.

@saade
Copy link
Owner

saade commented Oct 7, 2024

@felahdab I understand the needing for this and i'll review and merge as soon as i can. Right now i'm unable to do so.

If you really need this and can't wait, you may update your project to reference this branch.

To do so, temporarily add this PR's branch to the repositories property of your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/saade/filament-fullcalendar.git"
        }
    ]
}

Then update your dependency constraint to reference this branch:

{
    "require": {
        "saade/filament-fullcalendar": "felahdab:florianthecoder-introduce-methods-to-use-resources",
    }
}

Finally, run: composer update

@oxyac
Copy link

oxyac commented Mar 17, 2025

@saade How can I be of any help to get this merge request approved ?

@saade
Copy link
Owner

saade commented Mar 17, 2025

I would like to avoid making extra requests to the server, something alongs those lines this must be implemented to avoid that, please.

https://github.com/saade/filament-fullcalendar/blob/2.x/src/Widgets/Concerns/CanFetchEvents.php

@sprtk-ches
Copy link

For anyone who wants to use this in their code do the following

Change composer.json to look something like this

    "require": {
        "saade/filament-fullcalendar": "dev-florianthecoder-introduce-methods-to-use-resources",
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/felahdab/filament-fullcalendar.git"
        }
    ],
    "minimum-stability": "dev"

then run

composer update saade/filament-fullcalendar

Once/if this PR is merged, you can just revert these changes and it should work as expected.

@aurawindsurfing
Copy link

To be honest I loved the idea of full-calendar and filament integration but the speed at which this plugin is maintained tells me not to use it and just go full JS mode.

@luckykenlin
Copy link

Yep, totally agree
@aurawindsurfing.

That resource timeline feature really comes in handy for calendar-based booking systems.

@oxyac
Copy link

oxyac commented Jul 14, 2025

Tested this pull request locally, works great @saade @felahdab
Let's merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants