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:
commit
2bcaf62a2f
@ -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();
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user