Skip to content

Commit

Permalink
v2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Nov 8, 2018
1 parent 1c02e3d commit ec27bd3
Show file tree
Hide file tree
Showing 39 changed files with 1,018 additions and 1,238 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Solspace Calendar Changelog

## 2.0.10 - 2018-11-08
### Changed
- Updated demo templates to use Bootstrap 4.1 and made some general improvements.
- Updated event validation to no longer allow multi-day events to span longer than 365 days to prevent performance issues.

### Fixed
- Fixed a bug where editing events on the front end with Select Dates rule enabled would result in an error.
- Fixed a bug where the `.one()` method was not working correctly for Event query.

## 2.0.9 - 2018-11-01
### Changed
- Updated demo templates approach for viewing individual recurrences to validate that the date segments in URL match against an available recurrence.
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "solspace/craft3-calendar",
"description": "The most powerful event management plugin for Craft.",
"version": "2.0.9",
"version": "2.0.10",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
{
"name": "Solspace",
Expand All @@ -17,7 +16,7 @@
"symfony/property-access": "^2.8|^3.0|^4.0",
"symfony/finder": "^2.8|^3.0|^4.0",
"symfony/filesystem": "^2.8|^3.0|^4.0",
"solspace/craft3-commons": "^1.0.8",
"solspace/craft3-commons": "^1.0.16",
"nesbot/carbon": "^1.22.1"
},
"autoload": {
Expand Down
25 changes: 24 additions & 1 deletion src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class EventQuery extends ElementQuery implements \Countable
{
const MAX_EVENT_LENGTH_DAYS = 365;

const FORMAT_MONTH = 'Ym';
const FORMAT_WEEK = 'YW';
const FORMAT_DAY = 'Ymd';
Expand Down Expand Up @@ -428,6 +430,27 @@ public function count($q = '*', $db = null): int
return $this->totalCount;
}

/**
* @param null $db
*
* @return array|\craft\base\ElementInterface|null
*/
public function one($db = null)
{
$oldLimit = $this->limit;
$this->limit = 1;

$events = $this->all($db);

$this->limit = $oldLimit;

if (\count($events) >= 1) {
return reset($events);
}

return null;
}

/**
* @param null $db
*
Expand Down Expand Up @@ -1243,7 +1266,7 @@ private function cacheEvents()
}

$day = $startDate->copy();
for ($i = 0; $i <= $diffInDays; $i++) {
for ($i = 0; $i <= $diffInDays && $i <= self::MAX_EVENT_LENGTH_DAYS; $i++) {
if ($this->overlapThreshold && $i !== 0 && $i === $diffInDays) {
if (DateHelper::isDateBeforeOverlap($endDate, $this->overlapThreshold)) {
break;
Expand Down
6 changes: 6 additions & 0 deletions src/Elements/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Event extends Element implements \JsonSerializable
const UNTIL_TYPE_UNTIL = 'until';
const UNTIL_TYPE_COUNT = 'count';

const SPAN_LIMIT_DAYS = 365;

/** @var int */
private static $overlapThreshold;

Expand Down Expand Up @@ -1366,6 +1368,10 @@ public function validateDates()
if ($this->startDate >= $this->endDate) {
$this->addError('startDate', Calendar::t('Start Date must be before End Date'));
}

if ($this->startDate->diffInDays($this->endDate, true) > self::SPAN_LIMIT_DAYS) {
$this->addError('startDate', Calendar::t('The maximum time span of an event is 365 days'));
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Models/SelectDateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ class SelectDateModel extends Model

/** @var \DateTime */
public $date;

/**
* @return string
*/
public function __toString(): string
{
return $this->date->format('Y-m-d');
}
}
6 changes: 0 additions & 6 deletions src/codepack/assets/css/bootstrap-theme.min.css

This file was deleted.

1 change: 0 additions & 1 deletion src/codepack/assets/css/bootstrap-theme.min.css.map

This file was deleted.

6 changes: 0 additions & 6 deletions src/codepack/assets/css/bootstrap.min.css

This file was deleted.

1 change: 0 additions & 1 deletion src/codepack/assets/css/bootstrap.min.css.map

This file was deleted.

10 changes: 4 additions & 6 deletions src/codepack/assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* GLOBAL */

body {
margin-top: 30px;
}
.ss-pageinfo {
margin-top: 30px;
}
Expand All @@ -19,7 +16,7 @@ body {
width: 100%;
}
#month_calendar table, #month_calendar tr, #month_calendar td {
padding: 0px;
padding: 0;
}
#month_calendar_outer {
width: 100%;
Expand Down Expand Up @@ -144,7 +141,7 @@ body {
#month_calendar #month_year th.right {
text-align: right;
}
#month_calendar .popover-title span.event_time {
.popover-header span.event_time {
display: block;
color: #4f4f4f;
font-size: 85%;
Expand Down Expand Up @@ -285,7 +282,7 @@ body {

width: 30px;
height: 30px;
padding: 5px 0 0;
padding: 3px 0 0;

border-radius: 4px;

Expand All @@ -302,6 +299,7 @@ body {
.freq-list.freq-list-large input[type=checkbox] + label {
display: block;
width: 100%;
padding: 3px 10px 0;
}

.freq-list.freq-list-large > div div.row {
Expand Down
Binary file not shown.
Loading

0 comments on commit ec27bd3

Please sign in to comment.