diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php index 098e58795e..229bf03353 100644 --- a/src/applications/calendar/application/PhabricatorCalendarApplication.php +++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php @@ -1,68 +1,67 @@ [1-9]\d*)' => 'PhabricatorCalendarEventViewController', '/calendar/' => array( '' => 'PhabricatorCalendarViewController', 'all/' => 'PhabricatorCalendarBrowseController', 'event/' => array( '(?:query/(?P[^/]+)/)?' => 'PhabricatorCalendarEventListController', 'create/' => 'PhabricatorCalendarEventEditController', 'edit/(?P[1-9]\d*)/' => 'PhabricatorCalendarEventEditController', 'delete/(?P[1-9]\d*)/' => 'PhabricatorCalendarEventDeleteController', - 'view/(?P[1-9]\d*)/' - => 'PhabricatorCalendarEventViewController', ), ), ); } public function getQuickCreateItems(PhabricatorUser $viewer) { $items = array(); $item = id(new PHUIListItemView()) ->setName(pht('Calendar Event')) ->setIcon('fa-calendar') ->setHref($this->getBaseURI().'event/create/'); $items[] = $item; return $items; } } diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php index ef22084f58..78e25fe563 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php @@ -1,204 +1,203 @@ id = idx($data, 'id'); } public function isCreate() { return !$this->id; } public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $start_time = id(new AphrontFormDateControl()) ->setUser($user) ->setName('start') ->setLabel(pht('Start')) ->setInitialTime(AphrontFormDateControl::TIME_START_OF_DAY); $end_time = id(new AphrontFormDateControl()) ->setUser($user) ->setName('end') ->setLabel(pht('End')) ->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY); if ($this->isCreate()) { $status = new PhabricatorCalendarEvent(); $end_value = $end_time->readValueFromRequest($request); $start_value = $start_time->readValueFromRequest($request); $submit_label = pht('Create'); $filter = 'status/create/'; $page_title = pht('Create Event'); $redirect = 'created'; } else { $status = id(new PhabricatorCalendarEventQuery()) ->setViewer($user) ->withIDs(array($this->id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$status) { return new Aphront404Response(); } $end_time->setValue($status->getDateTo()); $start_time->setValue($status->getDateFrom()); $submit_label = pht('Update'); $filter = 'event/edit/'.$status->getID().'/'; $page_title = pht('Update Event'); $redirect = 'updated'; } $errors = array(); if ($request->isFormPost()) { $type = $request->getInt('status'); $start_value = $start_time->readValueFromRequest($request); $end_value = $end_time->readValueFromRequest($request); $description = $request->getStr('description'); if ($start_time->getError()) { $errors[] = pht('Invalid start time; reset to default.'); } if ($end_time->getError()) { $errors[] = pht('Invalid end time; reset to default.'); } if (!$errors) { try { $status ->setUserPHID($user->getPHID()) ->setStatus($type) ->setDateFrom($start_value) ->setDateTo($end_value) ->setDescription($description) ->save(); } catch (PhabricatorCalendarEventInvalidEpochException $e) { $errors[] = pht('Start must be before end.'); } } if (!$errors) { $uri = new PhutilURI($this->getApplicationURI()); $uri->setQueryParams( array( 'month' => phabricator_format_local_time($status->getDateFrom(), $user, 'm'), 'year' => phabricator_format_local_time($status->getDateFrom(), $user, 'Y'), $redirect => true, )); if ($request->isAjax()) { $response = id(new AphrontAjaxResponse()) ->setContent(array('redirect_uri' => $uri)); } else { $response = id(new AphrontRedirectResponse()) ->setURI($uri); } return $response; } } $error_view = null; if ($errors) { $error_view = id(new PHUIInfoView()) ->setTitle(pht('Status can not be set!')) ->setErrors($errors); } $status_select = id(new AphrontFormSelectControl()) ->setLabel(pht('Status')) ->setName('status') ->setValue($status->getStatus()) ->setOptions($status->getStatusOptions()); $description = id(new AphrontFormTextAreaControl()) ->setLabel(pht('Description')) ->setName('description') ->setValue($status->getDescription()); if ($request->isAjax()) { $dialog = id(new AphrontDialogView()) ->setUser($user) ->setTitle($page_title) ->setWidth(AphrontDialogView::WIDTH_FORM); if ($this->isCreate()) { $dialog->setSubmitURI($this->getApplicationURI('event/create/')); } else { $dialog->setSubmitURI( $this->getApplicationURI('event/edit/'.$status->getID().'/')); } $form = new PHUIFormLayoutView(); if ($error_view) { $form->appendChild($error_view); } } else { $form = id(new AphrontFormView()) ->setUser($user); } $form ->appendChild($status_select) ->appendChild($start_time) ->appendChild($end_time) ->appendChild($description); if ($request->isAjax()) { $dialog->addSubmitButton($submit_label); $submit = $dialog; } else { $submit = id(new AphrontFormSubmitControl()) ->setValue($submit_label); } if ($this->isCreate()) { $submit->addCancelButton($this->getApplicationURI()); } else { - $submit->addCancelButton( - $this->getApplicationURI('event/view/'.$status->getID().'/')); + $submit->addCancelButton('/E'.$status->getID()); } if ($request->isAjax()) { $dialog->appendChild($form); return id(new AphrontDialogResponse()) ->setDialog($dialog); } $form->appendChild($submit); $form_box = id(new PHUIObjectBoxView()) ->setHeaderText($page_title) ->setFormErrors($errors) ->setForm($form); $nav = $this->buildSideNavView($status); $nav->selectFilter($filter); $crumbs = $this ->buildApplicationCrumbs() ->addTextCrumb($page_title); $nav->appendChild( array( $crumbs, $form_box, )); return $this->buildApplicationPage( $nav, array( 'title' => $page_title, )); } } diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php index b337efb0b4..fe2bdfb3d0 100644 --- a/src/view/phui/calendar/PHUICalendarListView.php +++ b/src/view/phui/calendar/PHUICalendarListView.php @@ -1,130 +1,130 @@ events[] = $event; return $this; } public function showBlankState($state) { $this->blankState = $state; return $this; } protected function getTagName() { return 'div'; } protected function getTagAttributes() { require_celerity_resource('phui-calendar-css'); require_celerity_resource('phui-calendar-list-css'); return array('class' => 'phui-calendar-day-list'); } protected function getTagContent() { if (!$this->blankState && empty($this->events)) { return ''; } $events = msort($this->events, 'getEpochStart'); $singletons = array(); $allday = false; foreach ($events as $event) { $color = $event->getColor(); if ($event->getAllDay()) { $timelabel = pht('All Day'); } else { $timelabel = phabricator_time( $event->getEpochStart(), $this->getUser()); } $dot = phutil_tag( 'span', array( 'class' => 'phui-calendar-list-dot', ), ''); $title = phutil_tag( 'span', array( 'class' => 'phui-calendar-list-title', ), $this->renderEventLink($event, $allday)); $time = phutil_tag( 'span', array( 'class' => 'phui-calendar-list-time', ), $timelabel); $singletons[] = phutil_tag( 'li', array( 'class' => 'phui-calendar-list-item phui-calendar-'.$color, ), array( $dot, $title, $time, )); } if (empty($singletons)) { $singletons[] = phutil_tag( 'li', array( 'class' => 'phui-calendar-list-item-empty', ), pht('Clear sailing ahead.')); } $list = phutil_tag( 'ul', array( 'class' => 'phui-calendar-list', ), $singletons); return $list; } private function renderEventLink($event) { Javelin::initBehavior('phabricator-tooltips'); if ($event->getMultiDay()) { $tip = pht('%s, Until: %s', $event->getName(), phabricator_date($event->getEpochEnd(), $this->getUser())); } else { $tip = pht('%s, Until: %s', $event->getName(), phabricator_time($event->getEpochEnd(), $this->getUser())); } $description = $event->getDescription(); if (strlen($description) == 0) { $description = pht('(%s)', $event->getName()); } $anchor = javelin_tag( 'a', array( 'sigil' => 'has-tooltip', 'class' => 'phui-calendar-item-link', - 'href' => '/calendar/event/view/'.$event->getEventID().'/', + 'href' => '/E'.$event->getEventID(), 'meta' => array( 'tip' => $tip, 'size' => 200, ), ), $description); return $anchor; } }