Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Assign note to Notebook or Sub_Notebook functionality added #2566

Merged
merged 7 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ElectronClient/gui/MainScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,35 @@ class MainScreenComponent extends React.Component {
},
},
});
} else if (command.name === 'moveToFolder') {
const startFolders = [];
const maxDepth = 15;

const addOptions = (folders, depth) => {
for (let i = 0; i < folders.length; i++) {
const folder = folders[i];
startFolders.push({ key: folder.id, value: folder.id, label: folder.title, indentDepth: depth });
if (folder.children) addOptions(folder.children, (depth + 1) < maxDepth ? depth + 1 : maxDepth);
}
};
addOptions(await Folder.allAsTree(), 0);

this.setState({
promptOptions: {
label: _('Move to notebook:'),
inputType: 'dropdown',
value: '',
autocomplete: startFolders,
onClose: async answer => {
if (answer != null) {
for (let i = 0; i < command.noteIds.length; i++) {
await Note.moveToFolder(command.noteIds[i], answer.value);
}
}
this.setState({ promptOptions: null });
},
},
});
} else if (command.name === 'renameFolder') {
const folder = await Folder.load(command.id);

Expand Down
3 changes: 2 additions & 1 deletion ElectronClient/gui/PromptDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ class PromptDialog extends React.Component {
fontFamily: theme.fontFamily,
backgroundColor: theme.backgroundColor,
}),
option: provided =>
option: (provided, state) =>
Object.assign(provided, {
color: theme.color,
fontFamily: theme.fontFamily,
paddingLeft: `${10 + (state.data.indentDepth || 0) * 20}px`,
}),
multiValueLabel: provided =>
Object.assign(provided, {
Expand Down
13 changes: 13 additions & 0 deletions ElectronClient/gui/utils/NoteListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ class NoteListUtils {
})
);

menu.append(
new MenuItem({
label: _('Move to notebook'),
click: () => {
props.dispatch({
type: 'WINDOW_COMMAND',
name: 'moveToFolder',
noteIds: noteIds,
});
},
})
);

menu.append(
new MenuItem({
label: _('Duplicate'),
Expand Down