Is there a field or filter for views to hide an Event (Instance entity) when all available registration are taken?

In other words: only the free Events (Instance entity) should be displayed.

Thanks.

Comments

tylvis created an issue. See original summary.

owenbush’s picture

Assuming what you want to do is filter out event instances that do not have any spaces left available (registrations are full)?

If so, then there is no way to do that currently, but it shouldn't be too difficult to achieve with a custom view filter. I can try and take a look at this for you soon.

tylvis’s picture

Sorry for my awkward explanation. Would be great if there was a solution.
Thank you very much for the great module.

Thanks.

mrpauldriver’s picture

I've been thinking about this myself and different scenarios come to mind.

Yes, there is a case for hiding 'sold out' events, but there is also a case for maintaining visibility, but greying them out or otherwise labelling them as sold out. From a presentation angle, some css classes would also be helpful.

We also have to think about wait lists.

tylvis’s picture

Is it possible to specify a Field Inheritance (e.g. privacy boolesch-field) in the registration form and depending on whether this field has been filled in, this data is then saved in the Event Instance entity?

Then I can use the boolesch-field (Event Instance entity) as a filter in events-views.

owenbush’s picture

Tylvis - I'm not sure I follow your last request. Is that related to filtering events based on whether the event is full? If not, it might be better breaking it out into a separate issue so it does not get lost in this issue.

owenbush’s picture

This is actually proving to be harder than I thought. I was easily able to add view fields to display the number of registrations, waitlisted users, and available spaces.

The problem is that because you can register either for the instance, or the entire series, there is no simple MySQL query you can write to fetch the number of registrations etc because your view may contain a mix of series registration events and instance registration events.

You cannot filter on a computed field, which would be the obvious way to do it (and is the way I've done for the fields themselves). So I'll need to think on this one and see what can be done.

tylvis’s picture

Can the module Views Field View help here?

owenbush’s picture

Views Field View I don't think has the ability to create filters, it can add fields to a view based on another view, but not allow the view to be filtered.

I have code written to allow adding the number of waitlisted users, registered users, and spaces available to a view - but you cannot filter by them at this time, you can only display them.

I'm still thinking through how I could achieve filtering. I think i have an idea but need some time to figure it out.

For Paul's request about adding CSS classes if an event is full, that should be possible in twig I would imagine. If you add the new field I've created (when I submit the patch) you could then override the view row twig template for this view, and then dynamically add a class to the row if the availability is 0.

the_glitch’s picture

I'm guessing displays for this kind of filtering would need to have some sort of configurable CSS classes with settings such as "Hide Full Event", "Grey Out Full Event" and "Full but accepting waitlist reserves" because of the fact that if an event has waitlisting enabled you wouldn't want to hide that event.

Is it possible to somehow put the Spaces Available value into a field which could then be used as a filter in views which is triggered when the value reaches 0?
... and would then display using the CSS depending on which class was selected in the Series form?

owenbush’s picture

Displaying a field for Spaces Available is easy (I have that code ready to go)

But there is a difference between a field and a filter which makes this tricky.

Effectively a field can be computed at display time, this is a good way to do the Spaces Available because I can programmatically grab the most up-to-date registration counts and display them.

The problem is computed fields do not have database fields or tables associated with them, so filtering is not really possible (there are ways around it with some clever joins) but effectively the issue is made difficult by registrations being for entire series or instances, we need to check the series to know what type of registration an event uses in order to calculate the registration counts.

I have some thoughts but need to experiment.

the_glitch’s picture

When will the Spaces Available field be released in an update?

owenbush’s picture

Status: Active » Needs review
StatusFileSize
new17.87 KB

Attached is a patch which adds the following:

- A view field to display the number of registrations for an event instance (or series if it is a series registration event)
- A view field to display the number of waitlisted users for an event instance (or series if it is a series registration event)
- A view field to display the amount of spaces available (effectively capacity - registrations) for an event instance (or series if it is a series registration event)
- A view filter to filter event instances either by those which have availability, or those that are full. This filter is exposable too.

Marking this as 'needs review'.

the_glitch’s picture

So far so good.

However, having the words "Event Instance" as a prefix in the view field labels is a little superfluous.

Still have to test the filter.

owenbush’s picture

StatusFileSize
new2.23 KB
new17.77 KB

I have updated the patch to remove the superfluous "Event Instance" from the field and filter labels.

I've provided an interdiff to show the changes.

mrpauldriver’s picture

mrpauldriver’s picture

mrpauldriver’s picture

These view fields will be very useful, but the they are not reliable when Tag based view caching is enabled. Can this be resolved somehow? Or would caching be better disabled by default - it is an admin view after all and not one which effects frontend performance.

As discussed in #3155644: Can not add Event Registration (capacity) field to event instance admin view I think that capacity should be added to this patch, as it is totally related.

owenbush’s picture

Paul, can you describe what you are seeing with caching - I'll presume that when the view is tag cached you're not seeing the values update even when adding more registrations? I can take a look at the caching but my presumption would be that if the view as a whole is cached then we'd have to figure out how to invalidate the caches for the view results when registrations are added/removed, which may or may not be simple. But I'll take a look. Certainly not caching would be a workaround for now.

I'll look into the capacity field for you.

mrpauldriver’s picture

I'll presume that when the view is tag cached you're not seeing the values update even when adding more registrations?

Yes, that's correct.

owenbush’s picture

StatusFileSize
new15.19 KB
new30.55 KB

Attached is a patch with several fixes.

I've added the 'Capacity' field so it can be displayed in views. I also hid all the other Event Registration fields, because they do not actually work in views at this time, capacity is a special case. I also did the same with the recurring date fields, as those are not easily displayable in views.

I added some cache tag clearing of event series and event instances when creating or deleting registrants, which should keep those values in the view up to date.

I fixed the issue with waitlist count and registration count only ever being '1'

I modified the messaging a little when someone registers for an event and takes the last spot. It seemed to me that the message was being displayed but that it was confusing when you saw the form now saying "We cannot complete your registration" it now says "Registration Full".

  • owenbush committed 2675b7f on 8.x-1.x
    Issue #3150719 by owenbush, tylvis, MrPaulDriver, the_glitch: Hide an...

  • owenbush committed cfedfd7 on 2.0.x
    Issue #3150719 by owenbush, tylvis, MrPaulDriver, the_glitch: Hide an...
owenbush’s picture

Status: Needs review » Fixed

Given this has been outstanding for a while I've gone ahead and merged it so its no longer a blocker for other work. If there are still issues then we should address those in a separate issue if possible.

Thanks for all involved.

mrpauldriver’s picture

Agh. I was just about to test and review. I've been busy with client work :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.