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

Difficult to subclass views for creating custom views #3657

Closed
arshaw opened this issue Apr 27, 2017 · 3 comments
Closed

Difficult to subclass views for creating custom views #3657

arshaw opened this issue Apr 27, 2017 · 3 comments

Comments

@arshaw
Copy link
Member

arshaw commented Apr 27, 2017

As @benvan points out in #3357, if you want to subclass a standard view, you also need to port over it's defaults as well. Otherwise, in agendaview at least, slotDuration will be null and there will be an infinite loop. Workaround:

var agendaViewMeta = FC.views.agenda;
var AgendaView = agendaViewMeta['class'];

FC.views.myCustomView = {
  class: AgendaView.extend({ }),
  defaults: agendaViewMeta.defaults
}

It'd be nicer to bake in the options closer to the class. So, in agenda/config.js for example:

AgendaView.defaults = {
	allDaySlot: true,
	slotDuration: '00:30:00',
	slotEventOverlap: true // a bad name. confused with overlap/constraint system	
};

fcViews.customView = AgendaView.extendWithDefaults({ // or something like this
	duration: { days: 1 }
});

Which would allow for something like this:

fcViews.myCustomView = FC.AgendaView.extendWithOptions({
	// more defaults
});
@arshaw
Copy link
Member Author

arshaw commented Oct 2, 2018

This issue has been addressed in the latest alpha release (4.0.0-alpha.2)
See the blog post »

This has gotten better:
https://fullcalendar.io/docs/v4/release-notes#view-api

but still might change a bit

@arshaw
Copy link
Member Author

arshaw commented Dec 26, 2018

I'm closing this issue to signify that it's implemented (since v4-alpha2). I'll comment on this thread again when v4 is officially released, or if there are further API changes with this.

@arshaw arshaw closed this as completed Dec 26, 2018
@arshaw
Copy link
Member Author

arshaw commented Mar 20, 2019

V4 was officially released a few days ago!

Simply subclassing a view is all that's required. All options directed at the base view will automatically be applied to the subclass views, without requiring any hacks.

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

No branches or pull requests

1 participant