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

First step towards a Javelin behavior for Calendar day view

Summary: Ref T8300, First step towards a Javelin behavior for Calendar day view

Test Plan: No user facing changes.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8300

Differential Revision: https://secure.phabricator.com/D12978
This commit is contained in:
lkassianik 2015-05-22 14:30:15 -07:00
parent 36e2d02d6e
commit 8166f25c0d
4 changed files with 79 additions and 2 deletions

View file

@ -331,7 +331,8 @@ return array(
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'b1a59974',
'rsrc/js/application/aphlict/behavior-aphlict-status.js' => 'ea681761',
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/calendar/event-all-day.js' => 'ca5fa62a',
'rsrc/js/application/calendar/behavior-day-view.js' => 'f4f4ad80',
'rsrc/js/application/calendar/behavior-event-all-day.js' => '38dcf3c8',
'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de',
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '10246726',
'rsrc/js/application/conpherence/behavior-drag-and-drop-photo.js' => 'cf86d16a',
@ -553,6 +554,7 @@ return array(
'javelin-behavior-dashboard-move-panels' => '82439934',
'javelin-behavior-dashboard-query-panel-select' => '453c5375',
'javelin-behavior-dashboard-tab-panel' => 'd4eecc63',
'javelin-behavior-day-view' => 'f4f4ad80',
'javelin-behavior-device' => 'a205cf28',
'javelin-behavior-differential-add-reviewers-and-ccs' => 'e10f8e18',
'javelin-behavior-differential-comment-jump' => '4fdb476d',
@ -573,7 +575,7 @@ return array(
'javelin-behavior-doorkeeper-tag' => 'e5822781',
'javelin-behavior-durable-column' => '16c695bf',
'javelin-behavior-error-log' => '6882e80a',
'javelin-behavior-event-all-day' => 'ca5fa62a',
'javelin-behavior-event-all-day' => '38dcf3c8',
'javelin-behavior-fancy-datepicker' => '5c0f680f',
'javelin-behavior-global-drag-and-drop' => 'c8e57404',
'javelin-behavior-herald-rule-editor' => '7ebaeed3',

View file

@ -10,6 +10,7 @@ final class PHUICalendarDayView extends AphrontView {
private $browseURI;
private $events = array();
private $todayEvents = array();
private $jsTodayEvents = array();
private $allDayEvents = array();
@ -45,6 +46,7 @@ final class PHUICalendarDayView extends AphrontView {
require_celerity_resource('phui-calendar-day-css');
$hours = $this->getHoursOfDay();
$js_hourly_events = array();
$hourly_events = array();
$first_event_hour = null;
@ -83,6 +85,11 @@ final class PHUICalendarDayView extends AphrontView {
&& $event->getEpochStart() < $hour_end)) {
$current_hour_events[] = $event;
$this->todayEvents[] = $event;
$this->jsTodayEvents[] = array(
'eventStartEpoch' => $event->getEpochStart(),
'eventEndEpoch' => $event->getEpochEnd(),
'eventName' => $event->getName(),
);
}
}
foreach ($current_hour_events as $event) {
@ -102,6 +109,17 @@ final class PHUICalendarDayView extends AphrontView {
$first_event_hour = $hour;
}
$js_hourly_events[$event->getEventID()] = array(
'eventStartEpoch' => $event->getEpochStart(),
'eventEndEpoch' => $event->getEpochEnd(),
'eventName' => $event->getName(),
'hour' => $hour,
'offset' => '0',
'width' => '100%',
'top' => $top.'%',
'height' => $height.'%',
);
$hourly_events[$event->getEventID()] = array(
'hour' => $hour,
'event' => $event,
@ -176,6 +194,13 @@ final class PHUICalendarDayView extends AphrontView {
$sidebar = $this->renderSidebar();
$warnings = $this->getQueryRangeWarning();
Javelin::initBehavior(
'day-view',
array(
'todayEvents' => $this->jsTodayEvents,
'hourlyEvents' => $js_hourly_events,
));
$table_box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($all_day_event_box)

View file

@ -0,0 +1,50 @@
/**
* @provides javelin-behavior-day-view
*/
JX.behavior('day-view', function(config) {
var hourly_events = config.hourlyEvents;
var today_events = config.todayEvents;
function findTodayClusters() {
var events = today_events.sort(function(x, y){
return (x.eventStartEpoch - y.eventStartEpoch);
});
var clusters = [];
events.forEach(function(e){
var destination_cluster_index = null;
var event_start = e.eventStartEpoch - (30*60);
var event_end = e.eventEndEpoch + (30*60);
clusters.forEach(function(cluster, index){
for(var i=0; i < cluster.length; i++) {
var clustered_event = cluster[i];
var compare_event_start = clustered_event.eventStartEpoch;
var compare_event_end = clustered_event.eventEndEpoch;
if (event_start < compare_event_end &&
event_end > compare_event_start) {
destination_cluster_index = index;
break;
}
}
});
if (destination_cluster_index !== null) {
clusters[destination_cluster_index].push(e);
destination_cluster_index = null;
} else {
var next_cluster = [];
next_cluster.push(e);
clusters.push(next_cluster);
}
});
return clusters;
}
var today_clusters = findTodayClusters();
});