zotero/chrome/content/zotero/selectItemsDialog.js
Dan Stillman 56c7afc47e Duplicate detection:
- Adds a per-library "Duplicate Items" virtual search to the source list -- shows up by default for "My Library" but can be added to and removed from all libraries
- Current matching algorithm is very basic: finds exact title matches (after normalizing case/diacritics/punctuation/spacing) and DOI/ISBN matches (untested)
- In duplicates view, sets are selected automatically; in other views, duplicate items can be selected manually and the merge interface can be brought up with "Merge Items" in the context menu
- Can select a master item and individual fields to merge from other versions
- Word processor integration code will automatically find mapped replacements and update documents with new item keys

Possible future improvements:

- Improved detection algorithms
- UI tweaks
- Currently if any items differ, all available versions will be shown as master item options, even if only one item is different; probably the earliest equivalent item should be shown for each distinct version
- Caching of results for performance
- Confidence scale
- Creator version selection (currently the creators from the chosen master item are kept)
- Merging of matching child items
- Better sorting of duplicates if not clustered together by the selected sort column
- Relation path compression when merging items that are already mapped to previously removed duplicates

Other changes in this commit:

- Don't show Trash in word processor integration windows
- Consider items in trash to be missing in word processor documents
- Selection of special views (Trash, Unfiled, Duplicates) is now restored properly in new windows
- Disabled field transform context menu when item isn't editable
- Left/right arrow now expands/collapses all selected items instead of just the last-selected row
- Relation deletions are now synced
- The same items row is now reselected after item deletion
- (dev) Zotero.Item.getNotes(), Zotero.Item.getAttachments(), and Zotero.Item.getTags() now return empty arrays rather than FALSE if no matches -- tests on those return values in third-party code will need to be changed
- (dev) New function Zotero.Utilities.removeDiacritics(str, lowercaseOnly) -- could be used to generate ASCII BibTeX keys
- (dev) New 'tempTable' search condition can take a table to join against -- useful for implementing virtual source lists
- (dev) Significant UI code cleanup
- (dev) Moved all item pane content into itemPane.xul
- Probably various other things


Needless to say, this needs testing.
2011-07-22 21:24:38 +00:00

110 lines
No EOL
3.1 KiB
JavaScript

/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
var itemsView;
var collectionsView;
var io;
/*
* window takes two arguments:
* io - used for input/output (dataOut is list of item IDs)
* sourcesOnly - whether only sources should be shown in the window
*/
function doLoad()
{
// Set font size from pref
var sbc = document.getElementById('zotero-select-items-container');
Zotero.setFontSize(sbc);
io = window.arguments[0];
if(io.wrappedJSObject) io = io.wrappedJSObject;
if(io.addBorder) document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
if(io.singleSelection) document.getElementById("zotero-items-tree").setAttribute("seltype", "single");
collectionsView = new Zotero.CollectionTreeView();
// Don't show Commons when citing
collectionsView.hideSources = ['duplicates', 'trash', 'commons'];
document.getElementById('zotero-collections-tree').view = collectionsView;
if(io.select) itemsView.selectItem(io.select);
Zotero.updateQuickSearchBox(document);
}
function doUnload()
{
collectionsView.unregister();
if(itemsView)
itemsView.unregister();
}
function onCollectionSelected()
{
if(itemsView)
itemsView.unregister();
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
{
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
collection.setSearch('');
try {
Zotero.UnresponsiveScriptIndicator.disable();
itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
document.getElementById('zotero-items-tree').view = itemsView;
}
finally {
Zotero.UnresponsiveScriptIndicator.enable();
}
if (collection.isLibrary()) {
Zotero.Prefs.set('lastViewedFolder', 'L');
}
if (collection.isCollection()) {
Zotero.Prefs.set('lastViewedFolder', 'C' + collection.ref.getID());
}
else if (collection.isSearch()) {
Zotero.Prefs.set('lastViewedFolder', 'S' + collection.ref.id);
}
}
}
function onSearch()
{
if(itemsView)
{
var searchVal = document.getElementById('zotero-tb-search').value;
itemsView.setFilter('search', searchVal);
}
}
function onItemSelected()
{
}
function doAccept()
{
io.dataOut = itemsView.getSelectedItems(true);
}