Rock icon indicating copy to clipboard operation
Rock copied to clipboard

CalendarEvents and EventScheduledInstance Lava Commands are not Required to be Enabled

Open mikedotmundy opened this issue 4 months ago • 0 comments

Description

Enabled Lava Commands Calendar Events and Event Scheduled Instance are not required to be enabled (selected) in order to be used.

I have tested this with 2 blocks: HTML Content and Persisted Dataset Detail (both Obsidian and DotLiquid versions of this block). I am not sure if other blocks have the same issue.

Example 1

Consider the following example in the Persisted Dataset Detail block. In this scenario, it should be required that I select Calendar Events from the Enabled Lava Commands Section. As you can see, I do not have it selected and yet it still works.

Screenshot 2024-10-23 at 07 20 28

Example 2

Consider the following example in the HTML Content block. In this scenario, it should be required that I select Calendar Events from the Enabled Lava Commands Section. As you can see, I do not have it selected and yet it still works.

Screenshot 2024-10-23 at 07 22 37 Screenshot 2024-10-23 at 07 22 47

While I have not included screenshots, the same issue applies to the Event Scheduled Instance Lava Command in both blocks. See steps below.

Actual Behavior

You are not required to enable Calendar Events and Event Scheduled Instance Lava Commands in order to use them. (Only tested in the HTML Content Block and both Obsidian and DotLiquid versions of the Persisted Dataset Detail block.

Expected Behavior

You should be required to enable Calendar Events and Event Scheduled Instance Lava Commands in order to use them. (Only tested in the HTML Content Block and both Obsidian and DotLiquid versions of the Persisted Dataset Detail block.

Steps to Reproduce

Persisted Dataset Detail Block

If its not been refreshed, see example here: https://rockrmslatest.com/admin/cms/persisted-datasets/3

  • Ensure you have an upcoming event for the CalendarId = 1
  • Create a new Persisted Dataset and place the following code in the Build Script:
[
    {% calendarevents calendarid:'1' %}
        {% for item in EventScheduledInstances %}
            {
                "Name": {{ item.Name | ToJSON }},
                "Date": {{ item.Date | ToJSON }},
                "Time": {{ item.Time | ToJSON }}
            }{% unless forloop.last %},{% endunless %}
        {% endfor %}
    {% endcalendarevents %}
]
  • Do NOT enable the Calendar Events Lava Command
  • Save and manually refresh the Persisted Dataset.
  • In an HTML Content block, enter the following code, and see that it does in fact work (you may have to change the dataset key, depending on your settings):
{% assign testDataset = 'test' | PersistedDataset %}

{% for item in testDataset %}
    {{ item.Name }}<br>
    {{ item.Date }}<br>
    {{ item.Time }}<br>
{% endfor %}

You can do the same thing with Event Scheduled Instance Lava Command. Follow the same steps as above, but use this Build Script instead:

[
    {% eventscheduledinstance eventid:'2' maxoccurrences:'25' daterange:'2m' %}
        {% for item in EventScheduledInstances %}
            {
                "Name": {{ item.Name | ToJSON }},
                "Date": {{ item.Date | ToJSON }},
                "Time": {{ item.Time | ToJSON }}
            }{% unless forloop.last %},{% endunless %}
        {% endfor %}
    {% endeventscheduledinstance %}
]



HTML Content Block

  • Ensure you have an upcoming event for the CalendarId = 1
  • Create an HTML Block on a page and paste the following code:
{% calendarevents calendarid:'1' %}
    {% for item in EventScheduledInstances %}
        {{ item.Name }} 
        on {{ item.Date }}
        at {{ item.Time }}
        for {{ item.AudienceNames | Join:', ' }} 

        Contact: {{ item.EventItemOccurrence.ContactEmail }}
    {% endfor %}
{% endcalendarevents %}
  • Do NOT enable the Calendar Events Lava Command
  • See that content displays and it should not, because you don't have the Lava Command selected.

You can do the same thing with Event Scheduled Instance Lava Command. Follow the same steps as above, but use this code instead:

{% eventscheduledinstance eventid:'2' maxoccurrences:'25' daterange:'2m' %}
    {% for item in EventScheduledInstances %}
        {{ item.Name }} 
        on {{ item.Date }}
        at {{ item.Time }}
        involving {{ item.AudienceNames | Join:', ' }} <br>
        Contact: {{ item.EventItemOccurrence.ContactPersonAlias.Person.FullName }} 
           at {{ item.EventItemOccurrence.ContactEmail }}
    {% endfor %}
{% endeventscheduledinstance %}

Issue Confirmation

  • [X] Perform a search on the Github Issues to see if your bug or enhancement is already reported.
  • [X] Reproduced the problem on a fresh install or on the demo site.

Rock Version

v16.6, v17.0

Client Culture Setting

en-US

mikedotmundy avatar Oct 23 '24 11:10 mikedotmundy