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

Calendar events should be green if viewer is invited, and grey if not.

Summary: Closes T8189, Calendar events should be green if viewer is invited, and grey if not.

Test Plan: Check that month and day views display events that viewer is invited to as green and grey otherwise, including month day badges on mobile monthly view.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8189

Differential Revision: https://secure.phabricator.com/D12850
This commit is contained in:
lkassianik 2015-05-14 19:20:44 -07:00
parent f16dda288d
commit 4016107411
11 changed files with 142 additions and 54 deletions

View file

@ -120,10 +120,10 @@ return array(
'rsrc/css/layout/phabricator-hovercard-view.css' => 'dd9121a9',
'rsrc/css/layout/phabricator-side-menu-view.css' => 'c1db9e9c',
'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894',
'rsrc/css/phui/calendar/phui-calendar-day.css' => '38891735',
'rsrc/css/phui/calendar/phui-calendar-day.css' => '3b4a65d8',
'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1d0ca59',
'rsrc/css/phui/calendar/phui-calendar-month.css' => '3150cfbf',
'rsrc/css/phui/calendar/phui-calendar.css' => '8675968e',
'rsrc/css/phui/calendar/phui-calendar-month.css' => '3e42c803',
'rsrc/css/phui/calendar/phui-calendar.css' => '8345be98',
'rsrc/css/phui/phui-action-header-view.css' => '89c497e7',
'rsrc/css/phui/phui-action-list.css' => '4f4d09f2',
'rsrc/css/phui/phui-action-panel.css' => '3ee9afd5',
@ -760,10 +760,10 @@ return array(
'phui-action-panel-css' => '3ee9afd5',
'phui-box-css' => '7b3a2eed',
'phui-button-css' => 'de610129',
'phui-calendar-css' => '8675968e',
'phui-calendar-day-css' => '38891735',
'phui-calendar-css' => '8345be98',
'phui-calendar-day-css' => '3b4a65d8',
'phui-calendar-list-css' => 'c1d0ca59',
'phui-calendar-month-css' => '3150cfbf',
'phui-calendar-month-css' => '3e42c803',
'phui-crumbs-view-css' => '594d719e',
'phui-document-view-css' => '94d5dcd8',
'phui-feed-story-css' => 'c9f3a0b5',

View file

@ -10,6 +10,7 @@ final class CalendarColors extends CalendarConstants {
const COLOR_SKY = 'sky';
const COLOR_INDIGO = 'indigo';
const COLOR_VIOLET = 'violet';
const COLOR_GREY = 'grey';
public static function getColors() {
return array(
@ -21,6 +22,7 @@ final class CalendarColors extends CalendarConstants {
self::COLOR_INDIGO,
self::COLOR_RED,
self::COLOR_YELLOW,
self::COLOR_GREY,
);
}

View file

@ -359,25 +359,9 @@ final class PhabricatorCalendarEventSearchEngine
$phids = mpull($statuses, 'getUserPHID');
/* Assign Colors */
$unique = array_unique($phids);
$allblue = false;
$calcolors = CalendarColors::getColors();
if (count($unique) > count($calcolors)) {
$allblue = true;
}
$i = 0;
$eventcolor = array();
foreach ($unique as $phid) {
if ($allblue) {
$eventcolor[$phid] = CalendarColors::COLOR_SKY;
} else {
$eventcolor[$phid] = $calcolors[$i];
}
$i++;
}
foreach ($statuses as $status) {
$viewer_is_invited = $status->getIsUserInvited($viewer->getPHID());
$event = new AphrontCalendarEventView();
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
$event->setIsAllDay($status->getIsAllDay());
@ -388,7 +372,7 @@ final class PhabricatorCalendarEventSearchEngine
$event->setDescription(pht('%s (%s)', $name_text, $status_text));
$event->setName($status_text);
$event->setEventID($status->getID());
$event->setColor($eventcolor[$status->getUserPHID()]);
$event->setViewerIsInvited($viewer_is_invited);
$month_view->addEvent($event);
}
@ -422,10 +406,13 @@ final class PhabricatorCalendarEventSearchEngine
continue;
}
$viewer_is_invited = $status->getIsUserInvited($viewer->getPHID());
$event = new AphrontCalendarEventView();
$event->setEventID($status->getID());
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
$event->setIsAllDay($status->getIsAllDay());
$event->setViewerIsInvited($viewer_is_invited);
$event->setName($status->getName());
$event->setURI('/'.$status->getMonogram());

View file

@ -215,6 +215,16 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $is_attending;
}
public function getIsUserInvited($phid) {
$uninvited_status = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
$declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
$status = $this->getUserInviteStatus($phid);
if ($status == $uninvited_status || $status == $declined_status) {
return false;
}
return true;
}
/* -( Markup Interface )--------------------------------------------------- */

View file

@ -8,7 +8,7 @@ final class AphrontCalendarEventView extends AphrontView {
private $epochEnd;
private $description;
private $eventID;
private $color;
private $viewerIsInvited;
private $uri;
private $isAllDay;
@ -29,6 +29,14 @@ final class AphrontCalendarEventView extends AphrontView {
return $this->eventID;
}
public function setViewerIsInvited($viewer_is_invited) {
$this->viewerIsInvited = $viewer_is_invited;
return $this;
}
public function getViewerIsInvited() {
return $this->viewerIsInvited;
}
public function setUserPHID($user_phid) {
$this->userPHID = $user_phid;
return $this;
@ -70,18 +78,6 @@ final class AphrontCalendarEventView extends AphrontView {
return $this->description;
}
public function setColor($color) {
$this->color = $color;
return $this;
}
public function getColor() {
if ($this->color) {
return $this->color;
} else {
return CalendarColors::COLOR_SKY;
}
}
public function setIsAllDay($is_all_day) {
$this->isAllDay = $is_all_day;
return $this;

View file

@ -391,10 +391,15 @@ final class PHUICalendarDayView extends AphrontView {
}
private function drawAllDayEvent(AphrontCalendarEventView $event) {
$class = 'day-view-all-day';
if ($event->getViewerIsInvited()) {
$class = $class.' viewer-invited-day-event';
}
$name = phutil_tag(
'a',
array(
'class' => 'day-view-all-day',
'class' => $class,
'href' => $event->getURI(),
),
$event->getName());
@ -425,10 +430,16 @@ final class PHUICalendarDayView extends AphrontView {
$width,
$top,
$height) {
$class = 'phui-calendar-day-event-link';
if ($event->getViewerIsInvited()) {
$class = $class.' viewer-invited-day-event';
}
$name = phutil_tag(
'a',
array(
'class' => 'phui-calendar-day-event-link',
'class' => $class,
'href' => $event->getURI(),
),
$event->getName());

View file

@ -33,7 +33,6 @@ final class PHUICalendarListView extends AphrontTagView {
$singletons = array();
$allday = false;
foreach ($this->events as $event) {
$color = $event->getColor();
$start_epoch = $event->getEpochStart();
if ($event->getIsAllDay()) {
@ -65,7 +64,10 @@ final class PHUICalendarListView extends AphrontTagView {
),
$timelabel);
$class = 'phui-calendar-list-item phui-calendar-'.$color;
$class = 'phui-calendar-list-item';
if ($event->getViewerIsInvited()) {
$class = $class.' phui-calendar-viewer-invited';
}
if ($event->getIsAllDay()) {
$class = $class.' all-day';
}
@ -142,7 +144,7 @@ final class PHUICalendarListView extends AphrontTagView {
$description = pht('(%s)', $event->getName());
}
$class = 'phui-calendar-item-link';
$class = 'phui-calendar-item';
$anchor = javelin_tag(
'a',
@ -159,4 +161,13 @@ final class PHUICalendarListView extends AphrontTagView {
return $anchor;
}
public function getIsViewerInvitedOnList() {
foreach ($this->events as $event) {
if ($event->getViewerIsInvited()) {
return true;
}
}
return false;
}
}

View file

@ -178,7 +178,9 @@ final class PHUICalendarMonthView extends AphrontView {
$uri = $event_list['uri'];
$count = $event_list['count'];
$event_count_badge = $this->getEventCountBadge($count);
$viewer_is_invited = $list->getIsViewerInvitedOnList();
$event_count_badge = $this->getEventCountBadge($count, $viewer_is_invited);
$cell_day_secret_link = $this->getHiddenDayLink($uri);
$cell_data_div = phutil_tag(
@ -252,13 +254,19 @@ final class PHUICalendarMonthView extends AphrontView {
$cell_div);
}
private function getEventCountBadge($count) {
private function getEventCountBadge($count, $viewer_is_invited) {
$class = 'phui-calendar-month-count-badge';
if ($viewer_is_invited) {
$class = $class.' viewer-invited-day-badge';
}
$event_count = null;
if ($count > 0) {
$event_count = phutil_tag(
'div',
array(
'class' => 'phui-calendar-month-count-badge',
'class' => $class,
),
$count);
}

View file

@ -37,8 +37,8 @@
.phui-calendar-day-event-link {
padding: 8px;
border: 1px solid {$blueborder};
background-color: {$bluebackground};
border: 1px solid {$greyborder};
background-color: {$darkgreybackground};
margin: 0 4px;
position: absolute;
left: 0;
@ -49,17 +49,29 @@
color: {$greytext};
}
.phui-calendar-day-event-link.viewer-invited-day-event {
border-color: {$green};
background-color: {$lightgreen};
color: {$green};
}
.day-view-all-day {
border: 1px solid {$blueborder};
border: 1px solid {$greyborder};
height: 12px;
margin: 0;
display: block;
padding: 8px;
background-color: {$bluebackground};
background-color: {$darkgreybackground};
text-decoration: none;
color: {$greytext};
}
.day-view-all-day.viewer-invited-day-event {
border-color: {$green};
background-color: {$lightgreen};
color: {$green};
}
.phui-calendar-day-event + .phui-calendar-day-event .day-view-all-day {
border-top-style: none;
border-top-width: 0;

View file

@ -73,6 +73,11 @@ table.phui-calendar-view tr td:first-child {
margin: 0 auto;
}
.phui-calendar-month-count-badge.viewer-invited-day-badge {
border-color: {$green};
color: {$green};
}
table.phui-calendar-view a.phui-calendar-date-number {
color: {$lightgreytext};
padding: 0 4px;
@ -116,12 +121,18 @@ table.phui-calendar-view td.phui-calendar-date-number-container {
.phui-calendar-view .phui-calendar-list li.phui-calendar-list-item.all-day {
margin: 0;
padding: 4px 8px;
background-color: {$lightpink};
padding: 4px 4px 0px 4px;
background-color: {$darkgreybackground};
display: block;
float: none;
}
.phui-calendar-view
.phui-calendar-list
li.phui-calendar-viewer-invited.all-day {
background-color: {$lightgreen};
}
li.phui-calendar-list-item.all-day:first-child {
margin-top: 0;
}
@ -155,7 +166,11 @@ li.phui-calendar-list-item.all-day:first-child {
}
li.phui-calendar-list-item.all-day .phui-calendar-list-title a{
color: {$pink};
color: {$greytext};
}
li.phui-calendar-viewer-invited.all-day .phui-calendar-list-title a{
color: {$green};
}
.phui-calendar-view .phui-calendar-list-time {

View file

@ -2,6 +2,15 @@
* @provides phui-calendar-css
*/
.phui-calendar-list a {
color: {$lightgreytext};
}
.phui-calendar-viewer-invited a {
color: {$green};
font-weight: bold;
}
.phui-calendar-red a {
color: {$red};
}
@ -34,6 +43,14 @@
color: {$violet};
}
.phui-calendar-grey a {
color: {$lightgreytext};
}
.phui-calendar-bg-viewer-invited {
background-color: {$lightgreen};
}
.phui-calendar-bg-red {
background-color: {$lightred};
}
@ -47,7 +64,7 @@
}
.phui-calendar-bg-green {
background-color: {$lightgreen}
background-color: {$lightgreen};
}
.phui-calendar-bg-blue {
@ -66,6 +83,20 @@
background-color: {$lightviolet};
}
.phui-calendar-bg-grey {
background-color: {$darkgreybackground};
}
.phui-calendar-list-dot {
background-color: {$lightgreytext};
border-color: {$lightgreytext};
}
.phui-calendar-viewer-invited .phui-calendar-list-dot {
background-color: {$green};
border-color: {$green};
}
.phui-calendar-red .phui-calendar-list-dot {
background-color: {$red};
border-color: {$red};
@ -105,3 +136,8 @@
background-color: {$violet};
border-color: {$violet};
}
.phui-calendar-grey .phui-calendar-list-dot {
background-color: {$lightgreytext};
border-color: {$lightgreytext};
}