1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 04:42:40 +01:00

Calendar events should actually have an icon now.

Summary: Ref T7936, Calendar events should actually have an icon now.

Test Plan: Edit event, edit icon, save, observe transaction feed.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7936

Differential Revision: https://secure.phabricator.com/D12934
This commit is contained in:
lkassianik 2015-05-19 13:09:28 -07:00
parent 81a475d5a6
commit 3845057efb
8 changed files with 85 additions and 20 deletions

View file

@ -38,6 +38,7 @@ return array(
'rsrc/css/application/base/notification-menu.css' => '3c9d8aa1', 'rsrc/css/application/base/notification-menu.css' => '3c9d8aa1',
'rsrc/css/application/base/phabricator-application-launch-view.css' => '16ca323f', 'rsrc/css/application/base/phabricator-application-launch-view.css' => '16ca323f',
'rsrc/css/application/base/standard-page-view.css' => '61e68a55', '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/chatlog/chatlog.css' => '852140ff',
'rsrc/css/application/conduit/conduit-api.css' => '7bc725c4', 'rsrc/css/application/conduit/conduit-api.css' => '7bc725c4',
'rsrc/css/application/config/config-options.css' => '7fedf08b', 'rsrc/css/application/config/config-options.css' => '7fedf08b',
@ -492,6 +493,7 @@ return array(
'aphront-two-column-view-css' => '16ab3ad2', 'aphront-two-column-view-css' => '16ab3ad2',
'aphront-typeahead-control-css' => '0e403212', 'aphront-typeahead-control-css' => '0e403212',
'auth-css' => '44975d4b', 'auth-css' => '44975d4b',
'calendar-icon-css' => '98ce946d',
'changeset-view-manager' => '58562350', 'changeset-view-manager' => '58562350',
'conduit-api-css' => '7bc725c4', 'conduit-api-css' => '7bc725c4',
'config-options-css' => '7fedf08b', 'config-options-css' => '7fedf08b',

View file

@ -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 = "";

View file

@ -13,8 +13,7 @@ final class PhabricatorCalendarEventEditController
return !$this->id; return !$this->id;
} }
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$user_phid = $user->getPHID(); $user_phid = $user->getPHID();
$error_name = true; $error_name = true;
@ -74,6 +73,7 @@ final class PhabricatorCalendarEventEditController
$name = $event->getName(); $name = $event->getName();
$description = $event->getDescription(); $description = $event->getDescription();
$is_all_day = $event->getIsAllDay(); $is_all_day = $event->getIsAllDay();
$icon = $event->getIcon();
$current_policies = id(new PhabricatorPolicyQuery()) $current_policies = id(new PhabricatorPolicyQuery())
->setViewer($user) ->setViewer($user)
@ -95,6 +95,7 @@ final class PhabricatorCalendarEventEditController
$edit_policy = $request->getStr('editPolicy'); $edit_policy = $request->getStr('editPolicy');
$view_policy = $request->getStr('viewPolicy'); $view_policy = $request->getStr('viewPolicy');
$is_all_day = $request->getStr('isAllDay'); $is_all_day = $request->getStr('isAllDay');
$icon = $request->getStr('icon');
$invitees = $request->getArr('invitees'); $invitees = $request->getArr('invitees');
$new_invitees = $this->getNewInviteeList($invitees, $event); $new_invitees = $this->getNewInviteeList($invitees, $event);
@ -116,6 +117,11 @@ final class PhabricatorCalendarEventEditController
PhabricatorCalendarEventTransaction::TYPE_ALL_DAY) PhabricatorCalendarEventTransaction::TYPE_ALL_DAY)
->setNewValue($is_all_day); ->setNewValue($is_all_day);
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_ICON)
->setNewValue($icon);
$xactions[] = id(new PhabricatorCalendarEventTransaction()) $xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType( ->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_START_DATE) PhabricatorCalendarEventTransaction::TYPE_START_DATE)
@ -246,6 +252,20 @@ final class PhabricatorCalendarEventEditController
->setUser($user) ->setUser($user)
->setDatasource(new PhabricatorMetaMTAMailableDatasource()); ->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()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
->appendChild($name) ->appendChild($name)
@ -256,7 +276,8 @@ final class PhabricatorCalendarEventEditController
->appendControl($edit_policies) ->appendControl($edit_policies)
->appendControl($subscribers) ->appendControl($subscribers)
->appendControl($invitees) ->appendControl($invitees)
->appendChild($description); ->appendChild($description)
->appendChild($icon);
if ($request->isAjax()) { if ($request->isAjax()) {

View file

@ -264,6 +264,12 @@ final class PhabricatorCalendarEventViewController
$properties->invokeWillRenderEvent(); $properties->invokeWillRenderEvent();
$icon_display = PhabricatorCalendarIcon::renderIconForChooser(
$event->getIcon());
$properties->addProperty(
pht('Icon'),
$icon_display);
$properties->addSectionHeader( $properties->addSectionHeader(
pht('Description'), pht('Description'),
PHUIPropertyListView::ICON_SUMMARY); PHUIPropertyListView::ICON_SUMMARY);

View file

@ -21,6 +21,7 @@ final class PhabricatorCalendarEventEditor
$types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL; $types[] = PhabricatorCalendarEventTransaction::TYPE_CANCEL;
$types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE; $types[] = PhabricatorCalendarEventTransaction::TYPE_INVITE;
$types[] = PhabricatorCalendarEventTransaction::TYPE_ALL_DAY; $types[] = PhabricatorCalendarEventTransaction::TYPE_ALL_DAY;
$types[] = PhabricatorCalendarEventTransaction::TYPE_ICON;
$types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
@ -45,6 +46,8 @@ final class PhabricatorCalendarEventEditor
return $object->getIsCancelled(); return $object->getIsCancelled();
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
return (int)$object->getIsAllDay(); return (int)$object->getIsAllDay();
case PhabricatorCalendarEventTransaction::TYPE_ICON:
return $object->getIcon();
case PhabricatorCalendarEventTransaction::TYPE_INVITE: case PhabricatorCalendarEventTransaction::TYPE_INVITE:
$map = $xaction->getNewValue(); $map = $xaction->getNewValue();
$phids = array_keys($map); $phids = array_keys($map);
@ -73,6 +76,7 @@ final class PhabricatorCalendarEventEditor
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
case PhabricatorCalendarEventTransaction::TYPE_CANCEL: case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
case PhabricatorCalendarEventTransaction::TYPE_INVITE: case PhabricatorCalendarEventTransaction::TYPE_INVITE:
case PhabricatorCalendarEventTransaction::TYPE_ICON:
return $xaction->getNewValue(); return $xaction->getNewValue();
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
return (int)$xaction->getNewValue(); return (int)$xaction->getNewValue();
@ -107,6 +111,9 @@ final class PhabricatorCalendarEventEditor
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
$object->setIsAllDay((int)$xaction->getNewValue()); $object->setIsAllDay((int)$xaction->getNewValue());
return; return;
case PhabricatorCalendarEventTransaction::TYPE_ICON:
$object->setIcon($xaction->getNewValue());
return;
case PhabricatorCalendarEventTransaction::TYPE_INVITE: case PhabricatorCalendarEventTransaction::TYPE_INVITE:
return; return;
} }
@ -125,6 +132,7 @@ final class PhabricatorCalendarEventEditor
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION: case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
case PhabricatorCalendarEventTransaction::TYPE_CANCEL: case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
case PhabricatorCalendarEventTransaction::TYPE_ICON:
return; return;
case PhabricatorCalendarEventTransaction::TYPE_INVITE: case PhabricatorCalendarEventTransaction::TYPE_INVITE:
$map = $xaction->getNewValue(); $map = $xaction->getNewValue();
@ -171,6 +179,8 @@ final class PhabricatorCalendarEventEditor
$invalidate_phids = array(); $invalidate_phids = array();
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorCalendarEventTransaction::TYPE_ICON:
break;
case PhabricatorCalendarEventTransaction::TYPE_START_DATE: case PhabricatorCalendarEventTransaction::TYPE_START_DATE:
case PhabricatorCalendarEventTransaction::TYPE_END_DATE: case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
case PhabricatorCalendarEventTransaction::TYPE_CANCEL: case PhabricatorCalendarEventTransaction::TYPE_CANCEL:
@ -329,7 +339,7 @@ final class PhabricatorCalendarEventEditor
PhabricatorCalendarEventTransaction::MAILTAG_CONTENT => PhabricatorCalendarEventTransaction::MAILTAG_CONTENT =>
pht( pht(
"An event's name, status, invite list, ". "An event's name, status, invite list, ".
"and description changes."), "icon, and description changes."),
PhabricatorCalendarEventTransaction::MAILTAG_RESCHEDULE => PhabricatorCalendarEventTransaction::MAILTAG_RESCHEDULE =>
pht( pht(
"An event's start and end date ". "An event's start and end date ".

View file

@ -5,22 +5,22 @@ final class PhabricatorCalendarIcon extends Phobject {
public static function getIconMap() { public static function getIconMap() {
return return
array( array(
'fa-briefcase' => pht('Briefcase'), 'fa-calendar' => pht('Default'),
'fa-tags' => pht('Tag'), 'fa-glass' => pht('Party'),
'fa-folder' => pht('Folder'), 'fa-plane' => pht('Travel'),
'fa-users' => pht('Team'), 'fa-plus-square' => pht('Health / Appointment'),
'fa-bug' => pht('Bug'), 'fa-rocket' => pht('Sabatical / Leave'),
'fa-trash-o' => pht('Garbage'), 'fa-home' => pht('Working From Home'),
'fa-calendar' => pht('Deadline'), 'fa-tree' => pht('Holiday'),
'fa-flag-checkered' => pht('Goal'), 'fa-gamepad' => pht('Staycation'),
'fa-envelope' => pht('Communication'), 'fa-coffee' => pht('Coffee Meeting'),
'fa-truck' => pht('Release'), 'fa-film' => pht('Movie'),
'fa-lock' => pht('Policy'), 'fa-users' => pht('Meeting'),
'fa-umbrella' => pht('An Umbrella'), 'fa-cutlery' => pht('Meal'),
'fa-cloud' => pht('The Cloud'), 'fa-paw' => pht('Pet Activity'),
'fa-building' => pht('Company'), 'fa-institution' => pht('Official Business'),
'fa-credit-card' => pht('Accounting'), 'fa-bus' => pht('Field Trip'),
'fa-flask' => pht('Experimental'), 'fa-microphone' => pht('Conference'),
); );
} }

View file

@ -17,11 +17,14 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
protected $description; protected $description;
protected $isCancelled; protected $isCancelled;
protected $isAllDay; protected $isAllDay;
protected $icon;
protected $mailKey; protected $mailKey;
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
const DEFAULT_ICON = 'fa-calendar';
private $invitees = self::ATTACHABLE; private $invitees = self::ATTACHABLE;
private $appliedViewer; private $appliedViewer;
@ -35,6 +38,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
->setUserPHID($actor->getPHID()) ->setUserPHID($actor->getPHID())
->setIsCancelled(0) ->setIsCancelled(0)
->setIsAllDay(0) ->setIsAllDay(0)
->setIcon(self::DEFAULT_ICON)
->setViewPolicy($actor->getPHID()) ->setViewPolicy($actor->getPHID())
->setEditPolicy($actor->getPHID()) ->setEditPolicy($actor->getPHID())
->attachInvitees(array()) ->attachInvitees(array())
@ -166,6 +170,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
'description' => 'text', 'description' => 'text',
'isCancelled' => 'bool', 'isCancelled' => 'bool',
'isAllDay' => 'bool', 'isAllDay' => 'bool',
'icon' => 'text32',
'mailKey' => 'bytes20', 'mailKey' => 'bytes20',
), ),
self::CONFIG_KEY_SCHEMA => array( self::CONFIG_KEY_SCHEMA => array(

View file

@ -9,6 +9,7 @@ final class PhabricatorCalendarEventTransaction
const TYPE_DESCRIPTION = 'calendar.description'; const TYPE_DESCRIPTION = 'calendar.description';
const TYPE_CANCEL = 'calendar.cancel'; const TYPE_CANCEL = 'calendar.cancel';
const TYPE_ALL_DAY = 'calendar.allday'; const TYPE_ALL_DAY = 'calendar.allday';
const TYPE_ICON = 'calendar.icon';
const TYPE_INVITE = 'calendar.invite'; const TYPE_INVITE = 'calendar.invite';
const MAILTAG_RESCHEDULE = 'calendar-reschedule'; const MAILTAG_RESCHEDULE = 'calendar-reschedule';
@ -66,6 +67,8 @@ final class PhabricatorCalendarEventTransaction
public function getIcon() { public function getIcon() {
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case self::TYPE_ICON:
return $this->getNewValue();
case self::TYPE_NAME: case self::TYPE_NAME:
case self::TYPE_START_DATE: case self::TYPE_START_DATE:
case self::TYPE_END_DATE: case self::TYPE_END_DATE:
@ -130,6 +133,12 @@ final class PhabricatorCalendarEventTransaction
'%s converted this from an all day event.', '%s converted this from an all day event.',
$this->renderHandleLink($author_phid)); $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: case self::TYPE_CANCEL:
if ($new) { if ($new) {
return pht( return pht(
@ -292,6 +301,12 @@ final class PhabricatorCalendarEventTransaction
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$this->renderHandleLink($object_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: case self::TYPE_CANCEL:
if ($new) { if ($new) {
return pht( return pht(
@ -449,6 +464,7 @@ final class PhabricatorCalendarEventTransaction
case self::TYPE_NAME: case self::TYPE_NAME:
case self::TYPE_DESCRIPTION: case self::TYPE_DESCRIPTION:
case self::TYPE_INVITE: case self::TYPE_INVITE:
case self::TYPE_ICON:
$tags[] = self::MAILTAG_CONTENT; $tags[] = self::MAILTAG_CONTENT;
break; break;
case self::TYPE_START_DATE: case self::TYPE_START_DATE: