This repository has been archived by the owner on Jun 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calendarEventTitle): abstract all event title logic into a servi…
…ce that can easily be overridde BREAKING CHANGE: The `calendarConfig.displayEventTimes` option has been removed. Just override the `calendarEventTitle.yearView` and `calendarEventTitle.monthView` functions instead Closes #349 Closes #361
- Loading branch information
Matt Lewis
committed
Jun 26, 2016
1 parent
08c4292
commit a8ad01a
Showing
12 changed files
with
125 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
var angular = require('angular'); | ||
|
||
angular | ||
.module('mwl.calendar') | ||
.factory('calendarEventTitle', function(calendarDateFilter, calendarTruncateEventTitleFilter) { | ||
|
||
function yearView(event) { | ||
return event.title + ' (' + calendarDateFilter(event.startsAt, 'datetime', true) + ')'; | ||
} | ||
|
||
function monthView(event) { | ||
return event.title + ' (' + calendarDateFilter(event.startsAt, 'time', true) + ')'; | ||
} | ||
|
||
function monthViewTooltip(event) { | ||
return calendarDateFilter(event.startsAt, 'time', true) + ' - ' + event.title; | ||
} | ||
|
||
function weekView(event) { | ||
return event.title; | ||
} | ||
|
||
function weekViewTooltip(event) { | ||
return event.title; | ||
} | ||
|
||
function dayView(event) { | ||
return event.allDay ? event.title : calendarTruncateEventTitleFilter(event.title, 20, event.height); | ||
} | ||
|
||
return { | ||
yearView: yearView, | ||
monthView: monthView, | ||
monthViewTooltip: monthViewTooltip, | ||
weekView: weekView, | ||
weekViewTooltip: weekViewTooltip, | ||
dayView: dayView | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
var angular = require('angular'); | ||
beforeEach(angular.mock.module('mwl.calendar')); | ||
|
||
describe('calendarEventTitle', function() { | ||
|
||
var calendarEventTitle; | ||
beforeEach(inject(function(_calendarEventTitle_) { | ||
calendarEventTitle = _calendarEventTitle_; | ||
})); | ||
|
||
it('should get the year view title', function() { | ||
expect(calendarEventTitle.yearView({ | ||
title: 'Event name', | ||
startsAt: new Date('October 20, 2015 02:00:00') | ||
})).to.equal('Event name (Oct 20, 2:00 AM)'); | ||
}); | ||
|
||
it('should get the month view title', function() { | ||
expect(calendarEventTitle.monthView({ | ||
title: 'Event name', | ||
startsAt: new Date('October 20, 2015 02:00:00') | ||
})).to.equal('Event name (02:00)'); | ||
}); | ||
|
||
it('should get the month view tooltip', function() { | ||
expect(calendarEventTitle.monthViewTooltip({ | ||
title: 'Event name', | ||
startsAt: new Date('October 20, 2015 02:00:00') | ||
})).to.equal('02:00 - Event name'); | ||
}); | ||
|
||
it('should get the week view title', function() { | ||
expect(calendarEventTitle.weekView({ | ||
title: 'Event name', | ||
startsAt: new Date('October 20, 2015 02:00:00') | ||
})).to.equal('Event name'); | ||
}); | ||
|
||
it('should get the week view tooltip', function() { | ||
expect(calendarEventTitle.weekViewTooltip({ | ||
title: 'Event name', | ||
startsAt: new Date('October 20, 2015 02:00:00') | ||
})).to.equal('Event name'); | ||
}); | ||
|
||
it('should get the day view title', function() { | ||
expect(calendarEventTitle.dayView({ | ||
title: 'A really long event title that gets truncated', | ||
startsAt: new Date('October 20, 2015 02:00:00'), | ||
height: 10 | ||
})).to.equal('A really long event ...'); | ||
}); | ||
|
||
it('should get the day view title for an all day event', function() { | ||
expect(calendarEventTitle.dayView({ | ||
title: 'A really long event title thats not truncated', | ||
startsAt: new Date('October 20, 2015 02:00:00'), | ||
height: 10, | ||
allDay: true | ||
})).to.equal('A really long event title thats not truncated'); | ||
}); | ||
|
||
}); |