Skip to content

Commit

Permalink
v2.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Oct 30, 2019
1 parent fb137be commit 53ebe92
Show file tree
Hide file tree
Showing 24 changed files with 753 additions and 831 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Solspace Calendar Changelog

## 2.0.25 - 2019-10-30
### Changed
- Updated all Calendar CP page headings to be cleaner (removal of `Calendar: `, etc) and translatable.
- Updated the plugin icon.

### Fixed
- Fixed a bug where the Craft 3.2+ Element Export feature on Events index page would error.
- Fixed a bug where Calendar event data was not being included for all Sites in the Craft search index.
- Fixed a bug where including a Calendar Event field type in another Craft element CP index page's visible columns would error.
- Fixed a bug where the Calendar Event field type in another Craft element CP index page would only display 1 related event.
- Fixed a bug where the `Today` button in Month/Week/Day CP views wasn't translatable.
- Fixed a bug where the `calendar.calendars` function did not work with `orderBy` parameter.

## 2.0.24 - 2019-08-14
### Fixed
- Fixed a bug where ICS export was not exporting correctly for Safari.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solspace/craft3-calendar",
"description": "The most powerful event management plugin for Craft.",
"version": "2.0.24",
"description": "The most reliable and powerful event management plugin for Craft.",
"version": "2.0.25",
"type": "craft-plugin",
"authors": [
{
Expand All @@ -25,7 +25,7 @@
}
},
"extra": {
"schemaVersion": "2.0.5",
"schemaVersion": "2.0.6",
"handle": "calendar",
"class": "Solspace\\Calendar\\Calendar",
"name": "Calendar",
Expand Down
1 change: 1 addition & 0 deletions src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Calendar extends Plugin
'Couldn’t save event.',
'Are you sure you want to enable ICS sharing for this calendar?',
'Are you sure you want to disable ICS sharing for this calendar?',
'Today',
];

/** @var bool */
Expand Down
17 changes: 4 additions & 13 deletions src/Controllers/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ private function renderEditForm(Event $event, string $title): Response
$siteIds = [\Craft::$app->getSites()->getPrimarySite()->id];
}

if (!$event->enabled) {
$enabledSiteIds = [];
}

$previewActionUrl = 'calendar/events/preview';
if (version_compare(\Craft::$app->getVersion(), '3.1', '>=')) {
$previewActionUrl = \Craft::$app->getSecurity()->hashData($previewActionUrl);
Expand Down Expand Up @@ -435,10 +439,7 @@ private function renderEditForm(Event $event, string $title): Response
);
}

$siteHandle = $event->getSite()->handle;

$weekStartDay = $this->getSettingsService()->getWeekStartDay();

$variables = [
'name' => self::EVENT_FIELD_NAME,
'event' => $event,
Expand All @@ -462,16 +463,6 @@ private function renderEditForm(Event $event, string $title): Response
'showPreviewBtn' => $showPreviewButton,
'shareUrl' => $shareUrl,
'site' => $event->getSite(),
'crumbs' => [
['label' => Calendar::t('calendar'), 'url' => UrlHelper::cpUrl('calendar')],
['label' => Calendar::t('Events'), 'url' => UrlHelper::cpUrl('calendar/events')],
[
'label' => $title,
'url' => UrlHelper::cpUrl(
'calendar/events/' . ($event->id ?: 'new/' . $calendar->handle) . '/' . $siteHandle
),
],
],
];

return $this->renderTemplate('calendar/events/_edit', $variables);
Expand Down
10 changes: 10 additions & 0 deletions src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ public function one($db = null)
*/
public function all($db = null): array
{
// If an array data is requested - return it as is, without
// fetching occurrences
if ($this->asArray) {
return parent::all();
}

$configHash = $this->getConfigStateHash();

// Nasty elements index hack
Expand Down Expand Up @@ -1151,6 +1157,10 @@ function ($data) {

$eventsById = [];
foreach ($events as $event) {
if (is_array($event)) {
$event = new Event($event);
}

$eventsById[$event->getId()] = $event;
}

Expand Down
36 changes: 35 additions & 1 deletion src/FieldTypes/EventFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Solspace\Calendar\FieldTypes;

use craft\base\ElementInterface;
use craft\elements\db\ElementQueryInterface;
use craft\elements\db\ElementQuery;
use craft\fields\BaseRelationField;
use Solspace\Calendar\Calendar;
use Solspace\Calendar\Elements\Db\EventQuery;
Expand All @@ -27,6 +27,14 @@ public static function defaultSelectionLabel(): string
return Calendar::t('Add an event');
}

/**
* @inheritdoc
*/
public static function valueType(): string
{
return EventQuery::class;
}

/**
* @return string
*/
Expand All @@ -35,6 +43,32 @@ protected static function elementType(): string
return Event::class;
}

