Add option to skip tags when copying items between libraries

This commit is contained in:
Dan Stillman 2012-11-02 05:45:26 -04:00
parent 079b767974
commit dfd0a7ad83
6 changed files with 17 additions and 8 deletions

View File

@ -64,6 +64,7 @@ To add a new preference:
<preference id="pref-groups-copyChildNotes" name="extensions.zotero.groups.copyChildNotes" type="bool"/> <preference id="pref-groups-copyChildNotes" name="extensions.zotero.groups.copyChildNotes" type="bool"/>
<preference id="pref-groups-copyChildFileAttachments" name="extensions.zotero.groups.copyChildFileAttachments" type="bool"/> <preference id="pref-groups-copyChildFileAttachments" name="extensions.zotero.groups.copyChildFileAttachments" type="bool"/>
<preference id="pref-groups-copyChildLinks" name="extensions.zotero.groups.copyChildLinks" type="bool"/> <preference id="pref-groups-copyChildLinks" name="extensions.zotero.groups.copyChildLinks" type="bool"/>
<preference id="pref-groups-copyTags" name="extensions.zotero.groups.copyTags" type="bool"/>
</preferences> </preferences>
<groupbox id="zotero-prefpane-general-groupbox"> <groupbox id="zotero-prefpane-general-groupbox">
@ -148,6 +149,7 @@ To add a new preference:
<checkbox label="&zotero.preferences.groups.childNotes;" preference="pref-groups-copyChildNotes"/> <checkbox label="&zotero.preferences.groups.childNotes;" preference="pref-groups-copyChildNotes"/>
<checkbox label="&zotero.preferences.groups.childFiles;" preference="pref-groups-copyChildFileAttachments"/> <checkbox label="&zotero.preferences.groups.childFiles;" preference="pref-groups-copyChildFileAttachments"/>
<checkbox label="&zotero.preferences.groups.childLinks;" preference="pref-groups-copyChildLinks"/> <checkbox label="&zotero.preferences.groups.childLinks;" preference="pref-groups-copyChildLinks"/>
<checkbox label="&zotero.preferences.groups.tags;" preference="pref-groups-copyTags"/>
</vbox> </vbox>
</groupbox> </groupbox>

View File

@ -1449,7 +1449,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
// DEBUG: save here because clone() doesn't currently work on unsaved tagged items // DEBUG: save here because clone() doesn't currently work on unsaved tagged items
var id = newItem.save(); var id = newItem.save();
newItem = Zotero.Items.get(id); newItem = Zotero.Items.get(id);
item.clone(false, newItem); item.clone(false, newItem, false, !Zotero.Prefs.get('groups.copyTags'));
newItem.save(); newItem.save();
//var id = newItem.save(); //var id = newItem.save();
//var newItem = Zotero.Items.get(id); //var newItem = Zotero.Items.get(id);

View File

@ -3873,18 +3873,23 @@ Zotero.Item.prototype.multiDiff = function (otherItems, ignoreFields) {
/** /**
* Returns an unsaved copy of the item * Returns an unsaved copy of the item
* *
* @param {Boolean} [includePrimary=false] * @param {Boolean} [includePrimary=false]
* @param {Zotero.Item} [newItem=null] Target item for clone (used to pass a saved * @param {Zotero.Item} [newItem=null] Target item for clone (used to pass a saved
* item for duplicating items with tags) * item for duplicating items with tags)
* @param {Boolean} [unsaved=false] Skip properties that require a saved object (e.g., tags) * @param {Boolean} [unsaved=false] Skip properties that require a saved object (e.g., tags)
* @param {Boolean} [skipTags=false] Skip tags (implied by 'unsaved')
*/ */
Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved) { Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved, skipTags) {
Zotero.debug('Cloning item ' + this.id); Zotero.debug('Cloning item ' + this.id);
if (includePrimary && newItem) { if (includePrimary && newItem) {
throw ("includePrimary and newItem parameters are mutually exclusive in Zotero.Item.clone()"); throw ("includePrimary and newItem parameters are mutually exclusive in Zotero.Item.clone()");
} }
if (unsaved) {
skipTags = true;
}
Zotero.DB.beginTransaction(); Zotero.DB.beginTransaction();
// TODO: get rid of serialize() call // TODO: get rid of serialize() call
@ -4024,7 +4029,7 @@ Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved) {
} }
} }
if (!unsaved && obj.tags) { if (!skipTags && obj.tags) {
for each(var tag in obj.tags) { for each(var tag in obj.tags) {
if (sameLibrary) { if (sameLibrary) {
newItem.addTagByID(tag.primary.tagID); newItem.addTagByID(tag.primary.tagID);

View File

@ -1463,7 +1463,7 @@ var ZoteroPane = new function()
var id = newItem.save(); var id = newItem.save();
var newItem = Zotero.Items.get(id); var newItem = Zotero.Items.get(id);
item.clone(false, newItem); item.clone(false, newItem, false, !Zotero.Prefs.get('groups.copyTags'));
newItem.save(); newItem.save();
if (this.itemsView._itemGroup.isCollection() && !newItem.getSource()) { if (this.itemsView._itemGroup.isCollection() && !newItem.getSource()) {

View File

@ -38,6 +38,7 @@
<!ENTITY zotero.preferences.groups.childNotes "child notes"> <!ENTITY zotero.preferences.groups.childNotes "child notes">
<!ENTITY zotero.preferences.groups.childFiles "child snapshots and imported files"> <!ENTITY zotero.preferences.groups.childFiles "child snapshots and imported files">
<!ENTITY zotero.preferences.groups.childLinks "child links"> <!ENTITY zotero.preferences.groups.childLinks "child links">
<!ENTITY zotero.preferences.groups.tags "tags">
<!ENTITY zotero.preferences.openurl.caption "OpenURL"> <!ENTITY zotero.preferences.openurl.caption "OpenURL">

View File

@ -44,6 +44,7 @@ pref("extensions.zotero.viewOnDoubleClick", true);
pref("extensions.zotero.groups.copyChildLinks", true); pref("extensions.zotero.groups.copyChildLinks", true);
pref("extensions.zotero.groups.copyChildFileAttachments", true); pref("extensions.zotero.groups.copyChildFileAttachments", true);
pref("extensions.zotero.groups.copyChildNotes", true); pref("extensions.zotero.groups.copyChildNotes", true);
pref("extensions.zotero.groups.copyTags", true);
pref("extensions.zotero.backup.numBackups", 2); pref("extensions.zotero.backup.numBackups", 2);
pref("extensions.zotero.backup.interval", 1440); pref("extensions.zotero.backup.interval", 1440);