Skip to content

Commit

Permalink
Merge pull request #208 from solspace/fix/v4/SFT-215
Browse files Browse the repository at this point in the history
SFT-215 - Improved Calendar Event Site Status list
  • Loading branch information
kjmartens authored Feb 7, 2023
2 parents a006d27 + ceeb43f commit d579476
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/plugin/src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ public function all($db = null): array
if (\in_array($context, ['index', 'modal'], true)) {
$this->loadOccurrences = false;
}
// If we save an event via the events edit page or via the slide out panel, dont use the cached events
$action = \Craft::$app->request->post('action');
if (\in_array($action, ['elements/save', 'calendar/events/save-event'], true)) {
return parent::all();
}
}

if (null === $this->events || self::$lastCachedConfigStateHash !== $configHash) {
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin/src/Elements/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ public function getFieldLayout(): ?FieldLayout
if ($this->getCalendar()->hasTitleField) {
$tabs = $fieldLayout->getTabs();

if (empty($tabs)) {
$tab = new FieldLayoutTab();
$tab->name = 'Content';
$tab->setLayout($fieldLayout);

$fieldLayout->setTabs([$tab]);

$tabs = $fieldLayout->getTabs();
}

$hasTitle = !empty(
array_filter(
$tabs,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Services/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function saveEvent(Event $event, bool $validateContent = true, bool $bypa
$transaction = \Craft::$app->db->beginTransaction();

try {
$isSaved = \Craft::$app->elements->saveElement($event, $validateContent, $isNewEvent);
$isSaved = \Craft::$app->elements->saveElement($event, $validateContent);
if (!$isSaved) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin/src/templates/events/_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@
on: event.enabled
}) }}

{% for enabledCalendarSiteId in craft.calendar.calendarSites.getAllEnabledSiteIds()|sort %}
{% set site = craft.app.sites.getSiteById(enabledCalendarSiteId) %}
{% for calendarSiteId, calendarSite in craft.calendar.calendarSites.getSiteSettingsForCalendar(calendar)|sort((a, b) => a.site.id <=> b.site.id) %}
{% set site = craft.app.sites.getSiteById(calendarSiteId) %}
{{ forms.lightswitchField({
label: "{site}"|t('app', { site: site.name }),
id: 'enabledForSite-' ~ site.id,
Expand Down

0 comments on commit d579476

Please sign in to comment.