/**
* @param mixed $value
* @param ElementInterface $element
*
* @return string
*/
public function getTableAttributeHtml($value, ElementInterface $element): string
{
if (is_array($value)) {
$html = '';
foreach ($value as $event) {
$html .= parent::getTableAttributeHtml([$event], $element);
}

return $html;
}

return parent::getTableAttributeHtml($value, $element);
}

/**
* @param mixed $value
* @param ElementInterface|null $element
*
* @return ElementQuery|mixed
*/
public function normalizeValue($value, ElementInterface $element = null)
{
$query = parent::normalizeValue($value, $element);
Expand Down
3 changes: 2 additions & 1 deletion src/Library/Attributes/AbstractAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ private function parseAttributes($attributes = null)
continue;
}

if (in_array($attribute, array('order', 'limit', 'sort'), true)) {
if (in_array($attribute, ['order', 'orderBy', 'limit', 'sort'], true)) {
switch ($attribute) {
case 'order':
case 'orderBy':
$this->setOrder($value);
break;

Expand Down
19 changes: 19 additions & 0 deletions src/Services/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ public function saveEvent(Event $event, bool $validateContent = true, bool $bypa
try {
$isSaved = \Craft::$app->elements->saveElement($event, $validateContent);
if ($isSaved) {

$this->reindexSearchForAllSites($event);

if ($transaction !== null) {
$transaction->commit();
}
Expand Down Expand Up @@ -406,4 +409,20 @@ public function requireEventEditPermissions($event): bool

return true;
}

/**
* @param Event $event
*
* @throws \craft\errors\SiteNotFoundException
*/
private function reindexSearchForAllSites(Event $event) {

foreach (\Craft::$app->getSites()->getAllSites() as $site) {
$event->siteId = $site->id;
$searchService = \Craft::$app->getSearch();
$searchService->indexElementAttributes($event);
}

return;
}
}
2 changes: 1 addition & 1 deletion src/codepack/templates/calendars.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>Events by Calendar</h3>
{% set calendarHandle = segment2 ? segment2 : null %}
{% set calendars = craft.calendar.calendars({
handle: calendarHandle,
order: "name",
orderBy: "name",
sort: "asc"
}) %}

Expand Down
39 changes: 23 additions & 16 deletions src/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions src/migrations/m191022_124711_AddMultiSitesFix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Solspace\Calendar\migrations;

use Carbon\Carbon;
use Craft;
use craft\db\Migration;
use craft\db\Query;
use Solspace\Calendar\Elements\Event;
use Solspace\Calendar\Library\DateHelper;

/**
* m180628_091905_MigrateSelectDates migration.
*/
class m191022_124711_AddMultiSitesFix extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
$allSites = Craft::$app->getSites()->getAllSites();

if (count($allSites) > 1) {

$query = Event::find()
->setAllowedCalendarsOnly(false)
->status(null)
->limit(null)
->offset(null);

/** @var Event[] $events */
$events = $query->all();

if ($events) {
foreach ($events as $event) {
foreach ($allSites as $site) {
$event->siteId = $site->id;
$searchService = Craft::$app->getSearch();
$searchService->indexElementAttributes($event);
}
}
}
}

return true;
}

/**
* @inheritdoc
*/
public function safeDown()
{
return false;
}
}
4 changes: 1 addition & 3 deletions src/templates/calendars/_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

{% set selectedSubnavItem = "calendars" %}
{% set saveShortcutRedirect = 'calendar/calendars/{handle}' %}
{% set title = "Calendar: Calendars - {title}"|t('calendar', {title: title}) %}

{% set crumbs = [
{ label: "Calendar"|t('calendar'), url: url('calendar') },
{ label: "calendars"|t('calendar'), url: url('calendar/calendars') },
{ label: calendar.name ? calendar.name : "New Calendar"|t('calendar'), url: '' },
{ label: "Calendars"|t('calendar'), url: url('calendar/calendars') },
] %}

{% set fullPageForm = true %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/calendars/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "calendar/layouts/_calendarsLayout" %}

{% set selectedSubnavItem = "calendars" %}
{% set title = "Calendar"|t %}
{% set title = "Calendars"|t('calendar') %}

{% set content %}
<div id="nocalendars"{% if calendars %} class="hidden"{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/codepack/_no_codepacks.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "calendar/layouts/_settings" %}

{% set selectedSubnavItem = "settings" %}
{% set title = "Solspace Calendar: Demo Templates" %}
{% set title = "Demo Templates" %}
{% block actionButton %}{% endblock %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/codepack/_post_install.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% import "_includes/forms" as forms %}

{% set selectedSubnavItem = "settings" %}
{% set title = "Solspace Calendar: Demo Templates" %}
{% set title = "Demo Templates" %}
{% block actionButton %}{% endblock %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/codepack/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% import "_includes/forms" as forms %}

{% set selectedSubnavItem = "settings" %}
{% set title = "Solspace Calendar: Demo Templates" %}
{% set title = "Demo Templates" %}

{% macro listFiles(file) %}
{% import _self as dir %}
Expand Down
Loading

0 comments on commit 53ebe92

Please sign in to comment.