1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Merge pull request #543 from Abijeet/tag-rename

Adds functionality to allow for renaming of tags.
This commit is contained in:
Laurent Cozic 2018-05-20 12:24:15 +01:00 committed by GitHub
commit 2bcaf62a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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());
}