Fixes #1158, Cannot drag item to tag with both automatic and manual versions
And create a manual tag when dragging to an automatic tag in the tag selector
This commit is contained in:
parent
7ff2ddae89
commit
6b9f9643da
1 changed files with 30 additions and 5 deletions
|
@ -726,15 +726,40 @@
|
||||||
|
|
||||||
|
|
||||||
function onDrop(event, dropData, session) {
|
function onDrop(event, dropData, session) {
|
||||||
event.target.setAttribute('draggedOver', false);
|
var node = event.target;
|
||||||
|
node.setAttribute('draggedOver', false);
|
||||||
|
|
||||||
|
Zotero.DB.beginTransaction();
|
||||||
|
|
||||||
var ids = dropData.data.split(',');
|
var ids = dropData.data.split(',');
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
var unlock = Zotero.Notifier.begin(true);
|
|
||||||
for each(var item in items) {
|
// Find a manual tag if there is one
|
||||||
item.addTagByID(event.target.getAttribute('tagID'));
|
var tagID = null;
|
||||||
|
var tagIDs = node.getAttribute('tagID').split(/\-/);
|
||||||
|
var tagTypes = node.getAttribute('tagType').split(/\-/);
|
||||||
|
for (var i=0; i<tagIDs.length; i++) {
|
||||||
|
if (tagTypes[i] == 0) {
|
||||||
|
tagID = Zotero.Tags.get(tagIDs[i]).id
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Zotero.Notifier.commit(unlock);
|
}
|
||||||
|
|
||||||
|
// Otherwise use value
|
||||||
|
if (!tagID) {
|
||||||
|
var value = node.getAttribute('value');
|
||||||
|
}
|
||||||
|
|
||||||
|
for each(var item in items) {
|
||||||
|
if (tagID) {
|
||||||
|
item.addTagByID(tagID);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.addTag(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Zotero.DB.commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue