mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
Created new todo button, and option to switch is_todo
This commit is contained in:
parent
2b1d5ff726
commit
43dff9362a
@ -19,6 +19,7 @@ class MainScreenComponent extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
newNotePromptVisible: false,
|
newNotePromptVisible: false,
|
||||||
newFolderPromptVisible: false,
|
newFolderPromptVisible: false,
|
||||||
|
promptOptions: null,
|
||||||
noteVisiblePanes: ['editor', 'viewer'],
|
noteVisiblePanes: ['editor', 'viewer'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -39,6 +40,7 @@ class MainScreenComponent extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const style = this.props.style;
|
const style = this.props.style;
|
||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
|
const promptOptions = this.state.promptOptions;
|
||||||
|
|
||||||
const headerStyle = {
|
const headerStyle = {
|
||||||
width: style.width,
|
width: style.width,
|
||||||
@ -72,72 +74,98 @@ class MainScreenComponent extends React.Component {
|
|||||||
height: style.height,
|
height: style.height,
|
||||||
};
|
};
|
||||||
|
|
||||||
const headerButtons = [
|
const createNewNote = async (title, isTodo) => {
|
||||||
{
|
const folderId = Setting.value('activeFolderId');
|
||||||
title: _('New note'),
|
if (!folderId) return;
|
||||||
onClick: () => {
|
|
||||||
this.setState({ newNotePromptVisible: true });
|
const note = await Note.save({
|
||||||
},
|
title: title,
|
||||||
iconName: 'fa-file-o',
|
parent_id: folderId,
|
||||||
}, {
|
is_todo: isTodo ? 1 : 0,
|
||||||
title: _('New notebook'),
|
});
|
||||||
onClick: () => {
|
Note.updateGeolocation(note.id);
|
||||||
this.setState({ newFolderPromptVisible: true });
|
|
||||||
},
|
this.props.dispatch({
|
||||||
iconName: 'fa-folder-o',
|
type: 'NOTE_SELECT',
|
||||||
}, {
|
id: note.id,
|
||||||
title: _('Layout'),
|
});
|
||||||
onClick: () => {
|
}
|
||||||
this.toggleVisiblePanes();
|
|
||||||
},
|
const headerButtons = [];
|
||||||
iconName: 'fa-columns',
|
|
||||||
|
headerButtons.push({
|
||||||
|
title: _('New note'),
|
||||||
|
iconName: 'fa-file-o',
|
||||||
|
onClick: () => {
|
||||||
|
this.setState({
|
||||||
|
promptOptions: {
|
||||||
|
message: _('Note title:'),
|
||||||
|
onClose: async (answer) => {
|
||||||
|
if (answer) await createNewNote(answer, false);
|
||||||
|
this.setState({ promptOptions: null });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
];
|
});
|
||||||
|
|
||||||
|
headerButtons.push({
|
||||||
const newNotePromptOnClose = async (answer) => {
|
title: _('New to-do'),
|
||||||
if (answer) {
|
iconName: 'fa-check-square-o',
|
||||||
const folderId = Setting.value('activeFolderId');
|
onClick: () => {
|
||||||
if (!folderId) return;
|
this.setState({
|
||||||
|
promptOptions: {
|
||||||
const note = await Note.save({
|
message: _('Note title:'),
|
||||||
title: answer,
|
onClose: async (answer) => {
|
||||||
parent_id: folderId,
|
if (answer) await createNewNote(answer, true);
|
||||||
|
this.setState({ promptOptions: null });
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
Note.updateGeolocation(note.id);
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.props.dispatch({
|
headerButtons.push({
|
||||||
type: 'NOTE_SELECT',
|
title: _('New notebook'),
|
||||||
id: note.id,
|
iconName: 'fa-folder-o',
|
||||||
|
onClick: () => {
|
||||||
|
this.setState({
|
||||||
|
promptOptions: {
|
||||||
|
message: _('Notebook title:'),
|
||||||
|
onClose: async (answer) => {
|
||||||
|
if (answer) {
|
||||||
|
let folder = null;
|
||||||
|
try {
|
||||||
|
folder = await Folder.save({ title: answer }, { userSideValidation: true });
|
||||||
|
} catch (error) {
|
||||||
|
bridge().showErrorMessageBox(error.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.dispatch({
|
||||||
|
type: 'FOLDER_SELECT',
|
||||||
|
id: folder.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ promptOptions: null });
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.setState({ newNotePromptVisible: false });
|
headerButtons.push({
|
||||||
}
|
title: _('Layout'),
|
||||||
|
iconName: 'fa-columns',
|
||||||
const newFolderPromptOnClose = async (answer) => {
|
onClick: () => {
|
||||||
if (answer) {
|
this.toggleVisiblePanes();
|
||||||
let folder = null;
|
},
|
||||||
try {
|
});
|
||||||
folder = await Folder.save({ title: answer }, { userSideValidation: true });
|
|
||||||
} catch (error) {
|
|
||||||
bridge().showErrorMessageBox(error.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.dispatch({
|
|
||||||
type: 'FOLDER_SELECT',
|
|
||||||
id: folder.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ newFolderPromptVisible: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={style}>
|
<div style={style}>
|
||||||
<PromptDialog style={promptStyle} onClose={(answer) => newNotePromptOnClose(answer)} message={_('Note title:')} visible={this.state.newNotePromptVisible}/>
|
<PromptDialog theme={this.props.theme} style={promptStyle} onClose={(answer) => promptOptions.onClose(answer)} message={promptOptions ? promptOptions.message : ''} visible={!!this.state.promptOptions}/>
|
||||||
<PromptDialog style={promptStyle} onClose={(answer) => newFolderPromptOnClose(answer)} message={_('Notebook title:')} visible={this.state.newFolderPromptVisible}/>
|
|
||||||
<Header style={headerStyle} showBackButton={false} buttons={headerButtons} />
|
<Header style={headerStyle} showBackButton={false} buttons={headerButtons} />
|
||||||
<SideBar style={sideBarStyle} />
|
<SideBar style={sideBarStyle} />
|
||||||
<NoteList itemHeight={40} style={noteListStyle} />
|
<NoteList itemHeight={40} style={noteListStyle} />
|
||||||
@ -150,7 +178,7 @@ class MainScreenComponent extends React.Component {
|
|||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
theme: state.theme,
|
theme: state.settings.theme,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,11 +56,18 @@ class NoteListComponent extends React.Component {
|
|||||||
if (!noteId) throw new Error('No data-id on element');
|
if (!noteId) throw new Error('No data-id on element');
|
||||||
|
|
||||||
const menu = new Menu()
|
const menu = new Menu()
|
||||||
|
|
||||||
menu.append(new MenuItem({label: _('Delete'), click: async () => {
|
menu.append(new MenuItem({label: _('Delete'), click: async () => {
|
||||||
const ok = bridge().showConfirmMessageBox(_('Delete note?'));
|
const ok = bridge().showConfirmMessageBox(_('Delete note?'));
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
await Note.delete(noteId);
|
await Note.delete(noteId);
|
||||||
|
}}));
|
||||||
|
|
||||||
|
menu.append(new MenuItem({label: _('Switch between note and to-do'), click: async () => {
|
||||||
|
const note = await Note.load(noteId);
|
||||||
|
await Note.save(Note.toggleIsTodo(note));
|
||||||
}}))
|
}}))
|
||||||
|
|
||||||
menu.popup(bridge().window());
|
menu.popup(bridge().window());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class PromptDialog extends React.Component {
|
|||||||
|
|
||||||
const promptDialogStyle = {
|
const promptDialogStyle = {
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
padding: 10,
|
padding: 16,
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
boxShadow: '6px 6px 20px rgba(0,0,0,0.5)',
|
boxShadow: '6px 6px 20px rgba(0,0,0,0.5)',
|
||||||
};
|
};
|
||||||
@ -55,6 +55,13 @@ class PromptDialog extends React.Component {
|
|||||||
marginLeft: 5,
|
marginLeft: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const labelStyle = {
|
||||||
|
marginRight: 5,
|
||||||
|
fontSize: theme.fontSize,
|
||||||
|
color: theme.color,
|
||||||
|
fontFamily: theme.fontFamily,
|
||||||
|
};
|
||||||
|
|
||||||
const inputStyle = {
|
const inputStyle = {
|
||||||
width: 0.5 * style.width,
|
width: 0.5 * style.width,
|
||||||
maxWidth: 400,
|
maxWidth: 400,
|
||||||
@ -80,7 +87,7 @@ class PromptDialog extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div style={modalLayerStyle}>
|
<div style={modalLayerStyle}>
|
||||||
<div style={promptDialogStyle}>
|
<div style={promptDialogStyle}>
|
||||||
<label style={{ marginRight: 5 }}>{this.props.message ? this.props.message : ''}</label>
|
<label style={labelStyle}>{this.props.message ? this.props.message : ''}</label>
|
||||||
<input
|
<input
|
||||||
style={inputStyle}
|
style={inputStyle}
|
||||||
ref={input => this.answerInput_ = input}
|
ref={input => this.answerInput_ = input}
|
||||||
|
@ -59,6 +59,7 @@ globalStyle.lineInput = {
|
|||||||
let themeCache_ = {};
|
let themeCache_ = {};
|
||||||
|
|
||||||
function themeStyle(theme) {
|
function themeStyle(theme) {
|
||||||
|
if (!theme) throw new Error('Theme must be specified');
|
||||||
if (themeCache_[theme]) return themeCache_[theme];
|
if (themeCache_[theme]) return themeCache_[theme];
|
||||||
|
|
||||||
let output = Object.assign({}, globalStyle);
|
let output = Object.assign({}, globalStyle);
|
||||||
|
Loading…
Reference in New Issue
Block a user