From 56f976c766b3e611e88c6d3124805edc2070a073 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 12 Feb 2019 19:51:33 +0000 Subject: [PATCH] Implement journal creation and deletion. --- src/Journals/JournalEdit.tsx | 28 +++++++++++++++++++++++++++- src/Journals/index.tsx | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/Journals/JournalEdit.tsx b/src/Journals/JournalEdit.tsx index 5ffd273..d42e56f 100644 --- a/src/Journals/JournalEdit.tsx +++ b/src/Journals/JournalEdit.tsx @@ -1,6 +1,10 @@ import * as React from 'react'; import Button from '@material-ui/core/Button'; import TextField from '@material-ui/core/TextField'; +import Select from '@material-ui/core/Select'; +import MenuItem from '@material-ui/core/MenuItem'; +import FormControl from '@material-ui/core/FormControl'; +import InputLabel from '@material-ui/core/InputLabel'; import { Theme, withTheme } from '@material-ui/core/styles'; import IconDelete from '@material-ui/icons/Delete'; import IconCancel from '@material-ui/icons/Clear'; @@ -53,7 +57,7 @@ class JournalEdit extends React.PureComponent { this.state.info = {...collection}; } else { this.state.info.uid = EteSync.genUid(); - // FIXME: set the type + this.state.info.type = 'ADDRESS_BOOK'; } } @@ -73,13 +77,35 @@ class JournalEdit extends React.PureComponent { }, }; + const journalTypes = { + ADDRESS_BOOK: 'Address Book', + CALENDAR: 'Calendar', + TASKS: 'Task List', + }; + return ( <>
+ + + Collection type + + + ( <> - + + + + + )} /> + ( + + )} + /> { @@ -112,7 +135,13 @@ class Journals extends React.PureComponent { } onItemDelete(info: EteSync.CollectionInfo) { - return; + const journal = new EteSync.Journal(); + const cryptoManager = new EteSync.CryptoManager(this.props.etesync.encryptionKey, info.uid); + journal.setInfo(cryptoManager, info); + + store.dispatch(deleteJournal(this.props.etesync, journal)).then(() => + this.props.history.push(routeResolver.getRoute('journals')) + ); } onCancel() {