commit 6b9f9643da219d03d38f8c1125e836e5c6fdcbdb
parent 7ff2ddae8938a78be0b1b4771d46dc3de89a28f3
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 30 Sep 2010 22:00:45 +0000
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
Diffstat:
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml
@@ -726,15 +726,40 @@
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 items = Zotero.Items.get(ids);
- var unlock = Zotero.Notifier.begin(true);
+
+ // Find a manual tag if there is one
+ 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;
+ }
+ }
+
+ // Otherwise use value
+ if (!tagID) {
+ var value = node.getAttribute('value');
+ }
+
for each(var item in items) {
- item.addTagByID(event.target.getAttribute('tagID'));
+ if (tagID) {
+ item.addTagByID(tagID);
+ }
+ else {
+ item.addTag(value);
+ }
}
- Zotero.Notifier.commit(unlock);
+
+ Zotero.DB.commitTransaction();
}