1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Adds functionality to allow for renaming of tags.

Towards #374

Signed-off-by: Abijeet <abijeetpatro@gmail.com>
This commit is contained in:
Abijeet 2018-05-20 13:09:32 +05:30
parent 43bab3c1bd
commit 48883bfa13
2 changed files with 37 additions and 0 deletions

View File

@ -145,6 +145,28 @@ class MainScreenComponent extends React.Component {
}
},
});
} else if (command.name === 'renameTag') {
const tag = await Tag.load(command.id);
if(!tag) return;
this.setState({
promptOptions: {
label: _('Rename tag:'),
value: tag.title,
onClose: async (answer) => {
if (answer !== null) {
try {
tag.title = answer;
await Tag.save(tag, { fields: ['title'], userSideValidation: true });
} catch (error) {
bridge().showErrorMessageBox(error.message);
}
}
this.setState({promptOptions: null });
}
}
})
} else if (command.name === 'search') {
if (!this.searchId_) this.searchId_ = uuid.create();

View File

@ -250,6 +250,21 @@ class SideBarComponent extends React.Component {
);
}
if (itemType === BaseModel.TYPE_TAG) {
menu.append(
new MenuItem({
label: _('Rename'),
click: async () => {
this.props.dispatch({
type: "WINDOW_COMMAND",
name: "renameTag",
id: itemId
});
},
})
);
}
menu.popup(bridge().window());
}