@ -110,7 +110,7 @@ type CollectionRoutesPropsType = RouteComponentProps<{}> & {
componentEdit : any ;
componentEdit : any ;
componentView : any ;
componentView : any ;
items : { [ key : string ] : PimType } ;
items : { [ key : string ] : PimType } ;
onItemSave : ( item : PimType , journalUid : string , originalItem? : PimType ) = > void ;
onItemSave : ( item : PimType , journalUid : string , originalItem? : PimType ) = > Promise < void > ;
onItemDelete : ( item : PimType , journalUid : string ) = > void ;
onItemDelete : ( item : PimType , journalUid : string ) = > void ;
onItemCancel : ( ) = > void ;
onItemCancel : ( ) = > void ;
classes : any ;
classes : any ;
@ -144,6 +144,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
collections = { props . collections }
collections = { props . collections }
onSave = { props . onItemSave }
onSave = { props . onItemSave }
onCancel = { props . onItemCancel }
onCancel = { props . onItemCancel }
history = { props . history }
/ >
/ >
< / Container >
< / Container >
) }
) }
@ -161,6 +162,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
onSave = { props . onItemSave }
onSave = { props . onItemSave }
onDelete = { props . onItemDelete }
onDelete = { props . onItemDelete }
onCancel = { props . onItemCancel }
onCancel = { props . onItemCancel }
history = { props . history }
/ >
/ >
}
}
< / Container >
< / Container >
@ -238,11 +240,11 @@ class Pim extends React.PureComponent {
this . onItemSave = this . onItemSave . bind ( this ) ;
this . onItemSave = this . onItemSave . bind ( this ) ;
}
}
public onItemSave ( item : PimType , journalUid : string , originalEvent? : PimType ) {
public onItemSave ( item : PimType , journalUid : string , originalEvent? : PimType ) : Promise < void > {
const syncJournal = this . props . syncInfo . get ( journalUid ) ;
const syncJournal = this . props . syncInfo . get ( journalUid ) ;
if ( syncJournal === undefined ) {
if ( syncJournal === undefined ) {
return ;
return Promise . reject ( ) ;
}
}
const journal = syncJournal . journal ;
const journal = syncJournal . journal ;
@ -254,7 +256,7 @@ class Pim extends React.PureComponent {
if ( last ) {
if ( last ) {
prevUid = last . uid ;
prevUid = last . uid ;
}
}
store . dispatch < any > ( fetchEntries ( this . props . etesync , journal . uid , prevUid ) )
return store . dispatch < any > ( fetchEntries ( this . props . etesync , journal . uid , prevUid ) )
. then ( ( entriesAction : Action < EteSync.Entry [ ] > ) = > {
. then ( ( entriesAction : Action < EteSync.Entry [ ] > ) = > {
last = entriesAction . payload ! . slice ( - 1 ) . pop ( ) as EteSync . Entry ;
last = entriesAction . payload ! . slice ( - 1 ) . pop ( ) as EteSync . Entry ;
@ -263,13 +265,10 @@ class Pim extends React.PureComponent {
prevUid = last . uid ;
prevUid = last . uid ;
}
}
const saveEvent = store . dispatch (
return store . dispatch (
addJournalEntry (
addJournalEntry (
this . props . etesync , this . props . userInfo , journal ,
this . props . etesync , this . props . userInfo , journal ,
prevUid , action , item . toIcal ( ) ) ) ;
prevUid , action , item . toIcal ( ) ) ) ;
( saveEvent as any ) . then ( ( ) = > {
this . props . history . goBack ( ) ;
} ) ;
} ) ;
} ) ;
}
}