Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13983236
D12787.id30738.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12787.id30738.diff
View Options
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
@@ -323,11 +323,15 @@
if ($start_month == $now_month && $start_year == $now_year) {
$month_view = new PHUICalendarMonthView(
+ $this->getDateFrom($query),
+ $this->getDateTo($query),
$start_month,
$start_year,
$now_day);
} else {
$month_view = new PHUICalendarMonthView(
+ $this->getDateFrom($query),
+ $this->getDateTo($query),
$start_month,
$start_year);
}
diff --git a/src/view/phui/calendar/PHUICalendarDayView.php b/src/view/phui/calendar/PHUICalendarDayView.php
--- a/src/view/phui/calendar/PHUICalendarDayView.php
+++ b/src/view/phui/calendar/PHUICalendarDayView.php
@@ -170,33 +170,13 @@
$header = $this->renderDayViewHeader();
$sidebar = $this->renderSidebar();
-
- $errors = array();
-
- $range_start_epoch = $this->rangeStart->getEpoch();
- $range_end_epoch = $this->rangeEnd->getEpoch();
-
- if (($range_start_epoch != null &&
- $range_start_epoch < $day_end &&
- $range_start_epoch > $day_start) ||
- ($range_end_epoch != null &&
- $range_end_epoch < $day_end &&
- $range_end_epoch > $day_start)) {
- $errors[] = pht('Part of the day is out of range');
- }
-
- if (($this->rangeEnd->getEpoch() != null &&
- $this->rangeEnd->getEpoch() < $day_start) ||
- ($this->rangeStart->getEpoch() != null &&
- $this->rangeStart->getEpoch() > $day_end)) {
- $errors[] = pht('Day is out of query range');
- }
+ $warnings = $this->getQueryRangeWarning();
$table_box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($all_day_event_box)
->appendChild($table)
- ->setFormErrors($errors)
+ ->setFormErrors($warnings)
->setFlush(true);
$layout = id(new AphrontMultiColumnView())
@@ -226,6 +206,35 @@
return $all_day_events;
}
+ private function getQueryRangeWarning() {
+ $errors = array();
+
+ $range_start_epoch = $this->rangeStart->getEpoch();
+ $range_end_epoch = $this->rangeEnd->getEpoch();
+
+ $day_start = $this->getDateTime();
+ $day_end = id(clone $day_start)->modify('+1 day');
+
+ $day_start = $day_start->format('U');
+ $day_end = $day_end->format('U') - 1;
+
+ if (($range_start_epoch != null &&
+ $range_start_epoch < $day_end &&
+ $range_start_epoch > $day_start) ||
+ ($range_end_epoch != null &&
+ $range_end_epoch < $day_end &&
+ $range_end_epoch > $day_start)) {
+ $errors[] = pht('Part of the day is out of range');
+ }
+
+ if (($this->rangeEnd->getEpoch() != null &&
+ $this->rangeEnd->getEpoch() < $day_start) ||
+ ($this->rangeStart->getEpoch() != null &&
+ $this->rangeStart->getEpoch() > $day_end)) {
+ $errors[] = pht('Day is out of query range');
+ }
+ }
+
private function renderSidebar() {
$this->events = msort($this->events, 'getEpochStart');
$week_of_boxes = $this->getWeekOfBoxes();
diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php
--- a/src/view/phui/calendar/PHUICalendarMonthView.php
+++ b/src/view/phui/calendar/PHUICalendarMonthView.php
@@ -1,6 +1,8 @@
<?php
final class PHUICalendarMonthView extends AphrontView {
+ private $rangeStart;
+ private $rangeEnd;
private $day;
private $month;
@@ -40,7 +42,16 @@
return $this;
}
- public function __construct($month, $year, $day = null) {
+ public function __construct(
+ $range_start,
+ $range_end,
+ $month,
+ $year,
+ $day = null) {
+
+ $this->rangeStart = $range_start;
+ $this->rangeEnd = $range_end;
+
$this->day = $day;
$this->month = $month;
$this->year = $year;
@@ -188,9 +199,12 @@
phutil_implode_html("\n", $table),
));
+ $warnings = $this->getQueryRangeWarning();
+
$box = id(new PHUIObjectBoxView())
->setHeader($this->renderCalendarHeader($first))
- ->appendChild($table);
+ ->appendChild($table)
+ ->setFormErrors($warnings);
if ($this->error) {
$box->setInfoView($this->error);
@@ -250,6 +264,37 @@
return $header;
}
+ private function getQueryRangeWarning() {
+ $errors = array();
+
+ $range_start_epoch = $this->rangeStart->getEpoch();
+ $range_end_epoch = $this->rangeEnd->getEpoch();
+
+ $month_start = $this->getDateTime();
+ $month_end = id(clone $month_start)->modify('+1 month');
+
+ $month_start = $month_start->format('U');
+ $month_end = $month_end->format('U') - 1;
+
+ if (($range_start_epoch != null &&
+ $range_start_epoch < $month_end &&
+ $range_start_epoch > $month_start) ||
+ ($range_end_epoch != null &&
+ $range_end_epoch < $month_end &&
+ $range_end_epoch > $month_start)) {
+ $errors[] = pht('Part of the month is out of range');
+ }
+
+ if (($this->rangeEnd->getEpoch() != null &&
+ $this->rangeEnd->getEpoch() < $month_start) ||
+ ($this->rangeStart->getEpoch() != null &&
+ $this->rangeStart->getEpoch() > $month_end)) {
+ $errors[] = pht('Month is out of query range');
+ }
+
+ return $errors;
+ }
+
private function getNextYearAndMonth() {
$next = $this->getDateTime();
$next->modify('+1 month');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 21, 5:00 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6733329
Default Alt Text
D12787.id30738.diff (5 KB)
Attached To
Mode
D12787: Calendar month view should notify user if all or part of the month was not included in the query search
Attached
Detach File
Event Timeline
Log In to Comment