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

Electron: Resolves #679: Drag a note on a tag to associate the tag.

This commit is contained in:
Laurent Cozic 2018-09-05 11:43:03 +01:00
parent 758562cff9
commit 35294b5f97

View File

@ -55,6 +55,21 @@ class SideBarComponent extends React.Component {
} }
}; };
this.onTagDrop_ = async (event) => {
const tagId = event.currentTarget.getAttribute('tagid');
const dt = event.dataTransfer;
if (!dt) return;
if (dt.types.indexOf("text/x-jop-note-ids") >= 0) {
event.preventDefault();
const noteIds = JSON.parse(dt.getData("text/x-jop-note-ids"));
for (let i = 0; i < noteIds.length; i++) {
await Tag.addNote(tagId, noteIds[i]);
}
}
}
this.onFolderToggleClick_ = async (event) => { this.onFolderToggleClick_ = async (event) => {
const folderId = event.currentTarget.getAttribute('folderid'); const folderId = event.currentTarget.getAttribute('folderid');
@ -354,8 +369,10 @@ class SideBarComponent extends React.Component {
data-id={tag.id} data-id={tag.id}
data-type={BaseModel.TYPE_TAG} data-type={BaseModel.TYPE_TAG}
onContextMenu={event => this.itemContextMenu(event)} onContextMenu={event => this.itemContextMenu(event)}
tagid={tag.id}
key={tag.id} key={tag.id}
style={style} style={style}
onDrop={this.onTagDrop_}
onClick={() => { onClick={() => {
this.tagItem_click(tag); this.tagItem_click(tag);
}} }}