Skip to content

Commit f99fd6e

Browse files
committed
add basic read support for COLOR prop
1 parent 1d5c408 commit f99fd6e

File tree

7 files changed

+43
-2
lines changed

7 files changed

+43
-2
lines changed

assets/js/app/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,12 @@ var event_render_callback = function event_render_callback(event, element) {
15191519
// Icons
15201520
var icons = [];
15211521

1522+
// Set the background and text colors of the event
1523+
if (event.color) {
1524+
element.css('background-color', event.color);
1525+
element.css('color', fg_for_bg(event.color));
1526+
}
1527+
15221528
if (event.rrule !== undefined) {
15231529
icons.push('fa-repeat');
15241530
}

assets/templates/templates.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/AgenDAV/Event/VObjectEventInstanceTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class VObjectEventInstanceTest extends TestCase
2828
'TRANSP' => 'OPAQUE',
2929
'RRULE' => 'FREQ=MONTHLY',
3030
'RECURRENCE-ID' => '20150109T123456Z',
31+
'COLOR' => 'peachpuff',
3132
'SEQUENCE' => '2',
3233
];
3334

@@ -184,10 +185,12 @@ public function testOneSet()
184185
$vevent = $this->vcalendar->add('VEVENT', [
185186
'SUMMARY' => 'Test summary',
186187
'LOCATION' => 'Test location',
188+
'COLOR' => 'peachpuff',
187189
]);
188190
$instance = new VObjectEventInstance($vevent);
189191
$instance->setSummary('New summary');
190192
$instance->setLocation('');
193+
$instance->setColor('navajowhite');
191194
$this->assertEquals(
192195
'New summary',
193196
$instance->getSummary()
@@ -196,6 +199,10 @@ public function testOneSet()
196199
'',
197200
$instance->getLocation()
198201
);
202+
$this->assertEquals(
203+
'navajowhite',
204+
$instance->getColor()
205+
);
199206
}
200207

201208
public function testSetStart()
@@ -512,6 +519,7 @@ protected function checkSomeProperties(VObjectEventInstance $instance, $recurren
512519
} else {
513520
$this->assertEquals('FREQ=MONTHLY', $instance->getRepeatRule());
514521
}
522+
$this->assertEquals('peachpuff', $instance->getColor());
515523
}
516524

517525
protected function setSomeVAlarms(VEvent $vevent)

tests/AgenDAV/Event/VObjectEventTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function setUp()
2525
$this->vevent = $this->vcalendar->add('VEVENT', [
2626
'UID' => '123456',
2727
'SUMMARY' => 'Initial event instance',
28+
'COLOR' => 'peachpuff',
2829
'MYPROPERTY' => 'Check',
2930
]);
3031
}
@@ -272,6 +273,7 @@ public function testSetBaseInstanceWithBase()
272273
$instance->setStart($now, true);
273274
$instance->setSummary('New test summary');
274275
$instance->setRecurrenceId(RecurrenceId::buildFromString('20150110T100500Z'));
276+
$instance->setColor('navajowhite');
275277

276278
$event->storeInstance($instance);
277279

@@ -280,6 +282,7 @@ public function testSetBaseInstanceWithBase()
280282
$this->assertEmpty($vevent->{'RECURRENCE-ID'});
281283
$this->assertEquals('Check', $vevent->MYPROPERTY);
282284
$this->assertEquals('New test summary', $vevent->SUMMARY);
285+
$this->assertEquals('navajowhite', $vevent->COLOR);
283286
}
284287

285288

web/src/Data/Transformer/FullCalendarEventTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function transform(FullCalendarEvent $fc_event)
6565
'etag' => $fc_event->getEtag(),
6666
'uid' => $event->getUid(),
6767
'title' => $event->getSummary(),
68+
'color' => $event->getColor(),
6869
'start' => $start->format('c'),
6970
'end' => $end->format('c'),
7071
'allDay' => $event->isAllDay(),

web/src/Event/VObjectEventInstance.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public function getSummary()
8282
return (string) $this->vevent->SUMMARY;
8383
}
8484

85+
public function getColor()
86+
{
87+
return (string) $this->vevent->COLOR;
88+
}
89+
8590
/**
8691
* Get the LOCATION property of this event
8792
*
@@ -265,6 +270,10 @@ public function setSummary($summary)
265270
{
266271
$this->setProperty('SUMMARY', $summary);
267272
}
273+
public function setColor($color)
274+
{
275+
$this->setProperty('COLOR', $color);
276+
}
268277

269278
/**
270279
* Set the LOCATION property for this event
@@ -443,6 +452,7 @@ public function touch()
443452
public function copyPropertiesFrom(EventInstance $source)
444453
{
445454
$this->setSummary($source->getSummary());
455+
$this->setColor($source->getColor());
446456
$this->setLocation($source->getLocation());
447457
$this->setDescription($source->getDescription());
448458
$this->setClass($source->getClass());

web/src/EventInstance.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ public function getRepeatRule();
112112
*/
113113
public function getRecurrenceId();
114114

115+
/**
116+
* Get the COLOR property of this event
117+
*
118+
* @return string
119+
*/
120+
public function getColor();
121+
115122
/**
116123
* Returns all recognized reminders for this instance
117124
*
@@ -198,6 +205,13 @@ public function setRepeatRule($rrule);
198205
*/
199206
public function setRecurrenceId(RecurrenceId $recurrence_id = null);
200207

208+
/**
209+
* Set the COLOR property for this event
210+
*
211+
* @param string $color
212+
*/
213+
public function setColor($color);
214+
201215
/**
202216
* Sets the exception status for this instance. This is useful on
203217
* recurrent events which have exceptions (with their own RECURRENCE-ID)
@@ -243,4 +257,3 @@ public function touch();
243257
*/
244258
public function copyPropertiesFrom(EventInstance $source);
245259
}
246-

0 commit comments

Comments
 (0)