Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13998179
D16754.id40352.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D16754.id40352.diff
View Options
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
@@ -3,6 +3,10 @@
final class PhabricatorCalendarEventListController
extends PhabricatorCalendarController {
+ private $viewYear;
+ private $viewMonth;
+ private $viewDay;
+
public function shouldAllowPublic() {
return true;
}
@@ -16,6 +20,10 @@
$month = $request->getURIData('month');
$day = $request->getURIData('day');
+ $this->viewYear = $year;
+ $this->viewMonth = $month;
+ $this->viewDay = $day;
+
$engine = new PhabricatorCalendarEventSearchEngine();
if ($month && $year) {
@@ -33,9 +41,36 @@
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
+ $viewer = $this->getViewer();
+
+ $year = $this->viewYear;
+ $month = $this->viewMonth;
+ $day = $this->viewDay;
+
+ $parameters = array();
+
+ // If the viewer clicks "Create Event" while on a particular day view,
+ // default the times to that day.
+ if ($year && $month && $day) {
+ $datetimes = PhabricatorCalendarEvent::newDefaultEventDateTimes(
+ $viewer,
+ PhabricatorTime::getNow());
+
+ foreach ($datetimes as $datetime) {
+ $datetime
+ ->setYear($year)
+ ->setMonth($month)
+ ->setDay($day);
+ }
+
+ list($start, $end) = $datetimes;
+ $parameters['start'] = $start->getEpoch();
+ $parameters['end'] = $end->getEpoch();
+ }
+
id(new PhabricatorCalendarEventEditEngine())
->setViewer($this->getViewer())
- ->addActionToCrumbs($crumbs);
+ ->addActionToCrumbs($crumbs, $parameters);
return $crumbs;
}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -75,10 +75,10 @@
$default_icon = 'fa-calendar';
- $datetime_start = PhutilCalendarAbsoluteDateTime::newFromEpoch(
- $now,
- $actor->getTimezoneIdentifier());
- $datetime_end = $datetime_start->newRelativeDateTime('PT1H');
+ $datetime_defaults = self::newDefaultEventDateTimes(
+ $actor,
+ $now);
+ list($datetime_start, $datetime_end) = $datetime_defaults;
return id(new PhabricatorCalendarEvent())
->setDescription('')
@@ -102,6 +102,31 @@
->applyViewerTimezone($actor);
}
+ public static function newDefaultEventDateTimes(
+ PhabricatorUser $viewer,
+ $now) {
+
+ $datetime_start = PhutilCalendarAbsoluteDateTime::newFromEpoch(
+ $now,
+ $viewer->getTimezoneIdentifier());
+
+ // Advance the time by an hour, then round downwards to the nearest hour.
+ // For example, if it is currently 3:25 PM, we suggest a default start time
+ // of 4 PM.
+ $datetime_start = $datetime_start
+ ->newRelativeDateTime('PT1H')
+ ->newAbsoluteDateTime();
+ $datetime_start->setMinute(0);
+ $datetime_start->setSecond(0);
+
+ // Default the end time to an hour after the start time.
+ $datetime_end = $datetime_start
+ ->newRelativeDateTime('PT1H')
+ ->newAbsoluteDateTime();
+
+ return array($datetime_start, $datetime_end);
+ }
+
private function newChild(
PhabricatorUser $actor,
$sequence,
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -1349,7 +1349,9 @@
}
- final public function addActionToCrumbs(PHUICrumbsView $crumbs) {
+ final public function addActionToCrumbs(
+ PHUICrumbsView $crumbs,
+ array $parameters = array()) {
$viewer = $this->getViewer();
$can_create = $this->hasCreateCapability();
@@ -1385,6 +1387,11 @@
$form_key = $config->getIdentifier();
$create_uri = $this->getEditURI(null, "form/{$form_key}/");
+ if ($parameters) {
+ $create_uri = (string)id(new PhutilURI($create_uri))
+ ->setQueryParams($parameters);
+ }
+
if (count($configs) > 1) {
$menu_icon = 'fa-caret-square-o-down';
@@ -1395,6 +1402,11 @@
$form_key = $config->getIdentifier();
$config_uri = $this->getEditURI(null, "form/{$form_key}/");
+ if ($parameters) {
+ $config_uri = (string)id(new PhutilURI($config_uri))
+ ->setQueryParams($parameters);
+ }
+
$item_icon = 'fa-plus';
$dropdown->addAction(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 25, 7:59 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720316
Default Alt Text
D16754.id40352.diff (4 KB)
Attached To
Mode
D16754: Suggest better start/end datetimes for Calendar events
Attached
Detach File
Event Timeline
Log In to Comment