diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 1769c81f76..c2b79e7a10 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -38,6 +38,7 @@ return array( 'rsrc/css/application/base/notification-menu.css' => '3c9d8aa1', 'rsrc/css/application/base/phabricator-application-launch-view.css' => '16ca323f', 'rsrc/css/application/base/standard-page-view.css' => '61e68a55', + 'rsrc/css/application/calendar/calendar-icon.css' => '98ce946d', 'rsrc/css/application/chatlog/chatlog.css' => '852140ff', 'rsrc/css/application/conduit/conduit-api.css' => '7bc725c4', 'rsrc/css/application/config/config-options.css' => '7fedf08b', @@ -492,6 +493,7 @@ return array( 'aphront-two-column-view-css' => '16ab3ad2', 'aphront-typeahead-control-css' => '0e403212', 'auth-css' => '44975d4b', + 'calendar-icon-css' => '98ce946d', 'changeset-view-manager' => '58562350', 'conduit-api-css' => '7bc725c4', 'config-options-css' => '7fedf08b', diff --git a/resources/sql/autopatches/20150519.calendar.calendaricon.sql b/resources/sql/autopatches/20150519.calendar.calendaricon.sql new file mode 100644 index 0000000000..d91520df0a --- /dev/null +++ b/resources/sql/autopatches/20150519.calendar.calendaricon.sql @@ -0,0 +1,5 @@ +ALTER TABLE {$NAMESPACE}_calendar.calendar_event + ADD COLUMN icon VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL; + +UPDATE {$NAMESPACE}_calendar.calendar_event + SET icon = "fa-calendar" WHERE icon = ""; diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php index 900b3ad56b..cf9797da45 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php @@ -13,8 +13,7 @@ final class PhabricatorCalendarEventEditController return !$this->id; } - public function processRequest() { - $request = $this->getRequest(); + public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $user_phid = $user->getPHID(); $error_name = true; @@ -74,6 +73,7 @@ final class PhabricatorCalendarEventEditController $name = $event->getName(); $description = $event->getDescription(); $is_all_day = $event->getIsAllDay(); + $icon = $event->getIcon(); $current_policies = id(new PhabricatorPolicyQuery()) ->setViewer($user) @@ -95,6 +95,7 @@ final class PhabricatorCalendarEventEditController $edit_policy = $request->getStr('editPolicy'); $view_policy = $request->getStr('viewPolicy'); $is_all_day = $request->getStr('isAllDay'); + $icon = $request->getStr('icon'); $invitees = $request->getArr('invitees'); $new_invitees = $this->getNewInviteeList($invitees, $event); @@ -116,6 +117,11 @@ final class PhabricatorCalendarEventEditController PhabricatorCalendarEventTransaction::TYPE_ALL_DAY) ->setNewValue($is_all_day); + $xactions[] = id(new PhabricatorCalendarEventTransaction()) + ->setTransactionType( + PhabricatorCalendarEventTransaction::TYPE_ICON) + ->setNewValue($icon); + $xactions[] = id(new PhabricatorCalendarEventTransaction()) ->setTransactionType( PhabricatorCalendarEventTransaction::TYPE_START_DATE) @@ -246,6 +252,20 @@ final class PhabricatorCalendarEventEditController ->setUser($user) ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); + if ($this->isCreate()) { + $icon_uri = $this->getApplicationURI('icon/'); + } else { + $icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/'); + } + $icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon); + $icon = id(new AphrontFormChooseButtonControl()) + ->setLabel(pht('Icon')) + ->setName('icon') + ->setDisplayValue($icon_display) + ->setButtonText(pht('Choose Icon...')) + ->setChooseURI($icon_uri) + ->setValue($icon); + $form = id(new AphrontFormView()) ->setUser($user) ->appendChild($name) @@ -256,7 +276,8 @@ final class PhabricatorCalendarEventEditController ->appendControl($edit_policies) ->appendControl($subscribers) ->appendControl($invitees) - ->appendChild($description); + ->appendChild($description) + ->appendChild($icon); if ($request->isAjax()) { diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php index 742ec95e3f..656446c2a3 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php @@ -264,6 +264,12 @@ final class PhabricatorCalendarEventViewController $properties->invokeWillRenderEvent(); + $icon_display = PhabricatorCalendarIcon::renderIconForChooser( + $event->getIcon()); + $properties->addProperty( + pht('Icon'), + $icon_display); + $properties->addSectionHeader( pht('Description'), PHUIPropertyListView::ICON_SUMMARY); diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php index 203f29222b..291f6c1865 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php +++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php @@ -21,6 +21,7 @@ final class PhabricatorCalendarEventEditor $types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL; $types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE; $types[] = PhabricatorCalendarEventTransaction::TYPE_ALL_DAY; + $types[] = PhabricatorCalendarEventTransaction::TYPE_ICON; $types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; @@ -45,6 +46,8 @@ final class PhabricatorCalendarEventEditor return $object->getIsCancelled(); case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: return (int)$object->getIsAllDay(); + case PhabricatorCalendarEventTransaction::TYPE_ICON: + return $object->getIcon(); case PhabricatorCalendarEventTransaction::TYPE_INVITE: $map = $xaction->getNewValue(); $phids = array_keys($map); @@ -73,6 +76,7 @@ final class PhabricatorCalendarEventEditor case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: case PhabricatorCalendarEventTransaction::TYPE_CANCEL: case PhabricatorCalendarEventTransaction::TYPE_INVITE: + case PhabricatorCalendarEventTransaction::TYPE_ICON: return $xaction->getNewValue(); case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: return (int)$xaction->getNewValue(); @@ -107,6 +111,9 @@ final class PhabricatorCalendarEventEditor case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: $object->setIsAllDay((int)$xaction->getNewValue()); return; + case PhabricatorCalendarEventTransaction::TYPE_ICON: + $object->setIcon($xaction->getNewValue()); + return; case PhabricatorCalendarEventTransaction::TYPE_INVITE: return; } @@ -125,6 +132,7 @@ final class PhabricatorCalendarEventEditor case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: case PhabricatorCalendarEventTransaction::TYPE_CANCEL: case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: + case PhabricatorCalendarEventTransaction::TYPE_ICON: return; case PhabricatorCalendarEventTransaction::TYPE_INVITE: $map = $xaction->getNewValue(); @@ -171,6 +179,8 @@ final class PhabricatorCalendarEventEditor $invalidate_phids = array(); foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { + case PhabricatorCalendarEventTransaction::TYPE_ICON: + break; case PhabricatorCalendarEventTransaction::TYPE_START_DATE: case PhabricatorCalendarEventTransaction::TYPE_END_DATE: case PhabricatorCalendarEventTransaction::TYPE_CANCEL: @@ -329,7 +339,7 @@ final class PhabricatorCalendarEventEditor PhabricatorCalendarEventTransaction::MAILTAG_CONTENT => pht( "An event's name, status, invite list, ". - "and description changes."), + "icon, and description changes."), PhabricatorCalendarEventTransaction::MAILTAG_RESCHEDULE => pht( "An event's start and end date ". diff --git a/src/applications/calendar/icon/PhabricatorCalendarIcon.php b/src/applications/calendar/icon/PhabricatorCalendarIcon.php index 904ffee761..9ba4b00c01 100644 --- a/src/applications/calendar/icon/PhabricatorCalendarIcon.php +++ b/src/applications/calendar/icon/PhabricatorCalendarIcon.php @@ -5,22 +5,22 @@ final class PhabricatorCalendarIcon extends Phobject { public static function getIconMap() { return array( - 'fa-briefcase' => pht('Briefcase'), - 'fa-tags' => pht('Tag'), - 'fa-folder' => pht('Folder'), - 'fa-users' => pht('Team'), - 'fa-bug' => pht('Bug'), - 'fa-trash-o' => pht('Garbage'), - 'fa-calendar' => pht('Deadline'), - 'fa-flag-checkered' => pht('Goal'), - 'fa-envelope' => pht('Communication'), - 'fa-truck' => pht('Release'), - 'fa-lock' => pht('Policy'), - 'fa-umbrella' => pht('An Umbrella'), - 'fa-cloud' => pht('The Cloud'), - 'fa-building' => pht('Company'), - 'fa-credit-card' => pht('Accounting'), - 'fa-flask' => pht('Experimental'), + 'fa-calendar' => pht('Default'), + 'fa-glass' => pht('Party'), + 'fa-plane' => pht('Travel'), + 'fa-plus-square' => pht('Health / Appointment'), + 'fa-rocket' => pht('Sabatical / Leave'), + 'fa-home' => pht('Working From Home'), + 'fa-tree' => pht('Holiday'), + 'fa-gamepad' => pht('Staycation'), + 'fa-coffee' => pht('Coffee Meeting'), + 'fa-film' => pht('Movie'), + 'fa-users' => pht('Meeting'), + 'fa-cutlery' => pht('Meal'), + 'fa-paw' => pht('Pet Activity'), + 'fa-institution' => pht('Official Business'), + 'fa-bus' => pht('Field Trip'), + 'fa-microphone' => pht('Conference'), ); } diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 42bf5f9e05..3055e5e4e6 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -17,11 +17,14 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO protected $description; protected $isCancelled; protected $isAllDay; + protected $icon; protected $mailKey; protected $viewPolicy; protected $editPolicy; + const DEFAULT_ICON = 'fa-calendar'; + private $invitees = self::ATTACHABLE; private $appliedViewer; @@ -35,6 +38,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO ->setUserPHID($actor->getPHID()) ->setIsCancelled(0) ->setIsAllDay(0) + ->setIcon(self::DEFAULT_ICON) ->setViewPolicy($actor->getPHID()) ->setEditPolicy($actor->getPHID()) ->attachInvitees(array()) @@ -166,6 +170,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO 'description' => 'text', 'isCancelled' => 'bool', 'isAllDay' => 'bool', + 'icon' => 'text32', 'mailKey' => 'bytes20', ), self::CONFIG_KEY_SCHEMA => array( diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php index 91b5d5231f..767208648e 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php @@ -9,6 +9,7 @@ final class PhabricatorCalendarEventTransaction const TYPE_DESCRIPTION = 'calendar.description'; const TYPE_CANCEL = 'calendar.cancel'; const TYPE_ALL_DAY = 'calendar.allday'; + const TYPE_ICON = 'calendar.icon'; const TYPE_INVITE = 'calendar.invite'; const MAILTAG_RESCHEDULE = 'calendar-reschedule'; @@ -66,6 +67,8 @@ final class PhabricatorCalendarEventTransaction public function getIcon() { switch ($this->getTransactionType()) { + case self::TYPE_ICON: + return $this->getNewValue(); case self::TYPE_NAME: case self::TYPE_START_DATE: case self::TYPE_END_DATE: @@ -130,6 +133,12 @@ final class PhabricatorCalendarEventTransaction '%s converted this from an all day event.', $this->renderHandleLink($author_phid)); } + case self::TYPE_ICON: + return pht( + '%s set this event\'s icon to %s.', + $this->renderHandleLink($author_phid), + PhabricatorCalendarIcon::getLabel($new)); + break; case self::TYPE_CANCEL: if ($new) { return pht( @@ -292,6 +301,12 @@ final class PhabricatorCalendarEventTransaction $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } + case self::TYPE_ICON: + return pht( + '%s set the icon for %s to %s.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + PhabricatorCalendarIcon::getLabel($new)); case self::TYPE_CANCEL: if ($new) { return pht( @@ -449,6 +464,7 @@ final class PhabricatorCalendarEventTransaction case self::TYPE_NAME: case self::TYPE_DESCRIPTION: case self::TYPE_INVITE: + case self::TYPE_ICON: $tags[] = self::MAILTAG_CONTENT; break; case self::TYPE_START_DATE: