File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ class Journal extends React.PureComponent<PropsTypeInner> {
5151
5252 render ( ) {
5353 const { theme } = this . props ;
54- const currentTab = this . state . tab ;
54+ let currentTab = this . state . tab ;
55+ let journalOnly = false ;
5556 const journalUid = this . props . match . params . journalUid ;
5657
5758 const syncJournal = this . props . syncInfo . get ( journalUid ) ;
@@ -73,11 +74,18 @@ class Journal extends React.PureComponent<PropsTypeInner> {
7374 itemsView =
7475 < JournalAddressBook journal = { journal } entries = { syncEntriesToItemMap ( collectionInfo , syncEntries ) } /> ;
7576 itemsTitle = 'Contacts' ;
77+ } else if ( collectionInfo . type === 'TASKS' ) {
78+ itemsView = < div > Task preview is not yet supported</ div > ;
79+ itemsTitle = 'Tasks' ;
80+ journalOnly = true ;
7681 } else {
77- itemsView = < div > Unsupported type</ div > ;
82+ itemsView = < div > Preview is not supported for this journal type</ div > ;
7883 itemsTitle = 'Items' ;
84+ journalOnly = true ;
7985 }
8086
87+ currentTab = journalOnly ? 1 : currentTab ;
88+
8189 return (
8290 < React . Fragment >
8391 < SecondaryHeader text = { collectionInfo . displayName } />
@@ -87,7 +95,7 @@ class Journal extends React.PureComponent<PropsTypeInner> {
8795 value = { currentTab }
8896 onChange = { ( event , tab ) => this . setState ( { tab } ) }
8997 >
90- < Tab label = { itemsTitle } />
98+ < Tab label = { itemsTitle } disabled = { journalOnly } />
9199 < Tab label = "Journal Entries" />
92100 </ Tabs >
93101 { currentTab === 0 &&
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ class SideMenuJournals extends React.PureComponent {
4646 return ret ;
4747 } ,
4848 { CALENDAR : [ ] ,
49- ADDRESS_BOOK : [ ]
49+ ADDRESS_BOOK : [ ] ,
50+ TASKS : [ ]
5051 } ) ;
5152
5253 return (
@@ -60,6 +61,11 @@ class SideMenuJournals extends React.PureComponent {
6061 primaryText = "Calendars"
6162 nestedItems = { journalMap . CALENDAR }
6263 />
64+
65+ < ListItem
66+ primaryText = "Tasks"
67+ nestedItems = { journalMap . TASKS }
68+ />
6369 </ React . Fragment >
6470 ) ;
6571 }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import IconEdit from '@material-ui/icons/Edit';
1313
1414import * as ICAL from 'ical.js' ;
1515
16- import { EventType , ContactType } from '../pim-types' ;
16+ import { TaskType , EventType , ContactType } from '../pim-types' ;
1717
1818import * as EteSync from '../api/EteSync' ;
1919
@@ -57,9 +57,15 @@ class JournalEntries extends React.PureComponent {
5757 let name ;
5858 let uid ;
5959 if ( comp . name === 'vcalendar' ) {
60- const vevent = EventType . fromVCalendar ( comp ) ;
61- name = vevent . summary ;
62- uid = vevent . uid ;
60+ if ( EventType . isEvent ( comp ) ) {
61+ const vevent = EventType . fromVCalendar ( comp ) ;
62+ name = vevent . summary ;
63+ uid = vevent . uid ;
64+ } else {
65+ const vtodo = TaskType . fromVCalendar ( comp ) ;
66+ name = vtodo . summary ;
67+ uid = vtodo . uid ;
68+ }
6369 } else if ( comp . name === 'vcard' ) {
6470 const vcard = new ContactType ( comp ) ;
6571 name = vcard . fn ;
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ export interface PimType {
99export class EventType extends ICAL . Event implements PimType {
1010 color : string ;
1111
12+ static isEvent ( comp : ICAL . Component ) {
13+ return ! ! comp . getFirstSubcomponent ( 'vevent' ) ;
14+ }
15+
1216 static fromVCalendar ( comp : ICAL . Component ) {
1317 return new EventType ( comp . getFirstSubcomponent ( 'vevent' ) ) ;
1418 }
@@ -49,6 +53,29 @@ export class EventType extends ICAL.Event implements PimType {
4953 }
5054}
5155
56+ export class TaskType extends ICAL . Event implements PimType {
57+ color : string ;
58+
59+ static fromVCalendar ( comp : ICAL . Component ) {
60+ return new EventType ( comp . getFirstSubcomponent ( 'vtodo' ) ) ;
61+ }
62+
63+ toIcal ( ) {
64+ let comp = new ICAL . Component ( [ 'vcalendar' , [ ] , [ ] ] ) ;
65+ comp . updatePropertyWithValue ( 'prodid' , '-//iCal.js EteSync Web' ) ;
66+ comp . updatePropertyWithValue ( 'version' , '4.0' ) ;
67+
68+ comp . addSubcomponent ( this . component ) ;
69+ return comp . toString ( ) ;
70+ }
71+
72+ clone ( ) {
73+ const ret = new TaskType ( new ICAL . Component ( this . component . toJSON ( ) ) ) ;
74+ ret . color = this . color ;
75+ return ret ;
76+ }
77+ }
78+
5279export class ContactType implements PimType {
5380 comp : ICAL . Component ;
5481
You can’t perform that action at this time.
0 commit comments