-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add resource #423
Add resource #423
Conversation
🎉 thanks for picking this up! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind posting some screens as well to get an idea of it? We'll probably have to tweak the styles for when tehre are lots of resources to allow horizontal scrolling
src/TimeGrid.js
Outdated
@@ -174,10 +176,14 @@ export default class TimeGrid extends Component { | |||
|
|||
let gutterRef = ref => this._gutters[1] = ref && findDOMNode(ref); | |||
|
|||
let eventsRendered = resources ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resources && resources.length
?
src/TimeGrid.js
Outdated
return resources.map((resource, id) => { | ||
|
||
let eventsToDisplay = daysEvents.filter( | ||
event => event.resourceId === resource.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the events
I don't want to be prescriptive about the shape of the data in resources
so can we add accessor
props for these fields like we do with startAccessor, et al?
src/TimeGrid.js
Outdated
|
||
</div> | ||
</div> | ||
); | ||
} | ||
renderEventsWithResource(range, events, today, resources) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this method be joined with renderEvents
I'd be worried the common code will diverge unintentionally
@TeaBough Is this still happening? |
I couldn't work on it during the french summer. But I think I can work on this this weekend ! |
I think this feature would be a significant game changer here 👍 |
46a3634
to
081a4ef
Compare
@XVincentX @jquense I've finally updated this PR |
Awesome thanks! I'll try and review asap |
looks great! Can you rebase? The one concern i see here is that with a few resources the rendering hangs for a few seconds as you switch to the tab. I'm not sure what it is that is causing it, it may just be the number of divs being rendered as the grid since I see the same thing with or without any events. |
15c3b68
to
7396dee
Compare
I've rebased |
This is great! Exactly what I've been looking for. @jquense any chance that this will be added soon? |
7396dee
to
eaa5b93
Compare
Hey guys, |
Any updates? |
Looking forward to this as well. Happy to help moving this along if it requires some testing or updates.... |
If anyone wants to help, the last remaining thing is the performance concerns I noted in my comment. If anyone wants to take a crack at optimizing/testing that a bit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.PropTypes won't work in React16, and the rest of this file just uses PropTypes
src/DayColumn.js
Outdated
@@ -64,6 +64,7 @@ class DayColumn extends React.Component { | |||
dayWrapperComponent: elementType, | |||
eventComponent: elementType, | |||
eventWrapperComponent: elementType.isRequired, | |||
resource: React.PropTypes.string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove React.
here: just PropTypes.string
Here's a screenshot looking at the Chrome Dev Tool's performance tab when the resource example is created in Storybook. I'm no expert, but it appears that there isn't anything new per se that this PR introduces that reduces performance, it's just the fact that you're now rendering N number of Thoughts? |
yeah it may just be the extra columns now. The issue is that it's gonna worse and worse the more resources you have. One solution may be to do something completely different layout wise, like full calendar: https://fullcalendar.io/scheduler/ something a bit more amenable to simpler layout. another option is to maybe try and virtualize the TimeColumns so it's not rendering extra divs. We can also jsut try and reduce the amount of DOM elements rendered in the first place |
I'm currently looking at a way of possibly just having one DayColumn component and just using styling to put the events into different columns... does that seem like a reasonable solution? |
I'm up for whatever works and isnt too hacky :P |
On second thought, changing the CSS works well when it comes to displaying the events, but would require more work when you consider creating events. Hmm. I'm not really sure what the best way to go about doing this is then, other than what has already been done here. Perhaps just looking at optimizing TimeColumns to make them not so heavy... |
Will this find its way in the master somehow? @TeaBough |
5ce0c96
to
02181b1
Compare
@XVincentX I've rebased with master and removed |
if we can make CI green i'm ok merging for now. We really need to address the performance issues though |
@jquense done |
Any thoughts on when next version (including this) will be released? (Many thanks for a great package!) |
Could you please add the new "resources" API in the documentation? Thank you, |
Does anyone have a working example? Thank you |
any chance to know if this is implemented in 1.8.1? with a sort of documentation? thx! |
I've created this PR, that serve the same purpose as #373. The difference is that the logic of the resource is done directly in the
TimeGrid
instead of creating aResourceGrid
which DRY things up and allow to enjoy resource in the week view as well.