2011-01-30 09:44:01 +00:00
/ *
* * * * * 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
2011-05-18 18:34:22 +00:00
it under the terms of the GNU Affero General Public License as published by
2011-01-30 09:44:01 +00:00
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
2011-05-18 18:34:22 +00:00
GNU Affero General Public License for more details .
2011-01-30 09:44:01 +00:00
2011-05-18 18:34:22 +00:00
You should have received a copy of the GNU Affero General Public License
2011-01-30 09:44:01 +00:00
along with Zotero . If not , see < http : //www.gnu.org/licenses/>.
* * * * * END LICENSE BLOCK * * * * *
* /
2019-08-24 08:25:51 +00:00
import FilePicker from 'zotero/filePicker' ;
2011-01-30 09:44:01 +00:00
/ *
* This object contains the various functions for the interface
* /
var ZoteroPane = new function ( )
{
2011-09-06 01:26:13 +00:00
var _unserialized = false ;
2011-01-30 09:44:01 +00:00
this . collectionsView = false ;
this . itemsView = false ;
2016-10-14 13:21:48 +00:00
this . progressWindow = false ;
2014-09-23 05:11:41 +00:00
this . _listeners = { } ;
2016-10-15 19:20:09 +00:00
this . _ _defineGetter _ _ ( 'loaded' , function ( ) { return _loaded ; } ) ;
2015-05-07 19:05:37 +00:00
var _lastSelectedItems = [ ] ;
2011-01-30 09:44:01 +00:00
//Privileged methods
this . destroy = destroy ;
this . isFullScreen = isFullScreen ;
this . handleKeyDown = handleKeyDown ;
this . handleKeyUp = handleKeyUp ;
this . setHighlightedRowsCallback = setHighlightedRowsCallback ;
this . handleKeyPress = handleKeyPress ;
this . getSelectedCollection = getSelectedCollection ;
this . getSelectedSavedSearch = getSelectedSavedSearch ;
this . getSelectedItems = getSelectedItems ;
this . getSortedItems = getSortedItems ;
this . getSortField = getSortField ;
this . getSortDirection = getSortDirection ;
this . setItemsPaneMessage = setItemsPaneMessage ;
this . clearItemsPaneMessage = clearItemsPaneMessage ;
this . viewSelectedAttachment = viewSelectedAttachment ;
this . reportErrors = reportErrors ;
2011-05-19 23:00:01 +00:00
this . document = document ;
2011-08-25 21:24:51 +00:00
var self = this ,
_loaded = false , _madeVisible = false ,
titlebarcolorState , titleState , observerService ,
2013-11-05 20:52:40 +00:00
_reloadFunctions = [ ] , _beforeReloadFunctions = [ ] ;
2011-01-30 09:44:01 +00:00
2011-06-14 00:36:21 +00:00
/ * *
2011-01-30 09:44:01 +00:00
* Called when the window containing Zotero pane is open
* /
2017-07-07 07:20:06 +00:00
this . init = function ( ) {
2013-08-12 00:51:16 +00:00
Zotero . debug ( "Initializing Zotero pane" ) ;
2021-02-11 10:57:35 +00:00
if ( ! Zotero . isPDFBuild ) {
let win = document . getElementById ( 'main-window' )
win . setAttribute ( 'legacytoolbar' , 'true' ) ;
document . getElementById ( 'titlebar' ) . hidden = true ;
document . getElementById ( 'tab-bar-container' ) . hidden = true ;
}
2011-01-30 09:44:01 +00:00
// Set key down handler
2011-03-08 23:46:01 +00:00
document . getElementById ( 'appcontent' ) . addEventListener ( 'keydown' , ZoteroPane _Local . handleKeyDown , true ) ;
2011-01-30 09:44:01 +00:00
2018-10-05 05:56:46 +00:00
// Init toolbar buttons for all progress queues
let progressQueueButtons = document . getElementById ( 'zotero-pq-buttons' ) ;
let progressQueues = Zotero . ProgressQueues . getAll ( ) ;
for ( let progressQueue of progressQueues ) {
let button = document . createElement ( 'toolbarbutton' ) ;
button . id = 'zotero-tb-pq-' + progressQueue . getID ( ) ;
button . hidden = progressQueue . getTotal ( ) < 1 ;
button . addEventListener ( 'command' , function ( ) {
Zotero . ProgressQueues . get ( progressQueue . getID ( ) ) . getDialog ( ) . open ( ) ;
} , false ) ;
progressQueue . addListener ( 'empty' , function ( ) {
button . hidden = true ;
} ) ;
progressQueue . addListener ( 'nonempty' , function ( ) {
button . hidden = false ;
} ) ;
progressQueueButtons . appendChild ( button ) ;
}
2018-01-20 08:45:00 +00:00
2011-01-30 09:44:01 +00:00
_loaded = true ;
2011-02-12 19:56:13 +00:00
var zp = document . getElementById ( 'zotero-pane' ) ;
2011-02-13 03:51:24 +00:00
Zotero . setFontSize ( zp ) ;
2016-05-28 00:57:29 +00:00
ZoteroPane _Local . updateLayout ( ) ;
2011-06-14 00:36:21 +00:00
ZoteroPane _Local . updateToolbarPosition ( ) ;
2017-07-07 07:20:06 +00:00
this . updateWindow ( ) ;
window . addEventListener ( "resize" , ( ) => {
this . updateWindow ( ) ;
this . updateToolbarPosition ( ) ;
2019-11-13 10:28:03 +00:00
this . updateTagsBoxSize ( ) ;
2017-07-07 07:20:06 +00:00
} ) ;
2019-03-28 09:19:41 +00:00
window . setTimeout ( this . updateToolbarPosition . bind ( this ) , 0 ) ;
2011-01-30 09:44:01 +00:00
2011-04-26 17:43:00 +00:00
Zotero . updateQuickSearchBox ( document ) ;
2011-04-25 15:27:49 +00:00
2011-01-30 09:44:01 +00:00
if ( Zotero . isMac ) {
document . getElementById ( 'zotero-pane-stack' ) . setAttribute ( 'platform' , 'mac' ) ;
} else if ( Zotero . isWin ) {
document . getElementById ( 'zotero-pane-stack' ) . setAttribute ( 'platform' , 'win' ) ;
}
2016-04-08 21:03:29 +00:00
// Set the sync tooltip label
Components . utils . import ( "resource://zotero/config.js" ) ;
document . getElementById ( 'zotero-tb-sync-label' ) . value = Zotero . getString (
'sync.syncWith' , ZOTERO _CONFIG . DOMAIN _NAME
) ;
2011-06-14 00:36:21 +00:00
// register an observer for Zotero reload
observerService = Components . classes [ "@mozilla.org/observer-service;1" ]
. getService ( Components . interfaces . nsIObserverService ) ;
2011-07-03 04:33:37 +00:00
observerService . addObserver ( _reloadObserver , "zotero-reloaded" , false ) ;
2013-11-05 20:52:40 +00:00
observerService . addObserver ( _reloadObserver , "zotero-before-reload" , false ) ;
2011-06-14 00:36:21 +00:00
this . addReloadListener ( _loadPane ) ;
// continue loading pane
_loadPane ( ) ;
2017-07-07 07:20:06 +00:00
} ;
2011-06-14 00:36:21 +00:00
/ * *
2016-09-06 00:41:35 +00:00
* Called on window load or when pane has been reloaded after switching into or out of connector
2011-06-14 00:36:21 +00:00
* mode
* /
function _loadPane ( ) {
2018-08-17 06:18:35 +00:00
if ( ! Zotero || ! Zotero . initialized ) return ;
2011-06-14 00:36:21 +00:00
2016-10-04 07:12:20 +00:00
// Set flags for hi-res displays
Zotero . hiDPI = window . devicePixelRatio > 1 ;
Zotero . hiDPISuffix = Zotero . hiDPI ? "@2x" : "" ;
2020-09-15 07:30:17 +00:00
Zotero _Tabs . init ( ) ;
2014-03-07 07:21:39 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'pane.items.loading' ) ) ;
2011-06-14 00:36:21 +00:00
2016-10-14 13:21:48 +00:00
// Add a default progress window
2017-02-09 02:23:36 +00:00
ZoteroPane _Local . progressWindow = new Zotero . ProgressWindow ( { window } ) ;
2016-10-14 13:21:48 +00:00
2011-01-30 09:44:01 +00:00
//Initialize collections view
2011-06-14 00:36:21 +00:00
ZoteroPane _Local . collectionsView = new Zotero . CollectionTreeView ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Handle an error in setTree()/refresh()
ZoteroPane _Local . collectionsView . onError = function ( e ) {
2020-03-13 21:17:02 +00:00
Zotero . crash ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ;
2011-01-30 09:44:01 +00:00
var collectionsTree = document . getElementById ( 'zotero-collections-tree' ) ;
2011-06-14 00:36:21 +00:00
collectionsTree . view = ZoteroPane _Local . collectionsView ;
2011-01-30 09:44:01 +00:00
collectionsTree . controllers . appendController ( new Zotero . CollectionTreeCommandController ( collectionsTree ) ) ;
2012-12-11 20:16:40 +00:00
collectionsTree . addEventListener ( "mousedown" , ZoteroPane _Local . onTreeMouseDown , true ) ;
2011-03-08 23:46:01 +00:00
collectionsTree . addEventListener ( "click" , ZoteroPane _Local . onTreeClick , true ) ;
2011-01-30 09:44:01 +00:00
2016-09-06 00:41:35 +00:00
// Clear items view, so that the load registers as a new selected collection when switching
// between modes
ZoteroPane _Local . itemsView = null ;
2011-01-30 09:44:01 +00:00
var itemsTree = document . getElementById ( 'zotero-items-tree' ) ;
itemsTree . controllers . appendController ( new Zotero . ItemTreeCommandController ( itemsTree ) ) ;
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
itemsTree . addEventListener ( "mousedown" , ZoteroPane _Local . onTreeMouseDown , true ) ;
2011-03-08 23:46:01 +00:00
itemsTree . addEventListener ( "click" , ZoteroPane _Local . onTreeClick , true ) ;
2011-01-30 09:44:01 +00:00
Zotero . Keys . windowInit ( document ) ;
if ( Zotero . restoreFromServer ) {
Zotero . restoreFromServer = false ;
setTimeout ( function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var buttonFlags = ( ps . BUTTON _POS _0 ) * ( ps . BUTTON _TITLE _IS _STRING )
+ ( ps . BUTTON _POS _1 ) * ( ps . BUTTON _TITLE _CANCEL ) ;
var index = ps . confirmEx (
null ,
"Zotero Restore" ,
"The local Zotero database has been cleared."
+ " "
+ "Would you like to restore from the Zotero server now?" ,
buttonFlags ,
"Sync Now" ,
null , null , null , { }
) ;
if ( index == 0 ) {
Zotero . Sync . Server . sync ( {
onSuccess : function ( ) {
2015-07-20 21:27:55 +00:00
Zotero . Sync . Runner . updateIcons ( ) ;
2011-01-30 09:44:01 +00:00
ps . alert (
null ,
"Restore Completed" ,
"The local Zotero database has been successfully restored."
) ;
} ,
onError : function ( msg ) {
ps . alert (
null ,
"Restore Failed" ,
"An error occurred while restoring from the server:\n\n"
+ msg
) ;
Zotero . Sync . Runner . error ( msg ) ;
}
} ) ;
}
} , 1000 ) ;
}
// If the database was initialized or there are no sync credentials and
// Zotero hasn't been run before in this profile, display the start page
// -- this way the page won't be displayed when they sync their DB to
// another profile or if the DB is initialized erroneously (e.g. while
// switching data directory locations)
2011-07-02 16:52:34 +00:00
else if ( Zotero . Prefs . get ( 'firstRun2' ) ) {
2011-01-30 09:44:01 +00:00
if ( Zotero . Schema . dbInitialized || ! Zotero . Sync . Server . enabled ) {
setTimeout ( function ( ) {
2017-06-15 06:39:34 +00:00
ZoteroPane _Local . loadURI ( ZOTERO _CONFIG . START _URL ) ;
2011-01-30 09:44:01 +00:00
} , 400 ) ;
}
Zotero . Prefs . set ( 'firstRun2' , false ) ;
try {
Zotero . Prefs . clear ( 'firstRun' ) ;
}
catch ( e ) { }
}
2012-11-11 00:38:22 +00:00
if ( Zotero . openPane ) {
Zotero . openPane = false ;
setTimeout ( function ( ) {
ZoteroPane _Local . show ( ) ;
} , 0 ) ;
}
2018-06-16 07:07:46 +00:00
2019-06-07 05:13:42 +00:00
setTimeout ( function ( ) {
ZoteroPane . showRetractionBanner ( ) ;
} ) ;
2018-06-16 07:07:46 +00:00
// TEMP: Clean up extra files from Mendeley imports <5.0.51
setTimeout ( async function ( ) {
var needsCleanup = await Zotero . DB . valueQueryAsync (
"SELECT COUNT(*) FROM settings WHERE setting='mImport' AND key='cleanup'"
)
if ( ! needsCleanup ) return ;
Components . utils . import ( "chrome://zotero/content/import/mendeley/mendeleyImport.js" ) ;
var importer = new Zotero _Import _Mendeley ( ) ;
importer . deleteNonPrimaryFiles ( ) ;
} , 10000 )
2011-01-30 09:44:01 +00:00
}
2019-03-17 09:05:04 +00:00
this . initContainers = function ( ) {
this . initTagSelector ( ) ;
} ;
this . uninitContainers = function ( ) {
this . tagSelector . uninit ( ) ;
} ;
2011-06-01 04:22:45 +00:00
/ *
* Create the New Item ( + ) submenu with each item type
* /
this . buildItemTypeSubMenu = function ( ) {
2011-01-30 09:44:01 +00:00
var moreMenu = document . getElementById ( 'zotero-tb-add-more' ) ;
2012-08-02 20:59:28 +00:00
while ( moreMenu . hasChildNodes ( ) ) {
moreMenu . removeChild ( moreMenu . firstChild ) ;
}
2011-01-30 09:44:01 +00:00
// Sort by localized name
2011-06-01 04:22:45 +00:00
var t = Zotero . ItemTypes . getSecondaryTypes ( ) ;
2011-01-30 09:44:01 +00:00
var itemTypes = [ ] ;
for ( var i = 0 ; i < t . length ; i ++ ) {
itemTypes . push ( {
id : t [ i ] . id ,
name : t [ i ] . name ,
localized : Zotero . ItemTypes . getLocalizedString ( t [ i ] . id )
} ) ;
}
var collation = Zotero . getLocaleCollation ( ) ;
itemTypes . sort ( function ( a , b ) {
return collation . compareString ( 1 , a . localized , b . localized ) ;
} ) ;
for ( var i = 0 ; i < itemTypes . length ; i ++ ) {
var menuitem = document . createElement ( "menuitem" ) ;
menuitem . setAttribute ( "label" , itemTypes [ i ] . localized ) ;
menuitem . setAttribute ( "tooltiptext" , "" ) ;
2012-02-06 07:38:53 +00:00
let type = itemTypes [ i ] . id ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
menuitem . addEventListener ( "command" , function ( ) { ZoteroPane _Local . newItem ( type , { } , null , true ) . done ( ) ; } , false ) ;
2011-06-01 04:22:45 +00:00
moreMenu . appendChild ( menuitem ) ;
2011-01-30 09:44:01 +00:00
}
2011-06-01 04:22:45 +00:00
}
this . updateNewItemTypes = function ( ) {
var addMenu = document . getElementById ( 'zotero-tb-add' ) . firstChild ;
2011-01-30 09:44:01 +00:00
2011-06-01 04:22:45 +00:00
// Remove all nodes so we can regenerate
var options = addMenu . getElementsByAttribute ( "class" , "zotero-tb-add" ) ;
while ( options . length ) {
var p = options [ 0 ] . parentNode ;
p . removeChild ( options [ 0 ] ) ;
}
2011-01-30 09:44:01 +00:00
2011-06-01 04:22:45 +00:00
var separator = addMenu . firstChild ;
2011-01-30 09:44:01 +00:00
// Sort by localized name
2011-06-01 04:22:45 +00:00
var t = Zotero . ItemTypes . getPrimaryTypes ( ) ;
2011-01-30 09:44:01 +00:00
var itemTypes = [ ] ;
for ( var i = 0 ; i < t . length ; i ++ ) {
itemTypes . push ( {
id : t [ i ] . id ,
name : t [ i ] . name ,
localized : Zotero . ItemTypes . getLocalizedString ( t [ i ] . id )
} ) ;
}
var collation = Zotero . getLocaleCollation ( ) ;
itemTypes . sort ( function ( a , b ) {
return collation . compareString ( 1 , a . localized , b . localized ) ;
} ) ;
for ( var i = 0 ; i < itemTypes . length ; i ++ ) {
var menuitem = document . createElement ( "menuitem" ) ;
menuitem . setAttribute ( "label" , itemTypes [ i ] . localized ) ;
menuitem . setAttribute ( "tooltiptext" , "" ) ;
2012-02-06 07:38:53 +00:00
let type = itemTypes [ i ] . id ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
menuitem . addEventListener ( "command" , function ( ) { ZoteroPane _Local . newItem ( type , { } , null , true ) . done ( ) ; } , false ) ;
2011-01-30 09:44:01 +00:00
menuitem . className = "zotero-tb-add" ;
2011-06-01 04:22:45 +00:00
addMenu . insertBefore ( menuitem , separator ) ;
2011-01-30 09:44:01 +00:00
}
}
2011-06-01 04:22:45 +00:00
2011-01-30 09:44:01 +00:00
/ *
* Called when the window closes
* /
function destroy ( )
{
if ( ! Zotero || ! Zotero . initialized || ! _loaded ) {
return ;
}
2019-08-26 04:34:06 +00:00
this . serializePersist ( ) ;
2019-03-17 23:15:34 +00:00
this . uninitContainers ( ) ;
2011-01-30 09:44:01 +00:00
2011-08-24 22:08:27 +00:00
if ( this . collectionsView ) this . collectionsView . unregister ( ) ;
if ( this . itemsView ) this . itemsView . unregister ( ) ;
2011-06-14 00:36:21 +00:00
2011-08-24 22:08:27 +00:00
observerService . removeObserver ( _reloadObserver , "zotero-reloaded" ) ;
2021-03-17 15:53:16 +00:00
Zotero _Tabs . closeAll ( ) ;
2011-01-30 09:44:01 +00:00
}
/ * *
* Called before Zotero pane is to be made visible
* @ return { Boolean } True if Zotero pane should be loaded , false otherwise ( if an error
* occurred )
* /
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . makeVisible = Zotero . Promise . coroutine ( function * ( ) {
2013-08-12 00:51:16 +00:00
if ( Zotero . locked ) {
Zotero . showZoteroPaneProgressMeter ( ) ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield Zotero . unlockPromise ;
2016-10-08 22:59:20 +00:00
// The items pane is hidden initially to avoid showing column lines
document . getElementById ( 'zotero-items-tree' ) . hidden = false ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
Zotero . hideZoteroPaneOverlays ( ) ;
// If pane not loaded, load it or display an error message
if ( ! ZoteroPane _Local . loaded ) {
ZoteroPane _Local . init ( ) ;
}
// If Zotero could not be initialized, display an error message and return
2020-03-13 21:17:02 +00:00
if ( ! Zotero || Zotero . skipLoading || Zotero . crashed ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . displayStartupError ( ) ;
return false ;
}
if ( ! _madeVisible ) {
this . buildItemTypeSubMenu ( ) ;
}
_madeVisible = true ;
2016-04-04 10:33:15 +00:00
this . unserializePersist ( ) ;
2016-05-28 00:57:29 +00:00
this . updateLayout ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . updateToolbarPosition ( ) ;
2019-03-17 09:05:04 +00:00
this . initContainers ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// restore saved row selection (for tab switching)
2016-12-21 10:01:50 +00:00
// TODO: Remove now that no tab mode?
var containerWindow = window ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( containerWindow . zoteroSavedCollectionSelection ) {
2017-03-24 09:18:55 +00:00
this . collectionsView . onLoad . addListener ( Zotero . Promise . coroutine ( function * ( ) {
2016-02-08 06:37:48 +00:00
yield this . collectionsView . selectByID ( containerWindow . zoteroSavedCollectionSelection ) ;
if ( containerWindow . zoteroSavedItemSelection ) {
2017-03-24 09:18:55 +00:00
this . itemsView . onLoad . addListener ( function ( ) {
2016-02-08 06:37:48 +00:00
this . itemsView . rememberSelection ( containerWindow . zoteroSavedItemSelection ) ;
delete containerWindow . zoteroSavedItemSelection ;
} . bind ( this ) ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
2016-02-08 06:37:48 +00:00
delete containerWindow . zoteroSavedCollectionSelection ;
} . bind ( this ) ) ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
// Focus the quicksearch on pane open
var searchBar = document . getElementById ( 'zotero-tb-search' ) ;
setTimeout ( function ( ) {
searchBar . inputField . select ( ) ;
} , 1 ) ;
2017-11-18 03:36:50 +00:00
//
// TEMP: Remove after people are no longer upgrading from Zotero for Firefox
//
var showFxProfileWarning = false ;
var pref = 'firstRun.skipFirefoxProfileAccessCheck' ;
if ( Zotero . fxProfileAccessError != undefined && Zotero . fxProfileAccessError ) {
showFxProfileWarning = true ;
}
else if ( ! Zotero . Prefs . get ( pref ) ) {
showFxProfileWarning = ! ( yield Zotero . Profile . checkFirefoxProfileAccess ( ) ) ;
}
if ( showFxProfileWarning ) {
2017-11-17 14:29:00 +00:00
Zotero . uiReadyPromise . delay ( 2000 ) . then ( function ( ) {
var ps = Services . prompt ;
var buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _IS _STRING ;
2017-11-18 03:36:50 +00:00
var text = "Zotero was unable to access your Firefox profile to check for "
+ "existing Zotero data.\n\n"
+ "If you’ ve upgraded from Zotero 4.0 for Firefox and don’ t see the data "
2017-11-17 14:29:00 +00:00
+ "you expect, it may be located elsewhere on your computer. "
+ "Click “More Information” for help restoring your previous data.\n\n"
+ "If you’ re new to Zotero, you can ignore this message." ;
var url = 'https://www.zotero.org/support/kb/data_missing_after_zotero_5_upgrade' ;
2017-11-18 03:36:50 +00:00
var dontShowAgain = { } ;
2017-11-17 14:29:00 +00:00
let index = ps . confirmEx ( null ,
Zotero . getString ( 'general.warning' ) ,
text ,
buttonFlags ,
Zotero . getString ( 'general.moreInformation' ) ,
"Ignore" ,
2017-11-18 03:36:50 +00:00
null ,
Zotero . getString ( 'general.dontShowAgain' ) ,
dontShowAgain
2017-11-17 14:29:00 +00:00
) ;
2017-11-18 03:36:50 +00:00
if ( dontShowAgain . value ) {
Zotero . Prefs . set ( pref , true )
}
2017-11-17 14:29:00 +00:00
if ( index == 0 ) {
this . loadURI ( url ) ;
}
} . bind ( this ) ) ;
}
2017-11-18 03:36:50 +00:00
// Once we successfully find it once, don't bother checking again
else {
Zotero . Prefs . set ( pref , true ) ;
}
2017-11-17 14:29:00 +00:00
2018-08-09 10:11:33 +00:00
if ( Zotero . proxyFailure ) {
try {
Zotero . Sync . Runner . updateIcons ( Zotero . proxyFailure ) ;
}
catch ( e ) {
Zotero . logError ( e ) ;
}
}
2016-06-27 16:40:38 +00:00
// Auto-sync on pane open or if new account
if ( Zotero . Prefs . get ( 'sync.autoSync' ) || Zotero . initAutoSync ) {
2016-12-22 11:58:24 +00:00
yield Zotero . proxyAuthComplete ;
yield Zotero . uiReadyPromise ;
2013-08-12 00:51:16 +00:00
2016-04-01 06:24:50 +00:00
if ( ! Zotero . Sync . Runner . enabled ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
Zotero . debug ( 'Sync not enabled -- skipping auto-sync' , 4 ) ;
2013-08-12 00:51:16 +00:00
}
2016-04-01 06:24:50 +00:00
else if ( Zotero . Sync . Runner . syncInProgress ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
Zotero . debug ( 'Sync already running -- skipping auto-sync' , 4 ) ;
2013-08-12 00:51:16 +00:00
}
2016-04-01 06:24:50 +00:00
else if ( Zotero . Sync . Server . manualSyncRequired ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
Zotero . debug ( 'Manual sync required -- skipping auto-sync' , 4 ) ;
2013-08-12 00:51:16 +00:00
}
2017-11-18 03:36:50 +00:00
else if ( showFxProfileWarning ) {
2017-11-17 14:29:00 +00:00
Zotero . debug ( 'Firefox profile access error -- skipping initial auto-sync' , 4 ) ;
}
2016-04-01 06:24:50 +00:00
else {
Zotero . Sync . Runner . sync ( {
background : true
2016-06-27 16:40:38 +00:00
} ) . then ( ( ) => Zotero . initAutoSync = false ) ;
2016-04-01 06:24:50 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
2016-04-01 06:24:50 +00:00
// Set sync icon to spinning if there's an existing sync
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
//
2016-04-01 06:24:50 +00:00
// We don't bother setting an existing error state at open
if ( Zotero . Sync . Runner . syncInProgress ) {
2015-07-20 21:27:55 +00:00
Zotero . Sync . Runner . updateIcons ( 'animate' ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
return true ;
} ) ;
2011-01-30 09:44:01 +00:00
function isFullScreen ( ) {
return document . getElementById ( 'zotero-pane-stack' ) . getAttribute ( 'fullscreenmode' ) == 'true' ;
}
/ *
* Trigger actions based on keyboard shortcuts
* /
function handleKeyDown ( event , from ) {
2020-09-24 14:47:47 +00:00
// Close current tab
if ( event . key == 'w' ) {
let close = Zotero . isMac
? ( event . metaKey && ! event . shiftKey && ! event . ctrlKey && ! event . altKey )
: ( event . ctrlKey && ! event . shiftKey && ! event . altKey ) ;
if ( close ) {
if ( Zotero _Tabs . selectedIndex > 0 ) {
Zotero _Tabs . close ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
}
return ;
}
}
2021-06-28 11:07:49 +00:00
2021-07-11 00:29:42 +00:00
// Tab navigation: Ctrl-PageUp / PageDown
2021-06-28 11:07:49 +00:00
// TODO: Select across tabs without selecting with Ctrl-Shift, as in Firefox?
2021-07-11 00:29:42 +00:00
if ( event . ctrlKey && ! event . metaKey && ! event . shiftKey && ! event . altKey ) {
2021-06-28 11:07:49 +00:00
if ( event . key == 'PageUp' ) {
Zotero _Tabs . selectPrev ( ) ;
event . preventDefault ( ) ;
2021-07-11 00:32:12 +00:00
event . stopPropagation ( ) ;
2021-06-28 11:07:49 +00:00
return ;
}
else if ( event . key == 'PageDown' ) {
Zotero _Tabs . selectNext ( ) ;
event . preventDefault ( ) ;
2021-07-11 00:32:12 +00:00
event . stopPropagation ( ) ;
2021-06-28 11:07:49 +00:00
return ;
}
}
2021-07-11 00:41:13 +00:00
// Tab navigation: Cmd-Shift-[ / ]
// Common shortcut on macOS, but typically only supported on that platform to match OS
// conventions users expect from other macOS apps.
if ( Zotero . isMac ) {
if ( event . metaKey && event . shiftKey && ! event . altKey && ! event . ctrlKey ) {
if ( event . key == '[' ) {
Zotero _Tabs . selectPrev ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return ;
}
else if ( event . key == ']' ) {
Zotero _Tabs . selectNext ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return ;
}
}
}
2011-01-30 09:44:01 +00:00
try {
// Ignore keystrokes outside of Zotero pane
if ( ! ( event . originalTarget . ownerDocument instanceof XULDocument ) ) {
return ;
}
}
catch ( e ) {
Zotero . debug ( e ) ;
}
if ( Zotero . locked ) {
event . preventDefault ( ) ;
return ;
}
2021-06-28 11:07:49 +00:00
if ( from == 'zotero-pane' ) {
2011-01-30 09:44:01 +00:00
// Highlight collections containing selected items
//
// We use Control (17) on Windows because Alt triggers the menubar;
// otherwise we use Alt/Option (18)
if ( ( Zotero . isWin && event . keyCode == 17 && ! event . altKey ) ||
( ! Zotero . isWin && event . keyCode == 18 && ! event . ctrlKey )
&& ! event . shiftKey && ! event . metaKey ) {
this . highlightTimer = Components . classes [ "@mozilla.org/timer;1" ] .
createInstance ( Components . interfaces . nsITimer ) ;
// {} implements nsITimerCallback
this . highlightTimer . initWithCallback ( {
2011-03-08 23:46:01 +00:00
notify : ZoteroPane _Local . setHighlightedRowsCallback
2011-01-30 09:44:01 +00:00
} , 225 , Components . interfaces . nsITimer . TYPE _ONE _SHOT ) ;
}
2011-10-12 18:41:23 +00:00
// Unhighlight on key up
2011-01-30 09:44:01 +00:00
else if ( ( Zotero . isWin && event . ctrlKey ) ||
( ! Zotero . isWin && event . altKey ) ) {
if ( this . highlightTimer ) {
this . highlightTimer . cancel ( ) ;
this . highlightTimer = null ;
}
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . collectionsView . setHighlightedRows ( ) ;
2011-01-30 09:44:01 +00:00
}
}
}
2014-12-15 05:07:37 +00:00
function handleKeyUp ( event ) {
var from = event . originalTarget . id ;
if ( from == 'zotero-items-tree' ) {
2011-01-30 09:44:01 +00:00
if ( ( Zotero . isWin && event . keyCode == 17 ) ||
( ! Zotero . isWin && event . keyCode == 18 ) ) {
if ( this . highlightTimer ) {
this . highlightTimer . cancel ( ) ;
this . highlightTimer = null ;
}
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . collectionsView . setHighlightedRows ( ) ;
2014-12-15 05:07:37 +00:00
return ;
2011-01-30 09:44:01 +00:00
}
}
}
/ *
* Highlights collections containing selected items on Ctrl ( Win ) or
* Option / Alt ( Mac / Linux ) press
* /
function setHighlightedRowsCallback ( ) {
2011-03-08 23:46:01 +00:00
var itemIDs = ZoteroPane _Local . getSelectedItems ( true ) ;
2017-04-12 04:56:37 +00:00
// If no items or an unreasonable number, don't try
if ( ! itemIDs || ! itemIDs . length || itemIDs . length > 100 ) return ;
Zotero . Promise . coroutine ( function * ( ) {
var collectionIDs = yield Zotero . Collections . getCollectionsContainingItems ( itemIDs , true ) ;
var ids = collectionIDs . map ( id => "C" + id ) ;
var userLibraryID = Zotero . Libraries . userLibraryID ;
var allInPublications = Zotero . Items . get ( itemIDs ) . every ( ( item ) => {
return item . libraryID == userLibraryID && item . inPublications ;
} )
if ( allInPublications ) {
ids . push ( "P" + Zotero . Libraries . userLibraryID ) ;
}
if ( ids . length ) {
ZoteroPane _Local . collectionsView . setHighlightedRows ( ids ) ;
}
} ) ( ) ;
2011-01-30 09:44:01 +00:00
}
2013-07-02 06:43:53 +00:00
function handleKeyPress ( event ) {
var from = event . originalTarget . id ;
// Ignore keystrokes if Zotero pane is closed
var zoteroPane = document . getElementById ( 'zotero-pane-stack' ) ;
if ( zoteroPane . getAttribute ( 'hidden' ) == 'true' ||
zoteroPane . getAttribute ( 'collapsed' ) == 'true' ) {
return ;
}
if ( Zotero . locked ) {
event . preventDefault ( ) ;
return ;
}
2019-10-25 19:18:28 +00:00
var command = Zotero . Keys . getCommand ( event . key ) ;
2013-07-02 06:43:53 +00:00
2011-01-30 09:44:01 +00:00
if ( from == 'zotero-collections-tree' ) {
if ( ( event . keyCode == event . DOM _VK _BACK _SPACE && Zotero . isMac ) ||
event . keyCode == event . DOM _VK _DELETE ) {
2013-03-17 02:55:50 +00:00
var deleteItems = event . metaKey || ( ! Zotero . isMac && event . shiftKey ) ;
ZoteroPane _Local . deleteSelectedCollection ( deleteItems ) ;
2011-01-30 09:44:01 +00:00
event . preventDefault ( ) ;
return ;
}
}
else if ( from == 'zotero-items-tree' ) {
2017-01-12 07:38:32 +00:00
// Focus TinyMCE explicitly on tab key, since the normal focusing doesn't work right
if ( ! event . shiftKey && event . keyCode == event . DOM _VK _TAB ) {
2013-07-02 06:43:53 +00:00
var deck = document . getElementById ( 'zotero-item-pane-content' ) ;
if ( deck . selectedPanel . id == 'zotero-view-note' ) {
2017-01-12 07:38:32 +00:00
document . getElementById ( 'zotero-note-editor' ) . focus ( ) ;
event . preventDefault ( ) ;
return ;
2013-07-02 06:43:53 +00:00
}
}
else if ( ( event . keyCode == event . DOM _VK _BACK _SPACE && Zotero . isMac ) ||
2011-01-30 09:44:01 +00:00
event . keyCode == event . DOM _VK _DELETE ) {
2014-10-28 17:45:55 +00:00
// If Cmd/Shift delete, use forced mode, which does different
2011-01-30 09:44:01 +00:00
// things depending on the context
2013-03-17 02:55:50 +00:00
var force = event . metaKey || ( ! Zotero . isMac && event . shiftKey ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . deleteSelectedItems ( force ) ;
2011-01-30 09:44:01 +00:00
event . preventDefault ( ) ;
return ;
}
2012-11-01 05:53:31 +00:00
else if ( event . keyCode == event . DOM _VK _RETURN ) {
var items = this . itemsView . getSelectedItems ( ) ;
// Don't do anything if more than 20 items selected
if ( ! items . length || items . length > 20 ) {
return ;
}
ZoteroPane _Local . viewItems ( items , event ) ;
// These don't seem to do anything. Instead we override
// the tree binding's _handleEnter method in itemTreeView.js.
//event.preventDefault();
//event.stopPropagation();
return ;
}
2016-02-11 10:37:20 +00:00
else if ( command == 'toggleRead' ) {
// Toggle read/unread
let row = this . collectionsView . getRow ( this . collectionsView . selection . currentIndex ) ;
if ( ! row || ! row . isFeed ( ) ) return ;
2016-03-25 04:49:14 +00:00
this . toggleSelectedItemsRead ( ) ;
2017-11-03 08:36:42 +00:00
if ( itemReadPromise ) {
itemReadPromise . cancel ( ) ;
itemReadPromise = null ;
}
return ;
2016-02-11 10:37:20 +00:00
}
2011-01-30 09:44:01 +00:00
}
2013-07-02 06:43:53 +00:00
2016-02-11 10:37:20 +00:00
// Ignore modifiers other than Ctrl-Shift/Cmd-Shift
if ( ! ( ( Zotero . isMac ? event . metaKey : event . ctrlKey ) && event . shiftKey ) ) {
2013-07-02 06:43:53 +00:00
return ;
}
if ( ! command ) {
return ;
}
2016-03-25 04:49:14 +00:00
Zotero . debug ( 'Keyboard shortcut: ' + command ) ;
2013-07-02 06:43:53 +00:00
// Errors don't seem to make it out otherwise
try {
switch ( command ) {
case 'library' :
document . getElementById ( 'zotero-collections-tree' ) . focus ( ) ;
break ;
case 'quicksearch' :
document . getElementById ( 'zotero-tb-search' ) . select ( ) ;
break ;
case 'newItem' :
2019-10-25 19:21:56 +00:00
( async function ( ) {
// Default to most recent item type from here or the New Type menu,
// or fall back to 'book'
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var mru = Zotero . Prefs . get ( 'newItemTypeMRU' ) ;
2019-10-25 19:21:56 +00:00
var type = mru ? mru . split ( ',' ) [ 0 ] : 'book' ;
await ZoteroPane . newItem ( Zotero . ItemTypes . getID ( type ) ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let itemBox = document . getElementById ( 'zotero-editpane-item-box' ) ;
var menu = itemBox . itemTypeMenu ;
2019-10-25 19:21:56 +00:00
// If the new item's type is changed immediately, update the MRU
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var handleTypeChange = function ( ) {
2019-10-25 19:21:56 +00:00
this . addItemTypeToNewItemTypeMRU ( Zotero . ItemTypes . getName ( menu . value ) ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
itemBox . removeHandler ( 'itemtypechange' , handleTypeChange ) ;
2019-10-25 19:21:56 +00:00
} . bind ( this ) ;
// Don't update the MRU on subsequent opens of the item type menu
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var removeTypeChangeHandler = function ( ) {
itemBox . removeHandler ( 'itemtypechange' , handleTypeChange ) ;
itemBox . itemTypeMenu . firstChild . removeEventListener ( 'popuphiding' , removeTypeChangeHandler ) ;
// Focus the title field after menu closes
itemBox . focusFirstField ( ) ;
} ;
itemBox . addHandler ( 'itemtypechange' , handleTypeChange ) ;
itemBox . itemTypeMenu . firstChild . addEventListener ( 'popuphiding' , removeTypeChangeHandler ) ;
menu . focus ( ) ;
document . getElementById ( 'zotero-editpane-item-box' ) . itemTypeMenu . menupopup . openPopup ( menu , "before_start" , 0 , 0 ) ;
2019-10-25 19:21:56 +00:00
} . bind ( this ) ( ) ) ;
2013-07-02 06:43:53 +00:00
break ;
case 'newNote' :
// If a regular item is selected, use that as the parent.
// If a child item is selected, use its parent as the parent.
// Otherwise create a standalone note.
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var parentKey = false ;
2013-07-02 06:43:53 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
if ( items . length == 1 ) {
if ( items [ 0 ] . isRegularItem ( ) ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
parentKey = items [ 0 ] . key ;
2013-07-02 06:43:53 +00:00
}
else {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
parentKey = items [ 0 ] . parentItemKey ;
2013-07-02 06:43:53 +00:00
}
}
// Use key that's not the modifier as the popup toggle
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
ZoteroPane _Local . newNote ( event . altKey , parentKey ) ;
2013-07-02 06:43:53 +00:00
break ;
case 'toggleTagSelector' :
ZoteroPane _Local . toggleTagSelector ( ) ;
break ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
case 'sync' :
Zotero . Sync . Runner . sync ( ) ;
break ;
2016-03-25 04:49:14 +00:00
case 'saveToZotero' :
var collectionTreeRow = this . collectionsView . selectedTreeRow ;
if ( collectionTreeRow . isFeed ( ) ) {
ZoteroItemPane . translateSelectedItems ( ) ;
} else {
Zotero . debug ( command + ' does not do anything in non-feed views' )
}
break ;
case 'toggleAllRead' :
var collectionTreeRow = this . collectionsView . selectedTreeRow ;
if ( collectionTreeRow . isFeed ( ) ) {
this . markFeedRead ( ) ;
}
break ;
2017-07-27 06:29:50 +00:00
// Handled by <key>s in standalone.js, pointing to <command>s in zoteroPane.xul,
// which are enabled or disabled by this.updateQuickCopyCommands(), called by
// this.itemSelected()
case 'copySelectedItemCitationsToClipboard' :
case 'copySelectedItemsToClipboard' :
return ;
2013-07-02 06:43:53 +00:00
default :
throw ( 'Command "' + command + '" not found in ZoteroPane_Local.handleKeyDown()' ) ;
}
}
catch ( e ) {
Zotero . debug ( e , 1 ) ;
Components . utils . reportError ( e ) ;
}
event . preventDefault ( ) ;
2011-01-30 09:44:01 +00:00
}
/ *
* Create a new item
*
* _data _ is an optional object with field : value for itemData
* /
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . newItem = Zotero . Promise . coroutine ( function * ( typeID , data , row , manual )
2011-01-30 09:44:01 +00:00
{
2012-03-17 07:12:49 +00:00
if ( ( row === undefined || row === null ) && this . collectionsView . selection ) {
2011-01-30 09:44:01 +00:00
row = this . collectionsView . selection . currentIndex ;
2011-08-28 22:15:39 +00:00
2012-03-17 07:12:49 +00:00
// Make sure currently selected view is editable
2011-08-28 22:15:39 +00:00
if ( ! this . canEdit ( row ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
}
2015-05-04 06:00:52 +00:00
yield ZoteroItemPane . blurOpenField ( ) ;
2012-02-20 08:31:22 +00:00
if ( row !== undefined && row !== null ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . getRow ( row ) ;
var libraryID = collectionTreeRow . ref . libraryID ;
2011-01-30 09:44:01 +00:00
}
else {
2015-03-10 06:27:56 +00:00
var libraryID = Zotero . Libraries . userLibraryID ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = null ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let itemID ;
2014-08-09 22:01:28 +00:00
yield Zotero . DB . executeTransaction ( function * ( ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var item = new Zotero . Item ( typeID ) ;
item . libraryID = libraryID ;
for ( var i in data ) {
item . setField ( i , data [ i ] ) ;
}
itemID = yield item . save ( ) ;
if ( collectionTreeRow && collectionTreeRow . isCollection ( ) ) {
2014-08-09 22:01:28 +00:00
yield collectionTreeRow . ref . addItem ( itemID ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
} ) ;
2011-06-01 14:28:59 +00:00
2011-01-30 09:44:01 +00:00
//set to Info tab
document . getElementById ( 'zotero-view-item' ) . selectedIndex = 0 ;
2012-02-20 08:31:22 +00:00
if ( manual ) {
2013-08-07 17:17:25 +00:00
// Update most-recently-used list for New Item menu
2019-10-25 19:21:56 +00:00
this . addItemTypeToNewItemTypeMRU ( Zotero . ItemTypes . getName ( typeID ) ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Focus the title field
document . getElementById ( 'zotero-editpane-item-box' ) . focusFirstField ( ) ;
2011-06-01 04:22:45 +00:00
}
2015-05-03 07:17:53 +00:00
return Zotero . Items . getAsync ( itemID ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2019-10-25 19:21:56 +00:00
this . addItemTypeToNewItemTypeMRU = function ( itemType ) {
2013-07-02 20:48:53 +00:00
var mru = Zotero . Prefs . get ( 'newItemTypeMRU' ) ;
if ( mru ) {
var mru = mru . split ( ',' ) ;
2019-10-25 19:21:56 +00:00
var pos = mru . indexOf ( itemType ) ;
2013-07-02 20:48:53 +00:00
if ( pos != - 1 ) {
mru . splice ( pos , 1 ) ;
}
2019-10-25 19:21:56 +00:00
mru . unshift ( itemType ) ;
2013-07-02 20:48:53 +00:00
}
else {
2019-10-25 19:21:56 +00:00
var mru = [ itemType ] ;
2013-07-02 20:48:53 +00:00
}
Zotero . Prefs . set ( 'newItemTypeMRU' , mru . slice ( 0 , 5 ) . join ( ',' ) ) ;
}
2014-08-09 22:01:28 +00:00
this . newCollection = Zotero . Promise . coroutine ( function * ( parentKey ) {
2012-10-31 09:22:58 +00:00
if ( ! this . canEditLibrary ( ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var libraryID = this . getSelectedLibraryID ( ) ;
2018-12-27 12:11:15 +00:00
// Get a unique "Untitled" name for this level in the collection hierarchy
var collections ;
if ( parentKey ) {
let parent = Zotero . Collections . getIDFromLibraryAndKey ( libraryID , parentKey ) ;
collections = Zotero . Collections . getByParent ( parent ) ;
}
else {
collections = Zotero . Collections . getByLibrary ( libraryID ) ;
}
var prefix = Zotero . getString ( 'pane.collections.untitled' ) ;
var name = Zotero . Utilities . Internal . getNextName (
prefix ,
collections . map ( c => c . name ) . filter ( n => n . startsWith ( prefix ) )
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
) ;
2011-01-30 09:44:01 +00:00
2018-12-27 12:11:15 +00:00
var newName = { value : name } ;
var result = Services . prompt . prompt ( window ,
2011-01-30 09:44:01 +00:00
Zotero . getString ( 'pane.collections.newCollection' ) ,
Zotero . getString ( 'pane.collections.name' ) , newName , "" , { } ) ;
if ( ! result )
{
return ;
}
if ( ! newName . value )
{
newName . value = untitled ;
}
var collection = new Zotero . Collection ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
collection . libraryID = libraryID ;
2011-01-30 09:44:01 +00:00
collection . name = newName . value ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
collection . parentKey = parentKey ;
2015-05-10 08:20:47 +00:00
return collection . saveTx ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2019-08-24 08:25:51 +00:00
this . importFeedsFromOPML = async function ( event ) {
2016-04-20 14:09:31 +00:00
while ( true ) {
2019-08-24 08:25:51 +00:00
let fp = new FilePicker ( ) ;
fp . init ( window , Zotero . getString ( 'fileInterface.importOPML' ) , fp . modeOpen ) ;
2016-04-20 14:09:31 +00:00
fp . appendFilter ( Zotero . getString ( 'fileInterface.OPMLFeedFilter' ) , '*.opml; *.xml' ) ;
2019-08-24 08:25:51 +00:00
fp . appendFilters ( fp . filterAll ) ;
if ( await fp . show ( ) == fp . returnOK ) {
2020-03-10 02:46:03 +00:00
var contents = await Zotero . File . getContentsAsync ( fp . file ) ;
2019-08-24 08:25:51 +00:00
var success = await Zotero . Feeds . importFromOPML ( contents ) ;
2016-04-20 14:09:31 +00:00
if ( success ) {
return true ;
}
// Try again
Zotero . alert ( window , Zotero . getString ( 'general.error' ) , Zotero . getString ( 'fileInterface.unsupportedFormat' ) ) ;
} else {
return false ;
}
}
2019-08-24 08:25:51 +00:00
} ;
2016-04-20 14:09:31 +00:00
2016-04-01 11:28:01 +00:00
this . newFeedFromURL = Zotero . Promise . coroutine ( function * ( ) {
2014-11-07 04:12:12 +00:00
let data = { } ;
window . openDialog ( 'chrome://zotero/content/feedSettings.xul' ,
null , 'centerscreen, modal' , data ) ;
if ( ! data . cancelled ) {
let feed = new Zotero . Feed ( ) ;
feed . url = data . url ;
feed . name = data . title ;
feed . refreshInterval = data . ttl ;
2016-12-13 14:07:43 +00:00
feed . cleanupReadAfter = data . cleanupReadAfter ;
feed . cleanupUnreadAfter = data . cleanupUnreadAfter ;
2016-01-13 13:13:29 +00:00
yield feed . saveTx ( ) ;
2015-02-03 17:57:32 +00:00
yield feed . updateFeed ( ) ;
2014-11-07 04:12:12 +00:00
}
2015-02-03 17:56:27 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
this . newGroup = function ( ) {
this . loadURI ( Zotero . Groups . addGroupURL ) ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . newSearch = Zotero . Promise . coroutine ( function * ( ) {
2017-01-14 23:01:51 +00:00
if ( Zotero . DB . inTransaction ( ) ) {
yield Zotero . DB . waitForTransaction ( ) ;
}
2011-01-30 09:44:01 +00:00
2018-12-27 12:11:15 +00:00
var libraryID = this . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
var s = new Zotero . Search ( ) ;
2018-12-27 12:11:15 +00:00
s . libraryID = libraryID ;
2015-04-16 18:02:36 +00:00
s . addCondition ( 'title' , 'contains' , '' ) ;
2011-01-30 09:44:01 +00:00
2018-12-27 12:11:15 +00:00
var searches = yield Zotero . Searches . getAll ( libraryID )
var prefix = Zotero . getString ( 'pane.collections.untitled' ) ;
var name = Zotero . Utilities . Internal . getNextName (
prefix ,
searches . map ( s => s . name ) . filter ( n => n . startsWith ( prefix ) )
2016-12-14 08:37:56 +00:00
) ;
2018-12-27 12:11:15 +00:00
var io = { dataIn : { search : s , name } , dataOut : null } ;
2011-01-30 09:44:01 +00:00
window . openDialog ( 'chrome://zotero/content/searchDialog.xul' , '' , 'chrome,modal' , io ) ;
2016-09-24 01:02:36 +00:00
if ( ! io . dataOut ) {
return false ;
}
s . fromJSON ( io . dataOut . json ) ;
yield s . saveTx ( ) ;
return s . id ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
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
2019-06-10 06:37:54 +00:00
this . setVirtual = Zotero . Promise . coroutine ( function * ( libraryID , type , show , select ) {
2016-07-01 09:48:19 +00:00
switch ( type ) {
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
case 'duplicates' :
2016-07-01 09:48:19 +00:00
var treeViewID = 'D' + libraryID ;
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
break ;
case 'unfiled' :
2016-07-01 09:48:19 +00:00
var treeViewID = 'U' + libraryID ;
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
break ;
2019-06-10 06:37:54 +00:00
case 'retracted' :
var treeViewID = 'R' + libraryID ;
break ;
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
default :
2016-07-01 09:48:19 +00:00
throw new Error ( "Invalid virtual collection type '" + type + "'" ) ;
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
}
2016-07-01 09:48:19 +00:00
Zotero . Utilities . Internal . setVirtualCollectionStateForLibrary ( libraryID , type , show ) ;
2011-02-14 03:59:32 +00:00
2016-07-01 09:48:19 +00:00
var cv = this . collectionsView ;
2011-02-14 03:59:32 +00:00
2017-03-24 09:18:55 +00:00
var promise = cv . waitForSelect ( ) ;
2019-06-10 06:37:54 +00:00
var selectedRowID = cv . selectedTreeRow . id ;
2016-07-01 09:48:19 +00:00
var selectedRow = cv . selection . currentIndex ;
2011-02-14 03:59:32 +00:00
2016-07-01 09:48:19 +00:00
yield cv . refresh ( ) ;
2011-02-14 03:59:32 +00:00
2019-06-10 06:37:54 +00:00
// Select new or original row
2011-07-25 21:27:32 +00:00
if ( show ) {
2019-06-10 06:37:54 +00:00
yield this . collectionsView . selectByID ( select ? treeViewID : selectedRowID ) ;
}
else if ( type == 'retracted' ) {
yield this . collectionsView . selectByID ( "L" + libraryID ) ;
2011-07-25 21:27:32 +00:00
}
2016-07-01 09:48:19 +00:00
// Select next appropriate row after removal
2016-03-14 00:31:15 +00:00
else {
2016-07-01 09:48:19 +00:00
this . collectionsView . selectAfterRowRemoval ( selectedRow ) ;
2016-03-14 00:31:15 +00:00
}
this . collectionsView . selection . selectEventsSuppressed = false ;
2016-07-01 09:48:19 +00:00
2017-03-24 09:18:55 +00:00
return promise ;
2016-03-11 12:34:57 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
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
2015-04-16 18:02:36 +00:00
this . openAdvancedSearchWindow = function ( ) {
2011-01-30 09:44:01 +00:00
var wm = Components . classes [ "@mozilla.org/appshell/window-mediator;1" ]
. getService ( Components . interfaces . nsIWindowMediator ) ;
var enumerator = wm . getEnumerator ( 'zotero:search' ) ;
while ( enumerator . hasMoreElements ( ) ) {
var win = enumerator . getNext ( ) ;
}
if ( win ) {
win . focus ( ) ;
return ;
}
var s = new Zotero . Search ( ) ;
2014-05-15 07:19:49 +00:00
s . libraryID = this . getSelectedLibraryID ( ) ;
2015-04-16 18:02:36 +00:00
s . addCondition ( 'title' , 'contains' , '' ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2011-01-30 09:44:01 +00:00
var io = { dataIn : { search : s } , dataOut : null } ;
window . openDialog ( 'chrome://zotero/content/advancedSearch.xul' , '' , 'chrome,dialog=no,centerscreen' , io ) ;
2015-04-16 18:02:36 +00:00
} ;
2011-01-30 09:44:01 +00:00
2019-03-15 19:42:09 +00:00
this . initTagSelector = function ( ) {
2019-03-17 09:05:04 +00:00
var container = document . getElementById ( 'zotero-tag-selector-container' ) ;
if ( ! container . hasAttribute ( 'collapsed' ) || container . getAttribute ( 'collapsed' ) == 'false' ) {
this . tagSelector = Zotero . TagSelector . init (
document . getElementById ( 'zotero-tag-selector' ) ,
{
2019-03-28 09:19:41 +00:00
container : 'zotero-tag-selector-container' ,
onSelection : this . updateTagFilter . bind ( this ) ,
2019-03-17 09:05:04 +00:00
}
) ;
}
2019-03-15 19:42:09 +00:00
} ;
2019-03-28 09:19:41 +00:00
this . handleTagSelectorResize = Zotero . Utilities . debounce ( function ( ) {
if ( this . tagSelectorShown ( ) ) {
2020-03-29 03:50:30 +00:00
// Initialize if dragging open after startup
if ( ! this . tagSelector ) {
this . initTagSelector ( ) ;
this . setTagScope ( ) ;
}
2019-03-28 09:19:41 +00:00
this . tagSelector . handleResize ( ) ;
}
} , 100 ) ;
2019-03-17 09:05:04 +00:00
/ *
* Sets the tag filter on the items view
* /
this . updateTagFilter = Zotero . Promise . coroutine ( function * ( ) {
if ( this . itemsView ) {
yield this . itemsView . setFilter ( 'tags' , ZoteroPane _Local . tagSelector . getTagSelection ( ) ) ;
}
} ) ;
2019-08-12 20:18:46 +00:00
// Keep in sync with ZoteroStandalone.updateViewOption()
2019-03-28 09:19:41 +00:00
this . toggleTagSelector = function ( ) {
2019-03-15 19:42:09 +00:00
var container = document . getElementById ( 'zotero-tag-selector-container' ) ;
var showing = container . getAttribute ( 'collapsed' ) == 'true' ;
container . setAttribute ( 'collapsed' , ! showing ) ;
2011-01-30 09:44:01 +00:00
// If showing, set scope to items in current view
// and focus filter textbox
if ( showing ) {
2019-03-15 19:42:09 +00:00
this . initTagSelector ( ) ;
ZoteroPane . tagSelector . focusTextbox ( ) ;
2019-03-28 09:19:41 +00:00
this . setTagScope ( ) ;
2011-01-30 09:44:01 +00:00
}
// If hiding, clear selection
else {
2019-03-15 19:42:09 +00:00
ZoteroPane . tagSelector . uninit ( ) ;
2019-03-28 09:19:41 +00:00
ZoteroPane . tagSelector = null ;
2011-01-30 09:44:01 +00:00
}
2019-03-28 09:19:41 +00:00
} ;
2011-01-30 09:44:01 +00:00
2016-12-02 21:52:28 +00:00
this . tagSelectorShown = function ( ) {
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
if ( ! collectionTreeRow ) return ;
2019-03-17 09:05:04 +00:00
var tagSelector = document . getElementById ( 'zotero-tag-selector-container' ) ;
return ! tagSelector . hasAttribute ( 'collapsed' )
2016-12-02 21:52:28 +00:00
|| tagSelector . getAttribute ( 'collapsed' ) == 'false' ;
} ;
2011-01-30 09:44:01 +00:00
/ *
* Set the tags scope to the items in the current view
*
* Passed to the items tree to trigger on changes
* /
2019-03-28 09:19:41 +00:00
this . setTagScope = function ( ) {
2017-05-22 23:10:03 +00:00
var collectionTreeRow = self . getCollectionTreeRow ( ) ;
if ( self . tagSelectorShown ( ) ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . editable ) {
2017-05-22 23:10:03 +00:00
ZoteroPane _Local . tagSelector . setMode ( 'edit' ) ;
2011-01-30 09:44:01 +00:00
}
else {
2017-05-22 23:10:03 +00:00
ZoteroPane _Local . tagSelector . setMode ( 'view' ) ;
2011-01-30 09:44:01 +00:00
}
2018-12-12 10:34:39 +00:00
ZoteroPane _Local . tagSelector . onItemViewChanged ( {
libraryID : collectionTreeRow . ref . libraryID ,
2019-03-28 09:19:41 +00:00
collectionTreeRow
2018-12-12 10:34:39 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
}
2017-05-22 23:10:03 +00:00
} ;
2011-01-30 09:44:01 +00:00
2015-05-22 23:15:21 +00:00
this . onCollectionSelected = function ( ) {
return Zotero . spawn ( function * ( ) {
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
if ( ! collectionTreeRow ) {
return ;
}
2012-10-31 09:22:58 +00:00
2015-08-08 21:26:42 +00:00
if ( this . itemsView && this . itemsView . collectionTreeRow . id == collectionTreeRow . id ) {
2015-05-22 23:15:21 +00:00
Zotero . debug ( "Collection selection hasn't changed" ) ;
2016-03-25 20:48:33 +00:00
// Update toolbar, in case editability has changed
this . _updateToolbarIconsForRow ( collectionTreeRow ) ;
2015-05-22 23:15:21 +00:00
return ;
2012-10-31 09:22:58 +00:00
}
2015-05-22 23:15:21 +00:00
if ( this . itemsView ) {
// Wait for existing items view to finish loading before unloading it
//
// TODO: Cancel loading
2017-03-24 09:18:55 +00:00
let promise = this . itemsView . waitForLoad ( ) ;
if ( promise . isPending ( ) ) {
2015-05-22 23:15:21 +00:00
Zotero . debug ( "Waiting for items view " + this . itemsView . id + " to finish loading" ) ;
2017-03-24 09:18:55 +00:00
yield promise ;
2015-05-22 23:15:21 +00:00
}
this . itemsView . unregister ( ) ;
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView = null ;
2012-10-31 09:22:58 +00:00
}
2015-05-22 23:15:21 +00:00
if ( this . collectionsView . selection . count != 1 ) {
return ;
2011-10-02 23:28:38 +00:00
}
2015-05-22 23:15:21 +00:00
2020-09-15 07:30:17 +00:00
// Rename tab
2021-02-11 10:57:35 +00:00
if ( Zotero . isPDFBuild ) {
Zotero _Tabs . rename ( 'zotero-pane' , collectionTreeRow . getName ( ) ) ;
}
2021-02-16 09:05:45 +00:00
let type = Zotero . Libraries . get ( collectionTreeRow . ref . libraryID ) . libraryType ;
2021-06-30 13:48:55 +00:00
ZoteroItemPane . switchEditorEngine ( type == 'group' && ! Zotero . enablePDFBuildForGroups || ! Zotero . isPDFBuild ) ;
2020-09-15 07:30:17 +00:00
2015-05-22 23:15:21 +00:00
// Clear quick search and tag selector when switching views
document . getElementById ( 'zotero-tb-search' ) . value = "" ;
2019-03-17 09:05:04 +00:00
if ( ZoteroPane . tagSelector ) {
ZoteroPane . tagSelector . clearTagSelection ( ) ;
}
2015-05-22 23:15:21 +00:00
// Not necessary with seltype="cell", which calls nsITreeView::isSelectable()
/ * i f ( c o l l e c t i o n T r e e R o w . i s S e p a r a t o r ( ) ) {
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView = null ;
return ;
} * /
collectionTreeRow . setSearch ( '' ) ;
2019-03-17 09:05:04 +00:00
if ( ZoteroPane . tagSelector ) {
collectionTreeRow . setTags ( ZoteroPane . tagSelector . getTagSelection ( ) ) ;
}
2015-05-22 23:15:21 +00:00
2016-03-25 20:48:33 +00:00
this . _updateToolbarIconsForRow ( collectionTreeRow ) ;
2015-05-22 23:15:21 +00:00
2017-09-20 07:30:42 +00:00
this . itemsView = new Zotero . ItemTreeView ( collectionTreeRow ) ;
2017-04-12 04:56:37 +00:00
if ( collectionTreeRow . isPublications ( ) ) {
2017-04-20 01:48:08 +00:00
this . itemsView . collapseAll = true ;
2017-04-12 04:56:37 +00:00
}
2015-05-22 23:15:21 +00:00
this . itemsView . onError = function ( ) {
2016-03-26 07:00:10 +00:00
// Don't reload last folder, in case that's the problem
Zotero . Prefs . clear ( 'lastViewedFolder' ) ;
2020-03-13 21:17:02 +00:00
Zotero . crash ( ) ;
2015-05-22 23:15:21 +00:00
} ;
2020-02-29 21:24:34 +00:00
this . itemsView . onRefresh . addListener ( ( ) => {
this . setTagScope ( ) ;
} ) ;
this . itemsView . onLoad . addListener ( ( ) => {
// Show error if items list couldn't loaded (e.g., bad search), as set in
// Zotero.CollectionTreeRow::getSearchResults()
if ( Zotero . CollectionTreeCache . error ) {
this . setItemsPaneMessage ( Zotero . getString ( 'pane.items.loadError' ) ) ;
}
Zotero . uiIsReady ( ) ;
} ) ;
2016-04-10 22:58:01 +00:00
// If item data not yet loaded for library, load it now.
// Other data types are loaded at startup
var library = Zotero . Libraries . get ( collectionTreeRow . ref . libraryID ) ;
if ( ! library . getDataLoaded ( 'item' ) ) {
Zotero . debug ( "Waiting for items to load for library " + library . libraryID ) ;
2016-04-11 06:29:08 +00:00
ZoteroPane _Local . setItemsPaneMessage ( Zotero . getString ( 'pane.items.loading' ) ) ;
2016-04-10 22:58:01 +00:00
yield library . waitForDataLoad ( 'item' ) ;
}
2015-05-22 23:15:21 +00:00
document . getElementById ( 'zotero-items-tree' ) . view = this . itemsView ;
try {
2016-06-29 00:12:54 +00:00
let tree = document . getElementById ( 'zotero-items-tree' ) ;
2015-05-22 23:15:21 +00:00
let treecols = document . getElementById ( 'zotero-items-columns-header' ) ;
let treecolpicker = treecols . boxObject . firstChild . nextSibling ;
let menupopup = treecolpicker . boxObject . firstChild . nextSibling ;
2016-05-25 11:52:39 +00:00
// Add events to treecolpicker to update menu before showing/hiding
2015-05-22 23:15:21 +00:00
let attr = menupopup . getAttribute ( 'onpopupshowing' ) ;
if ( attr . indexOf ( 'Zotero' ) == - 1 ) {
2016-06-29 00:12:54 +00:00
menupopup . setAttribute ( 'onpopupshowing' , 'ZoteroPane.itemsView.onColumnPickerShowing(event); '
2015-05-22 23:15:21 +00:00
// Keep whatever else is there
2016-06-29 00:12:54 +00:00
+ attr ) ;
menupopup . setAttribute ( 'onpopuphidden' , 'ZoteroPane.itemsView.onColumnPickerHidden(event); '
2015-05-22 23:15:21 +00:00
// Keep whatever else is there
2016-06-29 00:12:54 +00:00
+ menupopup . getAttribute ( 'onpopuphidden' ) ) ;
2015-05-22 23:15:21 +00:00
}
2016-05-25 11:52:39 +00:00
2016-06-29 00:12:54 +00:00
// Items view column visibility for different groups
let prevViewGroup = tree . getAttribute ( 'current-view-group' ) ;
let curViewGroup = collectionTreeRow . visibilityGroup ;
tree . setAttribute ( 'current-view-group' , curViewGroup ) ;
if ( curViewGroup != prevViewGroup ) {
let cols = Array . from ( treecols . getElementsByTagName ( 'treecol' ) ) ;
let settings = JSON . parse ( Zotero . Prefs . get ( 'itemsView.columnVisibility' ) || '{}' ) ;
if ( prevViewGroup ) {
// Store previous view settings
let setting = { } ;
for ( let col of cols ) {
let colType = col . id . substring ( 'zotero-items-column-' . length ) ;
setting [ colType ] = col . getAttribute ( 'hidden' ) == 'true' ? 0 : 1
}
settings [ prevViewGroup ] = setting ;
Zotero . Prefs . set ( 'itemsView.columnVisibility' , JSON . stringify ( settings ) ) ;
}
// Recover current view settings
if ( settings [ curViewGroup ] ) {
for ( let col of cols ) {
let colType = col . id . substring ( 'zotero-items-column-' . length ) ;
col . setAttribute ( 'hidden' , ! settings [ curViewGroup ] [ colType ] ) ;
}
} else {
cols . forEach ( ( col ) => {
col . setAttribute ( 'hidden' , ! ( col . hasAttribute ( 'default-in' ) &&
col . getAttribute ( 'default-in' ) . split ( ' ' ) . indexOf ( curViewGroup ) != - 1 )
)
} )
2016-05-25 11:52:39 +00:00
}
}
2015-05-22 23:15:21 +00:00
}
catch ( e ) {
Zotero . debug ( e ) ;
}
Zotero . Prefs . set ( 'lastViewedFolder' , collectionTreeRow . id ) ;
} , this )
. finally ( function ( ) {
2017-03-24 09:18:55 +00:00
return this . collectionsView . runListeners ( 'select' ) ;
2015-05-22 23:15:21 +00:00
} . bind ( this ) ) ;
} ;
2011-01-30 09:44:01 +00:00
2016-03-25 20:48:33 +00:00
/ * *
* Enable or disable toolbar icons and menu options as necessary
* /
this . _updateToolbarIconsForRow = function ( collectionTreeRow ) {
const disableIfNoEdit = [
"cmd_zotero_newCollection" ,
"cmd_zotero_newSavedSearch" ,
"zotero-tb-add" ,
"zotero-tb-lookup" ,
"cmd_zotero_newStandaloneNote" ,
"zotero-tb-note-add" ,
"zotero-tb-attachment-add"
] ;
for ( let i = 0 ; i < disableIfNoEdit . length ; i ++ ) {
let command = disableIfNoEdit [ i ] ;
let el = document . getElementById ( command ) ;
// If a trash is selected, new collection depends on the
// editability of the library
if ( collectionTreeRow . isTrash ( ) && command == 'cmd_zotero_newCollection' ) {
2016-10-26 06:27:31 +00:00
var overrideEditable = Zotero . Libraries . get ( collectionTreeRow . ref . libraryID ) . editable ;
2016-03-25 20:48:33 +00:00
}
else {
var overrideEditable = false ;
}
// Don't allow normal buttons in My Publications, because things need to
// be dragged and go through the wizard
2021-02-25 23:29:49 +00:00
let forceDisable = collectionTreeRow . isPublications ( )
&& command != 'cmd_zotero_newCollection'
&& command != 'zotero-tb-note-add' ;
2016-03-25 20:48:33 +00:00
if ( ( collectionTreeRow . editable || overrideEditable ) && ! forceDisable ) {
if ( el . hasAttribute ( "disabled" ) ) el . removeAttribute ( "disabled" ) ;
} else {
el . setAttribute ( "disabled" , "true" ) ;
}
}
} ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . getCollectionTreeRow = function ( ) {
2016-10-08 23:58:49 +00:00
if ( ! this . collectionsView || ! this . collectionsView . selection . count ) {
2011-12-30 17:44:19 +00:00
return false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
return this . collectionsView . getRow ( this . collectionsView . selection . currentIndex ) ;
2011-01-30 09:44:01 +00:00
}
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
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
2015-05-08 20:01:25 +00:00
* @ return { Promise < Boolean > } - Promise that resolves to true if an item was selected ,
* or false if not ( used for tests , though there could possibly
* be a better test for whether the item pane changed )
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
* /
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
this . itemSelected = function ( event ) {
2017-01-14 23:01:51 +00:00
return Zotero . Promise . coroutine ( function * ( ) {
2015-05-10 08:20:47 +00:00
// Don't select item until items list has loaded
//
// This avoids an error if New Item is used while the pane is first loading.
2017-03-24 09:18:55 +00:00
var promise = this . itemsView . waitForLoad ( ) ;
if ( promise . isPending ( ) ) {
yield promise ;
2017-01-14 23:01:51 +00:00
}
2015-05-10 08:20:47 +00:00
2016-04-11 06:29:25 +00:00
if ( ! this . itemsView || ! this . itemsView . selection ) {
Zotero . debug ( "Items view not available in itemSelected" , 2 ) ;
return false ;
}
2015-05-07 19:05:37 +00:00
2017-04-12 04:56:37 +00:00
var selectedItems = this . itemsView . getSelectedItems ( ) ;
// Display buttons at top of item pane depending on context. This needs to run even if the
// selection hasn't changed, because the selected items might have been modified.
this . updateItemPaneButtons ( selectedItems ) ;
2017-07-27 06:29:50 +00:00
this . updateQuickCopyCommands ( selectedItems ) ;
2015-05-07 19:05:37 +00:00
// Check if selection has actually changed. The onselect event that calls this
// can be called in various situations where the selection didn't actually change,
// such as whenever selectEventsSuppressed is set to false.
var ids = selectedItems . map ( item => item . id ) ;
ids . sort ( ) ;
2015-05-08 20:01:25 +00:00
if ( ids . length && Zotero . Utilities . arrayEquals ( _lastSelectedItems , ids ) ) {
2015-05-07 19:05:37 +00:00
return false ;
}
_lastSelectedItems = ids ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var tabs = document . getElementById ( 'zotero-view-tabbox' ) ;
// save note when switching from a note
if ( document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex == 2 ) {
// TODO: only try to save when selected item is different
yield document . getElementById ( 'zotero-note-editor' ) . save ( ) ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
2015-06-09 05:29:26 +00:00
// I don't think this happens in normal usage, but it can happen during tests
if ( ! collectionTreeRow ) {
return false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Single item selected
2017-05-24 22:20:11 +00:00
if ( selectedItems . length == 1 ) {
2015-05-07 19:05:37 +00:00
var item = selectedItems [ 0 ] ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( item . isNote ( ) ) {
2017-12-11 07:23:15 +00:00
ZoteroItemPane . onNoteSelected ( item , this . collectionsView . editable ) ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( item . isAttachment ( ) ) {
var attachmentBox = document . getElementById ( 'zotero-attachment-box' ) ;
attachmentBox . mode = this . collectionsView . editable ? 'edit' : 'view' ;
attachmentBox . item = item ;
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 3 ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Regular item
2011-01-30 09:44:01 +00:00
else {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var isCommons = collectionTreeRow . isBucket ( ) ;
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 1 ;
var tabBox = document . getElementById ( 'zotero-view-tabbox' ) ;
2017-07-27 04:11:13 +00:00
// Reset tab when viewing a feed item, which only has the info tab
if ( item . isFeedItem ) {
tabBox . selectedIndex = 0 ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var pane = tabBox . selectedIndex ;
tabBox . firstChild . hidden = isCommons ;
var button = document . getElementById ( 'zotero-item-show-original' ) ;
if ( isCommons ) {
button . hidden = false ;
button . disabled = ! this . getOriginalItem ( ) ;
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
}
else {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
button . hidden = true ;
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
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( this . collectionsView . editable ) {
yield ZoteroItemPane . viewItem ( item , null , pane ) ;
tabs . selectedIndex = document . getElementById ( 'zotero-view-item' ) . selectedIndex ;
}
else {
yield ZoteroItemPane . viewItem ( item , 'view' , pane ) ;
tabs . selectedIndex = document . getElementById ( 'zotero-view-item' ) . selectedIndex ;
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
}
2014-11-07 04:10:59 +00:00
2014-12-15 05:07:37 +00:00
if ( item . isFeedItem ) {
2016-02-11 11:02:38 +00:00
// Too slow for now
// if (!item.isTranslated) {
// item.translate();
// }
2017-11-03 08:36:42 +00:00
this . updateReadLabel ( ) ;
this . startItemReadTimeout ( item . id ) ;
2014-11-07 04:10:59 +00:00
}
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
}
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Zero or multiple items selected
2011-01-30 09:44:01 +00:00
else {
2016-03-25 04:49:14 +00:00
if ( collectionTreeRow . isFeed ( ) ) {
2017-11-03 08:36:42 +00:00
this . updateReadLabel ( ) ;
2016-03-25 04:49:14 +00:00
}
2017-05-24 22:20:11 +00:00
let count = selectedItems . length ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Display duplicates merge interface in item pane
if ( collectionTreeRow . isDuplicates ( ) ) {
if ( ! collectionTreeRow . editable ) {
if ( count ) {
var msg = Zotero . getString ( 'pane.item.duplicates.writeAccessRequired' ) ;
}
else {
var msg = Zotero . getString ( 'pane.item.selected.zero' ) ;
}
this . setItemPaneMessage ( msg ) ;
}
else if ( count ) {
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 4 ;
// Load duplicates UI code
if ( typeof Zotero _Duplicates _Pane == 'undefined' ) {
Zotero . debug ( "Loading duplicatesMerge.js" ) ;
Components . classes [ "@mozilla.org/moz/jssubscript-loader;1" ]
. getService ( Components . interfaces . mozIJSSubScriptLoader )
. loadSubScript ( "chrome://zotero/content/duplicatesMerge.js" ) ;
}
// On a Select All of more than a few items, display a row
// count instead of the usual item type mismatch error
var displayNumItemsOnTypeError = count > 5 && count == this . itemsView . rowCount ;
// Initialize the merge pane with the selected items
2015-05-07 19:05:37 +00:00
Zotero _Duplicates _Pane . setItems ( selectedItems , displayNumItemsOnTypeError ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
else {
var msg = Zotero . getString ( 'pane.item.duplicates.selectToMerge' ) ;
this . setItemPaneMessage ( msg ) ;
}
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
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
// Display label in the middle of the item pane
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
else {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( count ) {
var msg = Zotero . getString ( 'pane.item.selected.multiple' , count ) ;
}
else {
var rowCount = this . itemsView . rowCount ;
var str = 'pane.item.unselected.' ;
switch ( rowCount ) {
case 0 :
str += 'zero' ;
break ;
case 1 :
str += 'singular' ;
break ;
default :
str += 'plural' ;
break ;
}
var msg = Zotero . getString ( str , [ rowCount ] ) ;
2012-03-13 19:21:07 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . setItemPaneMessage ( msg ) ;
2015-05-08 20:01:25 +00:00
return false ;
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
}
2011-01-30 09:44:01 +00:00
}
2015-05-07 19:05:37 +00:00
return true ;
2017-01-14 23:01:51 +00:00
} . bind ( this ) ) ( )
2017-05-18 01:29:22 +00:00
. catch ( function ( e ) {
2018-08-11 10:22:28 +00:00
Zotero . logError ( e ) ;
2020-03-13 21:17:02 +00:00
Zotero . crash ( ) ;
2017-05-18 01:29:22 +00:00
throw e ;
} . bind ( this ) )
2015-05-22 23:15:21 +00:00
. finally ( function ( ) {
2017-03-24 09:18:55 +00:00
return this . itemsView . runListeners ( 'select' ) ;
2014-10-10 08:35:45 +00:00
} . bind ( this ) ) ;
2015-05-08 20:01:25 +00:00
}
2011-01-30 09:44:01 +00:00
/ * *
2017-04-12 04:56:37 +00:00
* Display buttons at top of item pane depending on context
2011-01-30 09:44:01 +00:00
*
2017-04-12 04:56:37 +00:00
* @ param { Zotero . Item [ ] }
2011-01-30 09:44:01 +00:00
* /
2017-04-12 04:56:37 +00:00
this . updateItemPaneButtons = function ( selectedItems ) {
if ( ! selectedItems . length ) {
2017-06-23 08:59:48 +00:00
document . querySelectorAll ( '.zotero-item-pane-top-buttons' ) . forEach ( x => x . hidden = true ) ;
2017-04-12 04:56:37 +00:00
return ;
}
// My Publications buttons
2017-04-27 07:57:33 +00:00
var isPublications = this . getCollectionTreeRow ( ) . isPublications ( ) ;
// Show in My Publications view if selected items are all notes or non-linked-file attachments
var showMyPublicationsButtons = isPublications
&& selectedItems . every ( ( item ) => {
return item . isNote ( )
|| ( item . isAttachment ( )
&& item . attachmentLinkMode != Zotero . Attachments . LINK _MODE _LINKED _FILE ) ;
} ) ;
var myPublicationsButtons = document . getElementById ( 'zotero-item-pane-top-buttons-my-publications' ) ;
myPublicationsButtons . hidden = ! showMyPublicationsButtons ;
if ( showMyPublicationsButtons ) {
2017-04-12 04:56:37 +00:00
let button = myPublicationsButtons . firstChild ;
let hiddenItemsSelected = selectedItems . some ( item => ! item . inPublications ) ;
let str , onclick ;
if ( hiddenItemsSelected ) {
str = 'showInMyPublications' ;
onclick = ( ) => Zotero . Items . addToPublications ( selectedItems ) ;
2011-01-30 09:44:01 +00:00
}
2017-04-12 04:56:37 +00:00
else {
str = 'hideFromMyPublications' ;
onclick = ( ) => Zotero . Items . removeFromPublications ( selectedItems ) ;
}
button . label = Zotero . getString ( 'pane.item.' + str ) ;
button . onclick = onclick ;
2011-01-30 09:44:01 +00:00
}
2017-04-12 04:56:37 +00:00
// Trash button
let nonDeletedItemsSelected = selectedItems . some ( item => ! item . deleted ) ;
document . getElementById ( 'zotero-item-pane-top-buttons-trash' ) . hidden
= ! this . getCollectionTreeRow ( ) . isTrash ( ) || nonDeletedItemsSelected ;
// Feed buttons
document . getElementById ( 'zotero-item-pane-top-buttons-feed' ) . hidden
= ! this . getCollectionTreeRow ( ) . isFeed ( )
} ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
* @ return { Promise }
* /
2011-01-30 09:44:01 +00:00
this . updateNoteButtonMenu = function ( ) {
2011-03-08 23:46:01 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var cmd = document . getElementById ( 'cmd_zotero_newChildNote' ) ;
cmd . setAttribute ( "disabled" , ! this . canEdit ( ) ||
! ( items . length == 1 && ( items [ 0 ] . isRegularItem ( ) || ! items [ 0 ] . isTopLevelItem ( ) ) ) ) ;
2011-01-30 09:44:01 +00:00
}
this . updateAttachmentButtonMenu = function ( popup ) {
2011-03-08 23:46:01 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
2011-01-30 09:44:01 +00:00
var disabled = ! this . canEdit ( ) || ! ( items . length == 1 && items [ 0 ] . isRegularItem ( ) ) ;
if ( disabled ) {
2015-03-17 19:14:17 +00:00
for ( let node of popup . childNodes ) {
2011-01-30 09:44:01 +00:00
node . disabled = true ;
}
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . selectedTreeRow ;
2011-01-30 09:44:01 +00:00
var canEditFiles = this . canEditFiles ( ) ;
var prefix = "menuitem-iconic zotero-menuitem-attachments-" ;
for ( var i = 0 ; i < popup . childNodes . length ; i ++ ) {
var node = popup . childNodes [ i ] ;
2018-08-17 06:18:35 +00:00
var className = node . className ;
2011-01-30 09:44:01 +00:00
2013-05-19 04:14:13 +00:00
switch ( className ) {
2011-01-30 09:44:01 +00:00
case prefix + 'link' :
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
node . disabled = collectionTreeRow . isWithinGroup ( ) ;
2011-01-30 09:44:01 +00:00
break ;
case prefix + 'file' :
node . disabled = ! canEditFiles ;
break ;
case prefix + 'web-link' :
node . disabled = false ;
break ;
default :
2018-08-17 06:18:35 +00:00
throw new Error ( ` Invalid class name ' ${ className } ' ` ) ;
2011-01-30 09:44:01 +00:00
}
}
}
2017-07-27 06:29:50 +00:00
/ * *
* Update the < command > elements that control the shortcut keys and the enabled state of the
* "Copy Citation" / "Copy Bibliography" / "Copy as" menu options . When disabled , the shortcuts are
* still caught in handleKeyPress so that we can show an alert about not having references selected .
* /
this . updateQuickCopyCommands = function ( selectedItems ) {
var format = Zotero . QuickCopy . getFormatFromURL ( Zotero . QuickCopy . lastActiveURL ) ;
format = Zotero . QuickCopy . unserializeSetting ( format ) ;
if ( format . mode == 'bibliography' ) {
var canCopy = selectedItems . some ( item => item . isRegularItem ( ) ) ;
}
else {
var canCopy = true ;
}
document . getElementById ( 'cmd_zotero_copyCitation' ) . setAttribute ( 'disabled' , ! canCopy ) ;
document . getElementById ( 'cmd_zotero_copyBibliography' ) . setAttribute ( 'disabled' , ! canCopy ) ;
} ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
* @ return { Promise }
* /
this . reindexItem = Zotero . Promise . coroutine ( function * ( ) {
2011-01-30 09:44:01 +00:00
var items = this . getSelectedItems ( ) ;
if ( ! items ) {
return ;
}
var itemIDs = [ ] ;
2018-01-15 17:09:38 +00:00
2011-01-30 09:44:01 +00:00
for ( var i = 0 ; i < items . length ; i ++ ) {
itemIDs . push ( items [ i ] . id ) ;
}
2020-03-09 05:07:06 +00:00
yield Zotero . FullText . indexItems ( itemIDs , { complete : true } ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield document . getElementById ( 'zotero-attachment-box' ) . updateItemIndexedState ( ) ;
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
2016-04-01 06:00:12 +00:00
* @ return { Promise < Zotero . Item > } - The new Zotero . Item
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
* /
this . duplicateSelectedItem = Zotero . Promise . coroutine ( function * ( ) {
var self = this ;
if ( ! self . canEdit ( ) ) {
self . displayCannotEditLibraryMessage ( ) ;
2011-01-30 09:44:01 +00:00
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var item = self . getSelectedItems ( ) [ 0 ] ;
var newItem ;
2011-01-30 09:44:01 +00:00
2015-03-17 05:08:18 +00:00
yield Zotero . DB . executeTransaction ( function * ( ) {
2016-06-11 03:26:32 +00:00
newItem = item . clone ( ) ;
// If in a collection, add new item to it
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( self . collectionsView . selectedTreeRow . isCollection ( ) && newItem . isTopLevelItem ( ) ) {
2016-06-11 03:26:32 +00:00
newItem . setCollections ( [ self . collectionsView . selectedTreeRow . ref . id ] ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
2016-06-11 03:26:32 +00:00
yield newItem . save ( ) ;
2017-10-02 02:04:11 +00:00
for ( let relItemKey of item . relatedItems ) {
try {
let relItem = yield Zotero . Items . getByLibraryAndKeyAsync ( item . libraryID , relItemKey ) ;
if ( relItem . addRelatedItem ( newItem ) ) {
yield relItem . save ( {
skipDateModifiedUpdate : true
} ) ;
}
}
catch ( e ) {
Zotero . logError ( e ) ;
}
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield self . selectItem ( newItem . id ) ;
2016-04-01 06:00:12 +00:00
return newItem ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
this . deleteSelectedItem = function ( ) {
2011-03-08 23:46:01 +00:00
Zotero . debug ( "ZoteroPane_Local.deleteSelectedItem() is deprecated -- use ZoteroPane_Local.deleteSelectedItems()" ) ;
2011-01-30 09:44:01 +00:00
this . deleteSelectedItems ( ) ;
}
/ *
* Remove , trash , or delete item ( s ) , depending on context
*
2013-01-05 21:35:33 +00:00
* @ param { Boolean } [ force = false ] Trash or delete even if in a collection or search ,
* or trash without prompt in library
* @ param { Boolean } [ fromMenu = false ] If triggered from context menu , which always prompts for deletes
2011-01-30 09:44:01 +00:00
* /
2013-01-05 21:35:33 +00:00
this . deleteSelectedItems = function ( force , fromMenu ) {
2011-01-30 09:44:01 +00:00
if ( ! this . itemsView || ! this . itemsView . selection . count ) {
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . selectedTreeRow ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( ! collectionTreeRow . isTrash ( ) && ! collectionTreeRow . isBucket ( ) && ! this . canEdit ( ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var toTrash = {
title : Zotero . getString ( 'pane.items.trash.title' ) ,
text : Zotero . getString (
'pane.items.trash' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
var toDelete = {
title : Zotero . getString ( 'pane.items.delete.title' ) ,
text : Zotero . getString (
'pane.items.delete' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
2015-03-08 21:20:57 +00:00
var toRemove = {
title : Zotero . getString ( 'pane.items.remove.title' ) ,
text : Zotero . getString (
'pane.items.remove' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
2011-01-30 09:44:01 +00:00
2015-03-06 19:21:33 +00:00
if ( collectionTreeRow . isPublications ( ) ) {
2017-04-12 04:56:37 +00:00
let toRemoveFromPublications = {
title : Zotero . getString ( 'pane.items.removeFromPublications.title' ) ,
text : Zotero . getString (
'pane.items.removeFromPublications' + ( this . itemsView . selection . count > 1 ? '.multiple' : '' )
)
} ;
var prompt = force ? toTrash : toRemoveFromPublications ;
2015-03-06 19:21:33 +00:00
}
else if ( collectionTreeRow . isLibrary ( true ) ) {
2011-01-30 09:44:01 +00:00
// In library, don't prompt if meta key was pressed
2013-01-05 21:35:33 +00:00
var prompt = ( force && ! fromMenu ) ? false : toTrash ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isCollection ( ) ) {
2015-03-21 01:39:55 +00:00
// Ignore unmodified action if only child items are selected
if ( ! force && this . itemsView . getSelectedItems ( ) . every ( item => ! item . isTopLevelItem ( ) ) ) {
return ;
}
2015-03-08 21:20:57 +00:00
var prompt = force ? toTrash : toRemove ;
2011-01-30 09:44:01 +00:00
}
2019-06-10 06:37:54 +00:00
else if ( collectionTreeRow . isSearch ( )
|| collectionTreeRow . isUnfiled ( )
|| collectionTreeRow . isRetracted ( )
|| collectionTreeRow . isDuplicates ( ) ) {
2011-01-30 09:44:01 +00:00
if ( ! force ) {
return ;
}
var prompt = toTrash ;
}
// Do nothing in trash view if any non-deleted items are selected
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isTrash ( ) ) {
2011-01-30 09:44:01 +00:00
var start = { } ;
var end = { } ;
for ( var i = 0 , len = this . itemsView . selection . getRangeCount ( ) ; i < len ; i ++ ) {
this . itemsView . selection . getRangeAt ( i , start , end ) ;
for ( var j = start . value ; j <= end . value ; j ++ ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( ! this . itemsView . getRow ( j ) . ref . deleted ) {
2011-01-30 09:44:01 +00:00
return ;
}
}
}
var prompt = toDelete ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isBucket ( ) ) {
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
var prompt = toDelete ;
}
// Do nothing in share views
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isShare ( ) ) {
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
return ;
}
2011-01-30 09:44:01 +00:00
var promptService = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
if ( ! prompt || promptService . confirm ( window , prompt . title , prompt . text ) ) {
this . itemsView . deleteSelection ( force ) ;
}
}
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
this . mergeSelectedItems = function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 4 ;
if ( typeof Zotero _Duplicates _Pane == 'undefined' ) {
Zotero . debug ( "Loading duplicatesMerge.js" ) ;
Components . classes [ "@mozilla.org/moz/jssubscript-loader;1" ]
. getService ( Components . interfaces . mozIJSSubScriptLoader )
. loadSubScript ( "chrome://zotero/content/duplicatesMerge.js" ) ;
}
// Initialize the merge pane with the selected items
Zotero _Duplicates _Pane . setItems ( this . getSelectedItems ( ) ) ;
}
2013-03-17 02:55:50 +00:00
this . deleteSelectedCollection = function ( deleteItems ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
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
2017-01-17 12:12:09 +00:00
// Don't allow deleting libraries
if ( collectionTreeRow . isLibrary ( true ) && ! collectionTreeRow . isFeed ( ) ) {
return ;
}
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
// Remove virtual duplicates collection
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isDuplicates ( ) ) {
this . setVirtual ( collectionTreeRow . ref . libraryID , 'duplicates' , false ) ;
2012-01-11 23:08:11 +00:00
return ;
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
}
// Remove virtual unfiled collection
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isUnfiled ( ) ) {
this . setVirtual ( collectionTreeRow . ref . libraryID , 'unfiled' , false ) ;
2011-02-14 03:59:32 +00:00
return ;
}
2019-06-10 06:37:54 +00:00
// Remove virtual retracted collection
else if ( collectionTreeRow . isRetracted ( ) ) {
this . setVirtual ( collectionTreeRow . ref . libraryID , 'retracted' , false ) ;
return ;
}
2011-02-14 03:59:32 +00:00
2016-02-11 11:02:38 +00:00
if ( ! this . canEdit ( ) && ! collectionTreeRow . isFeed ( ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2013-03-17 02:55:50 +00:00
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _CANCEL ;
2011-01-30 09:44:01 +00:00
if ( this . collectionsView . selection . count == 1 ) {
2015-02-03 17:57:32 +00:00
var title , message ;
// Work out the required title and message
if ( collectionTreeRow . isCollection ( ) ) {
2013-03-17 02:55:50 +00:00
if ( deleteItems ) {
2015-02-03 17:57:32 +00:00
title = Zotero . getString ( 'pane.collections.deleteWithItems.title' ) ;
message = Zotero . getString ( 'pane.collections.deleteWithItems' ) ;
2013-03-17 02:55:50 +00:00
}
else {
2015-02-03 17:57:32 +00:00
title = Zotero . getString ( 'pane.collections.delete.title' ) ;
message = Zotero . getString ( 'pane.collections.delete' )
2013-03-17 02:55:50 +00:00
+ "\n\n"
2015-02-03 17:57:32 +00:00
+ Zotero . getString ( 'pane.collections.delete.keepItems' ) ;
2011-01-30 09:44:01 +00:00
}
}
2015-02-03 17:57:32 +00:00
else if ( collectionTreeRow . isFeed ( ) ) {
title = Zotero . getString ( 'pane.feed.deleteWithItems.title' ) ;
message = Zotero . getString ( 'pane.feed.deleteWithItems' ) ;
}
else if ( collectionTreeRow . isSearch ( ) ) {
title = Zotero . getString ( 'pane.collections.deleteSearch.title' ) ;
message = Zotero . getString ( 'pane.collections.deleteSearch' ) ;
}
// Display prompt
var index = ps . confirmEx (
null ,
title ,
message ,
buttonFlags ,
title ,
"" , "" , "" , { }
) ;
if ( index == 0 ) {
2016-06-28 18:29:15 +00:00
return this . collectionsView . deleteSelection ( deleteItems ) ;
2011-01-30 09:44:01 +00:00
}
}
}
// Currently used only for Commons to find original linked item
this . getOriginalItem = function ( ) {
var item = this . getSelectedItems ( ) [ 0 ] ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
2011-01-30 09:44:01 +00:00
// TEMP: Commons buckets only
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
return collectionTreeRow . ref . getLocalItem ( item ) ;
2011-01-30 09:44:01 +00:00
}
this . showOriginalItem = function ( ) {
var item = this . getOriginalItem ( ) ;
if ( ! item ) {
Zotero . debug ( "Original item not found" ) ;
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . selectItem ( item . id ) . done ( ) ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
* @ return { Promise }
* /
this . restoreSelectedItems = Zotero . Promise . coroutine ( function * ( ) {
2011-01-30 09:44:01 +00:00
var items = this . getSelectedItems ( ) ;
if ( ! items ) {
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield Zotero . DB . executeTransaction ( function * ( ) {
for ( let i = 0 ; i < items . length ; i ++ ) {
items [ i ] . deleted = false ;
2015-05-10 00:10:22 +00:00
yield items [ i ] . save ( {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
skipDateModifiedUpdate : true
} ) ;
}
} . bind ( this ) ) ;
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
* @ return { Promise }
* /
this . emptyTrash = Zotero . Promise . coroutine ( function * ( ) {
2011-08-30 23:35:12 +00:00
var libraryID = this . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var result = ps . confirm (
null ,
"" ,
Zotero . getString ( 'pane.collections.emptyTrash' ) + "\n\n"
+ Zotero . getString ( 'general.actionCannotBeUndone' )
) ;
if ( result ) {
2017-09-16 00:20:41 +00:00
Zotero . showZoteroPaneProgressMeter ( null , true ) ;
try {
let deleted = yield Zotero . Items . emptyTrash (
libraryID ,
{
onProgress : ( progress , progressMax ) => {
var percentage = Math . round ( ( progress / progressMax ) * 100 ) ;
Zotero . updateZoteroPaneProgressMeter ( percentage ) ;
}
}
) ;
}
finally {
Zotero . hideZoteroPaneOverlays ( ) ;
}
2016-04-10 22:58:01 +00:00
yield Zotero . purgeDataObjects ( ) ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2018-12-16 07:22:50 +00:00
// Currently only works on searches
this . duplicateSelectedCollection = async function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( this . collectionsView . selection . count == 0 ) {
return ;
}
var row = this . collectionsView . selectedTreeRow ;
let o = row . ref . clone ( ) ;
o . name = await row . ref . ObjectsClass . getNextName ( row . ref . libraryID , o . name ) ;
await o . saveTx ( ) ;
} ;
2015-04-17 23:27:37 +00:00
this . editSelectedCollection = Zotero . Promise . coroutine ( function * ( ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
if ( this . collectionsView . selection . count > 0 ) {
2016-02-11 11:02:38 +00:00
var row = this . collectionsView . selectedTreeRow ;
2011-01-30 09:44:01 +00:00
if ( row . isCollection ( ) ) {
var promptService = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
var newName = { value : row . getName ( ) } ;
var result = promptService . prompt ( window , "" ,
Zotero . getString ( 'pane.collections.rename' ) , newName , "" , { } ) ;
if ( result && newName . value ) {
row . ref . name = newName . value ;
2015-05-10 08:20:47 +00:00
row . ref . saveTx ( ) ;
2011-01-30 09:44:01 +00:00
}
}
else {
2016-03-26 06:59:54 +00:00
let s = row . ref . clone ( ) ;
2015-04-17 23:27:37 +00:00
let groups = [ ] ;
// Promises don't work in the modal dialog, so get the group name here, if
// applicable, and pass it in. We only need the group that this search belongs
// to, if any, since the library drop-down is disabled for saved searches.
2015-11-01 23:29:02 +00:00
if ( Zotero . Libraries . get ( s . libraryID ) . libraryType == 'group' ) {
2016-10-21 02:55:42 +00:00
groups . push ( Zotero . Groups . getByLibraryID ( s . libraryID ) ) ;
2015-04-17 23:27:37 +00:00
}
var io = {
dataIn : {
search : s ,
name : row . getName ( ) ,
groups : groups
} ,
dataOut : null
} ;
window . openDialog ( 'chrome://zotero/content/searchDialog.xul' , '' , 'chrome,modal' , io ) ;
if ( io . dataOut ) {
2016-03-26 06:59:54 +00:00
row . ref . fromJSON ( io . dataOut . json ) ;
yield row . ref . saveTx ( ) ;
2015-04-17 23:27:37 +00:00
}
2011-01-30 09:44:01 +00:00
}
}
2015-04-17 23:27:37 +00:00
} ) ;
2016-02-10 16:10:55 +00:00
2016-03-25 04:49:14 +00:00
this . toggleSelectedItemsRead = Zotero . Promise . coroutine ( function * ( ) {
yield Zotero . FeedItems . toggleReadByID ( this . getSelectedItems ( true ) ) ;
} ) ;
2016-02-10 16:10:55 +00:00
this . markFeedRead = Zotero . Promise . coroutine ( function * ( ) {
if ( ! this . collectionsView . selection . count ) return ;
2016-02-11 11:02:38 +00:00
let feed = this . collectionsView . selectedTreeRow . ref ;
2016-02-10 16:10:55 +00:00
let feedItemIDs = yield Zotero . FeedItems . getAll ( feed . libraryID , true , false , true ) ;
yield Zotero . FeedItems . toggleReadByID ( feedItemIDs , true ) ;
} ) ;
2011-01-30 09:44:01 +00:00
2014-11-07 04:10:59 +00:00
this . editSelectedFeed = Zotero . Promise . coroutine ( function * ( ) {
if ( ! this . collectionsView . selection . count ) return ;
2016-02-11 11:02:38 +00:00
let feed = this . collectionsView . selectedTreeRow . ref ;
2014-11-07 04:10:59 +00:00
let data = {
url : feed . url ,
title : feed . name ,
ttl : feed . refreshInterval ,
2016-12-13 14:07:43 +00:00
cleanupReadAfter : feed . cleanupReadAfter ,
cleanupUnreadAfter : feed . cleanupUnreadAfter
2014-11-07 04:10:59 +00:00
} ;
window . openDialog ( 'chrome://zotero/content/feedSettings.xul' ,
null , 'centerscreen, modal' , data ) ;
if ( data . cancelled ) return ;
feed . name = data . title ;
feed . refreshInterval = data . ttl ;
2016-12-13 14:07:43 +00:00
feed . cleanupReadAfter = data . cleanupReadAfter ;
feed . cleanupUnreadAfter = data . cleanupUnreadAfter ;
2016-01-13 13:13:29 +00:00
yield feed . saveTx ( ) ;
2014-11-07 04:10:59 +00:00
} ) ;
this . refreshFeed = function ( ) {
if ( ! this . collectionsView . selection . count ) return ;
2016-02-11 11:02:38 +00:00
let feed = this . collectionsView . selectedTreeRow . ref ;
2014-11-07 04:10:59 +00:00
return feed . updateFeed ( ) ;
}
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . copySelectedItemsToClipboard = function ( asCitations ) {
2011-01-30 09:44:01 +00:00
var items = this . getSelectedItems ( ) ;
if ( ! items . length ) {
return ;
}
2017-07-27 06:29:50 +00:00
var format = Zotero . QuickCopy . getFormatFromURL ( Zotero . QuickCopy . lastActiveURL ) ;
format = Zotero . QuickCopy . unserializeSetting ( format ) ;
// In bibliography mode, remove notes and attachments
if ( format . mode == 'bibliography' ) {
items = items . filter ( item => item . isRegularItem ( ) ) ;
}
2011-01-30 09:44:01 +00:00
// DEBUG: We could copy notes via keyboard shortcut if we altered
// Z_F_I.copyItemsToClipboard() to use Z.QuickCopy.getContentFromItems(),
// but 1) we'd need to override that function's drag limit and 2) when I
// tried it the OS X clipboard seemed to be getting text vs. HTML wrong,
// automatically converting text/html to plaintext rather than using
// text/unicode. (That may be fixable, however.)
2017-07-27 06:29:50 +00:00
//
// This isn't currently shown, because the commands are disabled when not relevant, so this
// function isn't called
if ( ! items . length ) {
let ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
2011-01-30 09:44:01 +00:00
. getService ( Components . interfaces . nsIPromptService ) ;
ps . alert ( null , "" , Zotero . getString ( "fileInterface.noReferencesError" ) ) ;
return ;
}
2015-02-03 02:23:59 +00:00
// determine locale preference
var locale = format . locale ? format . locale : Zotero . Prefs . get ( 'export.quickCopy.locale' ) ;
if ( format . mode == 'bibliography' ) {
2016-08-26 06:42:56 +00:00
Zotero _File _Interface . copyItemsToClipboard (
items , format . id , locale , format . contentType == 'html' , asCitations
) ;
2011-01-30 09:44:01 +00:00
}
2015-02-03 02:23:59 +00:00
else if ( format . mode == 'export' ) {
2011-01-30 09:44:01 +00:00
// Copy citations doesn't work in export mode
if ( asCitations ) {
return ;
}
else {
2015-02-03 02:23:59 +00:00
Zotero _File _Interface . exportItemsToClipboard ( items , format . id ) ;
2011-01-30 09:44:01 +00:00
}
}
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . clearQuicksearch = Zotero . Promise . coroutine ( function * ( ) {
2011-01-30 09:44:01 +00:00
var search = document . getElementById ( 'zotero-tb-search' ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( search . value !== '' ) {
2011-01-30 09:44:01 +00:00
search . value = '' ;
2016-02-06 08:26:31 +00:00
yield this . search ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
return true ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
return false ;
} ) ;
2011-01-30 09:44:01 +00:00
2016-02-06 20:20:02 +00:00
/ * *
* Some keys trigger an immediate search
* /
2016-02-06 08:26:31 +00:00
this . handleSearchKeypress = function ( textbox , event ) {
2011-01-30 09:44:01 +00:00
if ( event . keyCode == event . DOM _VK _ESCAPE ) {
textbox . value = '' ;
2016-02-06 08:26:31 +00:00
this . search ( ) ;
2011-01-30 09:44:01 +00:00
}
2014-08-12 23:18:29 +00:00
else if ( event . keyCode == event . DOM _VK _RETURN ) {
2016-02-06 08:26:31 +00:00
this . search ( true ) ;
2011-01-30 09:44:01 +00:00
}
}
2016-02-06 08:26:31 +00:00
this . handleSearchInput = function ( textbox , event ) {
2016-02-06 20:20:02 +00:00
if ( textbox . value . indexOf ( '"' ) != - 1 ) {
2016-02-06 08:26:31 +00:00
this . setItemsPaneMessage ( Zotero . getString ( 'advancedSearchMode' ) ) ;
2011-01-30 09:44:01 +00:00
}
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
* @ return { Promise }
* /
this . search = Zotero . Promise . coroutine ( function * ( runAdvanced ) {
if ( ! this . itemsView ) {
return ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var search = document . getElementById ( 'zotero-tb-search' ) ;
if ( ! runAdvanced && search . value . indexOf ( '"' ) != - 1 ) {
return ;
}
2016-11-21 07:57:57 +00:00
var spinner = document . getElementById ( 'zotero-tb-search-spinner' ) ;
2018-03-06 09:19:01 +00:00
spinner . style . display = 'inline' ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var searchVal = search . value ;
2016-02-06 08:26:31 +00:00
yield this . itemsView . setFilter ( 'search' , searchVal ) ;
2018-03-06 09:19:01 +00:00
spinner . style . display = 'none' ;
2016-11-21 07:57:57 +00:00
if ( runAdvanced ) {
this . clearItemsPaneMessage ( ) ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2019-02-23 22:28:44 +00:00
this . selectItem = async function ( itemID , inLibraryRoot ) {
2011-01-30 09:44:01 +00:00
if ( ! itemID ) {
return false ;
}
2019-02-23 22:28:44 +00:00
return this . selectItems ( [ itemID ] , inLibraryRoot ) ;
} ;
this . selectItems = async function ( itemIDs , inLibraryRoot ) {
if ( ! itemIDs . length ) {
return false ;
}
2011-01-30 09:44:01 +00:00
2019-02-23 22:28:44 +00:00
var items = await Zotero . Items . getAsync ( itemIDs ) ;
if ( ! items . length ) {
2011-01-30 09:44:01 +00:00
return false ;
}
2014-09-23 05:11:41 +00:00
// Restore window if it's in the dock
if ( window . windowState == Components . interfaces . nsIDOMChromeWindow . STATE _MINIMIZED ) {
window . restore ( ) ;
2011-01-30 09:44:01 +00:00
}
2014-09-23 05:11:41 +00:00
if ( ! this . collectionsView ) {
throw new Error ( "Collections view not loaded" ) ;
2011-01-30 09:44:01 +00:00
}
2019-02-23 22:28:44 +00:00
var found = await this . collectionsView . selectItems ( itemIDs , inLibraryRoot ) ;
2015-11-02 02:22:13 +00:00
2016-12-26 23:44:39 +00:00
// Focus the items pane
if ( found ) {
document . getElementById ( 'zotero-items-tree' ) . focus ( ) ;
2014-09-23 05:11:41 +00:00
}
2019-02-23 22:28:44 +00:00
} ;
2014-09-23 05:11:41 +00:00
2011-01-30 09:44:01 +00:00
this . getSelectedLibraryID = function ( ) {
2011-10-05 17:46:23 +00:00
return this . collectionsView . getSelectedLibraryID ( ) ;
2011-01-30 09:44:01 +00:00
}
function getSelectedCollection ( asID ) {
2011-10-05 17:46:23 +00:00
return this . collectionsView ? this . collectionsView . getSelectedCollection ( asID ) : false ;
2011-01-30 09:44:01 +00:00
}
function getSelectedSavedSearch ( asID )
{
if ( this . collectionsView . selection . count > 0 && this . collectionsView . selection . currentIndex != - 1 ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collection = this . collectionsView . getRow ( this . collectionsView . selection . currentIndex ) ;
2011-01-30 09:44:01 +00:00
if ( collection && collection . isSearch ( ) ) {
return asID ? collection . ref . id : collection . ref ;
}
}
return false ;
}
/ *
* Return an array of Item objects for selected items
*
* If asIDs is true , return an array of itemIDs instead
* /
function getSelectedItems ( asIDs )
{
if ( ! this . itemsView ) {
return [ ] ;
}
return this . itemsView . getSelectedItems ( asIDs ) ;
}
this . getSelectedGroup = function ( asID ) {
if ( this . collectionsView . selection
&& this . collectionsView . selection . count > 0
&& this . collectionsView . selection . currentIndex != - 1 ) {
2011-08-30 23:35:12 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
if ( collectionTreeRow && collectionTreeRow . isGroup ( ) ) {
return asID ? collectionTreeRow . ref . id : collectionTreeRow . ref ;
2011-01-30 09:44:01 +00:00
}
}
return false ;
}
/ *
* Returns an array of Zotero . Item objects of visible items in current sort order
*
* If asIDs is true , return an array of itemIDs instead
* /
function getSortedItems ( asIDs ) {
if ( ! this . itemsView ) {
return [ ] ;
}
return this . itemsView . getSortedItems ( asIDs ) ;
}
function getSortField ( ) {
if ( ! this . itemsView ) {
return false ;
}
return this . itemsView . getSortField ( ) ;
}
function getSortDirection ( ) {
if ( ! this . itemsView ) {
return false ;
}
return this . itemsView . getSortDirection ( ) ;
}
2018-04-14 15:32:23 +00:00
/ * *
* Show context menu once it ' s ready
* /
this . onCollectionsContextMenuOpen = async function ( event ) {
await ZoteroPane . buildCollectionContextMenu ( ) ;
document . getElementById ( 'zotero-collectionmenu' ) . openPopup (
null , null , event . clientX + 1 , event . clientY + 1 , true , false , event
) ;
} ;
/ * *
* Show context menu once it ' s ready
* /
this . onItemsContextMenuOpen = async function ( event ) {
await ZoteroPane . buildItemContextMenu ( )
document . getElementById ( 'zotero-itemmenu' ) . openPopup (
null , null , event . clientX + 1 , event . clientY + 1 , true , false , event
) ;
} ;
this . onCollectionContextMenuSelect = function ( event ) {
event . stopPropagation ( ) ;
var o = _collectionContextMenuOptions . find ( o => o . id == event . target . id )
if ( o . oncommand ) {
o . oncommand ( ) ;
}
} ;
2017-07-12 19:43:20 +00:00
// menuitem configuration
//
// This has to be kept in sync with zotero-collectionmenu in zoteroPane.xul. We could do this
// entirely in JS, but various localized strings are only in zotero.dtd, and they're used in
// standalone.xul as well, so for now they have to remain as XML entities.
var _collectionContextMenuOptions = [
{
id : "sync" ,
label : Zotero . getString ( 'sync.sync' ) ,
oncommand : ( ) => {
Zotero . Sync . Runner . sync ( {
2017-07-14 05:06:57 +00:00
libraries : [ this . getSelectedLibraryID ( ) ] ,
2017-07-12 19:43:20 +00:00
} ) ;
}
} ,
{
id : "sep1" ,
} ,
{
id : "newCollection" ,
command : "cmd_zotero_newCollection"
} ,
{
id : "newSavedSearch" ,
command : "cmd_zotero_newSavedSearch"
} ,
{
id : "newSubcollection" ,
oncommand : ( ) => {
this . newCollection ( this . getSelectedCollection ( ) . key ) ;
}
} ,
{
id : "refreshFeed" ,
oncommand : ( ) => this . refreshFeed ( )
} ,
{
id : "sep2" ,
} ,
{
id : "showDuplicates" ,
oncommand : ( ) => {
2019-06-10 06:37:54 +00:00
this . setVirtual ( this . getSelectedLibraryID ( ) , 'duplicates' , true , true ) ;
2017-07-12 19:43:20 +00:00
}
} ,
{
id : "showUnfiled" ,
oncommand : ( ) => {
2019-06-10 06:37:54 +00:00
this . setVirtual ( this . getSelectedLibraryID ( ) , 'unfiled' , true , true ) ;
}
} ,
{
id : "showRetracted" ,
oncommand : ( ) => {
this . setVirtual ( this . getSelectedLibraryID ( ) , 'retracted' , true , true ) ;
2017-07-12 19:43:20 +00:00
}
} ,
{
id : "editSelectedCollection" ,
oncommand : ( ) => this . editSelectedCollection ( )
} ,
2018-12-16 07:22:50 +00:00
{
id : "duplicate" ,
oncommand : ( ) => this . duplicateSelectedCollection ( )
} ,
2017-07-12 19:43:20 +00:00
{
id : "markReadFeed" ,
oncommand : ( ) => this . markFeedRead ( )
} ,
{
id : "editSelectedFeed" ,
oncommand : ( ) => this . editSelectedFeed ( )
} ,
{
id : "deleteCollection" ,
oncommand : ( ) => this . deleteSelectedCollection ( )
} ,
{
id : "deleteCollectionAndItems" ,
oncommand : ( ) => this . deleteSelectedCollection ( true )
} ,
{
id : "sep3" ,
} ,
{
id : "exportCollection" ,
oncommand : ( ) => Zotero _File _Interface . exportCollection ( )
} ,
{
id : "createBibCollection" ,
oncommand : ( ) => Zotero _File _Interface . bibliographyFromCollection ( )
} ,
{
id : "exportFile" ,
oncommand : ( ) => Zotero _File _Interface . exportFile ( )
} ,
{
id : "loadReport" ,
2020-01-04 05:51:43 +00:00
oncommand : ( ) => Zotero _Report _Interface . loadCollectionReport ( )
2017-07-12 19:43:20 +00:00
} ,
{
id : "emptyTrash" ,
oncommand : ( ) => this . emptyTrash ( )
} ,
{
id : "removeLibrary" ,
label : Zotero . getString ( 'pane.collections.menu.remove.library' ) ,
oncommand : ( ) => {
2017-07-14 05:06:57 +00:00
let library = Zotero . Libraries . get ( this . getSelectedLibraryID ( ) ) ;
2017-07-12 19:43:20 +00:00
let ps = Services . prompt ;
let buttonFlags = ( ps . BUTTON _POS _0 ) * ( ps . BUTTON _TITLE _IS _STRING )
+ ( ps . BUTTON _POS _1 ) * ( ps . BUTTON _TITLE _CANCEL ) ;
let index = ps . confirmEx (
null ,
Zotero . getString ( 'pane.collections.removeLibrary' ) ,
Zotero . getString ( 'pane.collections.removeLibrary.text' , library . name ) ,
buttonFlags ,
Zotero . getString ( 'general.remove' ) ,
null ,
null , null , { }
) ;
if ( index == 0 ) {
library . eraseTx ( ) ;
}
}
} ,
] ;
2018-04-14 15:32:23 +00:00
this . buildCollectionContextMenu = async function ( ) {
2016-07-02 05:46:23 +00:00
var libraryID = this . getSelectedLibraryID ( ) ;
2017-07-12 19:43:20 +00:00
var options = _collectionContextMenuOptions ;
2016-07-02 05:46:23 +00:00
2016-05-12 06:12:22 +00:00
var collectionTreeRow = this . collectionsView . selectedTreeRow ;
2016-07-02 05:46:23 +00:00
// This can happen if selection is changing during delayed second call below
if ( ! collectionTreeRow ) {
return ;
}
2018-04-14 15:32:23 +00:00
// If the items view isn't initialized, this was a right-click on a different collection
// and the new collection's items are still loading, so continue menu after loading is
// done. This causes some menu items (e.g., export/createBib/loadReport) to appear gray
// in the menu at first and then turn black once there are items
if ( ! collectionTreeRow . isHeader ( ) && ! this . itemsView . initialized ) {
await new Promise ( ( resolve ) => {
this . itemsView . onLoad . addListener ( ( ) => {
resolve ( ) ;
} ) ;
} ) ;
2016-05-12 06:12:22 +00:00
}
2016-07-02 05:46:23 +00:00
// Set attributes on the menu from the configuration object
var menu = document . getElementById ( 'zotero-collectionmenu' ) ;
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
var m = { } ;
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < options . length ; i ++ ) {
2016-07-02 05:46:23 +00:00
let option = options [ i ] ;
let menuitem = menu . childNodes [ i ] ;
m [ option . id ] = menuitem ;
menuitem . id = option . id ;
if ( ! menuitem . classList . contains ( 'menuitem-iconic' ) ) {
menuitem . classList . add ( 'menuitem-iconic' ) ;
}
if ( option . label ) {
menuitem . setAttribute ( 'label' , option . label ) ;
}
if ( option . command ) {
menuitem . setAttribute ( 'command' , option . command ) ;
}
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
}
// By default things are hidden and visible, so we only need to record
// when things are visible and when they're visible but disabled
var show = [ ] , disable = [ ] ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isCollection ( ) ) {
2011-01-30 09:44:01 +00:00
show = [
2016-07-02 05:46:23 +00:00
'newSubcollection' ,
'sep2' ,
'editSelectedCollection' ,
'deleteCollection' ,
'deleteCollectionAndItems' ,
'sep3' ,
'exportCollection' ,
'createBibCollection' ,
'loadReport'
2011-01-30 09:44:01 +00:00
] ;
2016-04-11 06:52:09 +00:00
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
if ( ! this . itemsView . rowCount ) {
2018-04-14 15:32:23 +00:00
disable = [ 'createBibCollection' , 'loadReport' ] ;
// If no items in subcollections either, disable export
if ( ! ( await collectionTreeRow . ref . getDescendents ( false , 'item' , false ) . length ) ) {
disable . push ( 'exportCollection' ) ;
}
2011-01-30 09:44:01 +00:00
}
// Adjust labels
2016-07-02 05:46:23 +00:00
m . editSelectedCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.rename.collection' ) ) ;
m . deleteCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.collection' ) ) ;
m . deleteCollectionAndItems . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.collectionAndItems' ) ) ;
m . exportCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.export.collection' ) ) ;
m . createBibCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.createBib.collection' ) ) ;
m . loadReport . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.generateReport.collection' ) ) ;
2011-01-30 09:44:01 +00:00
}
2014-11-07 04:10:59 +00:00
else if ( collectionTreeRow . isFeed ( ) ) {
show = [
2016-07-02 05:46:23 +00:00
'refreshFeed' ,
'sep2' ,
'markReadFeed' ,
'editSelectedFeed' ,
'deleteCollectionAndItems'
2014-11-07 04:10:59 +00:00
] ;
2016-02-10 16:10:55 +00:00
if ( collectionTreeRow . ref . unreadCount == 0 ) {
2016-07-02 05:46:23 +00:00
disable = [ 'markReadFeed' ] ;
2016-02-10 16:10:55 +00:00
}
2014-11-07 04:10:59 +00:00
// Adjust labels
2016-07-02 05:46:23 +00:00
m . deleteCollectionAndItems . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.feedAndItems' ) ) ;
2014-11-07 04:10:59 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isSearch ( ) ) {
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
show = [
2016-07-02 05:46:23 +00:00
'editSelectedCollection' ,
2018-12-16 07:22:50 +00:00
'duplicate' ,
2016-07-02 05:46:23 +00:00
'deleteCollection' ,
'sep3' ,
'exportCollection' ,
'createBibCollection' ,
'loadReport'
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
] ;
2011-01-30 09:44:01 +00:00
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
if ( ! this . itemsView . rowCount ) {
2016-07-02 05:46:23 +00:00
disable . push ( 'exportCollection' , 'createBibCollection' , 'loadReport' ) ;
2011-01-30 09:44:01 +00:00
}
// Adjust labels
2016-07-02 05:46:23 +00:00
m . editSelectedCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.edit.savedSearch' ) ) ;
2018-12-16 07:22:50 +00:00
m . duplicate . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.duplicate.savedSearch' ) ) ;
m . deleteCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.delete.savedSearch' ) ) ;
2016-07-02 05:46:23 +00:00
m . exportCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.export.savedSearch' ) ) ;
m . createBibCollection . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.createBib.savedSearch' ) ) ;
m . loadReport . setAttribute ( 'label' , Zotero . getString ( 'pane.collections.menu.generateReport.savedSearch' ) ) ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isTrash ( ) ) {
2016-07-02 05:46:23 +00:00
show = [ 'emptyTrash' ] ;
2011-01-30 09:44:01 +00:00
}
2019-06-10 06:37:54 +00:00
else if ( collectionTreeRow . isDuplicates ( ) || collectionTreeRow . isUnfiled ( ) || collectionTreeRow . isRetracted ( ) ) {
2016-07-02 05:46:23 +00:00
show = [ 'deleteCollection' ] ;
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
2016-07-02 05:46:23 +00:00
m . deleteCollection . setAttribute ( 'label' , Zotero . getString ( 'general.hide' ) ) ;
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
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
else if ( collectionTreeRow . isHeader ( ) ) {
2011-01-30 09:44:01 +00:00
}
2015-05-23 23:07:14 +00:00
else if ( collectionTreeRow . isPublications ( ) ) {
2016-07-02 05:46:23 +00:00
show = [
'exportFile'
] ;
2015-05-23 23:07:14 +00:00
}
2011-01-30 09:44:01 +00:00
// Library
2015-05-23 23:07:14 +00:00
else {
2017-02-24 07:29:11 +00:00
let library = Zotero . Libraries . get ( libraryID ) ;
show = [ ] ;
if ( ! library . archived ) {
show . push (
'sync' ,
'sep1' ,
'newCollection' ,
'newSavedSearch'
) ;
}
2019-06-10 06:37:54 +00:00
// Only show "Show Duplicates", "Show Unfiled Items", and "Show Retracted" if rows are hidden
2016-07-02 05:46:23 +00:00
let duplicates = Zotero . Utilities . Internal . getVirtualCollectionStateForLibrary (
libraryID , 'duplicates'
) ;
let unfiled = Zotero . Utilities . Internal . getVirtualCollectionStateForLibrary (
libraryID , 'unfiled'
) ;
2019-06-10 06:37:54 +00:00
let retracted = Zotero . Utilities . Internal . getVirtualCollectionStateForLibrary (
libraryID , 'retracted'
) ;
if ( ! duplicates || ! unfiled || ! retracted ) {
2017-02-24 07:29:11 +00:00
if ( ! library . archived ) {
show . push ( 'sep2' ) ;
}
2016-07-02 05:46:23 +00:00
if ( ! duplicates ) {
show . push ( 'showDuplicates' ) ;
}
if ( ! unfiled ) {
show . push ( 'showUnfiled' ) ;
}
2019-06-10 06:37:54 +00:00
if ( ! retracted ) {
show . push ( 'showRetracted' ) ;
}
2016-07-02 05:46:23 +00:00
}
2017-02-24 07:29:11 +00:00
if ( ! library . archived ) {
show . push ( 'sep3' ) ;
}
2016-07-02 05:46:23 +00:00
show . push (
'exportFile'
) ;
2017-02-24 07:29:11 +00:00
if ( library . archived ) {
show . push ( 'removeLibrary' ) ;
}
2011-01-30 09:44:01 +00:00
}
// Disable some actions if user doesn't have write access
2012-01-11 23:23:36 +00:00
//
// Some actions are disabled via their commands in onCollectionSelected()
2019-06-10 06:37:54 +00:00
if ( collectionTreeRow . isWithinGroup ( )
&& ! collectionTreeRow . editable
&& ! collectionTreeRow . isDuplicates ( )
&& ! collectionTreeRow . isUnfiled ( )
&& ! collectionTreeRow . isRetracted ( ) ) {
2016-07-02 05:46:23 +00:00
disable . push (
'newSubcollection' ,
'editSelectedCollection' ,
2018-12-16 07:22:50 +00:00
'duplicate' ,
2016-07-02 05:46:23 +00:00
'deleteCollection' ,
'deleteCollectionAndItems'
) ;
2011-01-30 09:44:01 +00:00
}
2012-01-19 07:40:46 +00:00
// If within non-editable group or trash it empty, disable Empty Trash
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isTrash ( ) ) {
if ( ( collectionTreeRow . isWithinGroup ( ) && ! collectionTreeRow . isWithinEditableGroup ( ) ) || ! this . itemsView . rowCount ) {
2016-07-02 05:46:23 +00:00
disable . push ( 'emptyTrash' ) ;
2012-01-19 07:40:46 +00:00
}
}
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
// Hide and enable all actions by default (so if they're shown they're enabled)
2015-03-17 19:14:17 +00:00
for ( let i in m ) {
2016-07-02 05:46:23 +00:00
m [ i ] . setAttribute ( 'hidden' , true ) ;
m [ i ] . setAttribute ( 'disabled' , false ) ;
2011-01-30 09:44:01 +00:00
}
2016-07-02 05:46:23 +00:00
for ( let id of show ) {
m [ id ] . setAttribute ( 'hidden' , false ) ;
2011-01-30 09:44:01 +00:00
}
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
2016-07-02 05:46:23 +00:00
for ( let id of disable ) {
m [ id ] . setAttribute ( 'disabled' , true ) ;
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
}
2017-07-12 19:43:20 +00:00
} ;
2017-07-13 07:26:28 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . buildItemContextMenu = Zotero . Promise . coroutine ( function * ( ) {
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
var options = [
'showInLibrary' ,
'sep1' ,
'addNote' ,
2021-02-24 06:38:15 +00:00
'createNoteFromAnnotations' ,
'createNoteFromAnnotationsMenu' ,
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
'addAttachments' ,
'sep2' ,
2018-08-07 08:08:47 +00:00
'findPDF' ,
'sep3' ,
2016-02-10 16:10:55 +00:00
'toggleRead' ,
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
'duplicateItem' ,
2017-04-12 04:56:37 +00:00
'removeItems' ,
2011-10-02 15:50:54 +00:00
'restoreToLibrary' ,
2015-11-03 22:01:07 +00:00
'moveToTrash' ,
'deleteFromLibrary' ,
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
'mergeItems' ,
2018-08-07 08:08:47 +00:00
'sep4' ,
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
'exportItems' ,
'createBib' ,
'loadReport' ,
2018-08-07 08:08:47 +00:00
'sep5' ,
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
'recognizePDF' ,
2018-03-08 08:50:51 +00:00
'unrecognize' ,
'reportMetadata' ,
2011-08-04 06:00:57 +00:00
'createParent' ,
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
'renameAttachments' ,
2019-08-18 20:22:39 +00:00
'reindexItem' ,
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
] ;
var m = { } ;
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < options . length ; i ++ ) {
m [ options [ i ] ] = i ;
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
}
2011-01-30 09:44:01 +00:00
var menu = document . getElementById ( 'zotero-itemmenu' ) ;
2011-03-01 22:40:56 +00:00
// remove old locate menu items
while ( menu . firstChild && menu . firstChild . getAttribute ( "zotero-locate" ) ) {
menu . removeChild ( menu . firstChild ) ;
}
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
var disable = [ ] , show = [ ] , multiple = '' ;
2011-01-30 09:44:01 +00:00
if ( ! this . itemsView ) {
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
2015-11-03 22:01:07 +00:00
var isTrash = collectionTreeRow . isTrash ( ) ;
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
2015-11-03 22:01:07 +00:00
if ( isTrash ) {
show . push ( m . deleteFromLibrary ) ;
2011-10-02 15:50:54 +00:00
show . push ( m . restoreToLibrary ) ;
2015-11-03 22:01:07 +00:00
}
2016-02-11 11:02:38 +00:00
else if ( ! collectionTreeRow . isFeed ( ) ) {
2015-11-03 22:01:07 +00:00
show . push ( m . moveToTrash ) ;
}
2016-02-11 11:02:38 +00:00
if ( ! collectionTreeRow . isFeed ( ) ) {
2018-08-07 08:08:47 +00:00
show . push ( m . sep4 , m . exportItems , m . createBib , m . loadReport ) ;
2016-02-11 11:02:38 +00:00
}
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
2017-05-27 22:38:28 +00:00
var items = this . getSelectedItems ( ) ;
if ( items . length > 0 ) {
2011-01-30 09:44:01 +00:00
// Multiple items selected
2017-06-07 15:50:06 +00:00
if ( items . length > 1 ) {
2011-01-30 09:44:01 +00:00
var multiple = '.multiple' ;
2018-08-07 08:08:47 +00:00
var canMerge = true ,
canIndex = true ,
canRecognize = true ,
canUnrecognize = true ,
2021-01-22 14:28:00 +00:00
canRename = true ;
2016-02-10 16:10:55 +00:00
var canMarkRead = collectionTreeRow . isFeed ( ) ;
var markUnread = true ;
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
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < items . length ; i ++ ) {
let item = items [ i ] ;
2018-08-07 08:08:47 +00:00
if ( canMerge && ( ! item . isRegularItem ( ) || item . isFeedItem || collectionTreeRow . isDuplicates ( ) ) ) {
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
canMerge = false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( canIndex && ! ( yield Zotero . Fulltext . canReindex ( item ) ) ) {
2011-01-30 09:44:01 +00:00
canIndex = false ;
}
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
2018-01-20 08:45:00 +00:00
if ( canRecognize && ! Zotero . RecognizePDF . canRecognize ( item ) ) {
2011-01-30 09:44:01 +00:00
canRecognize = false ;
}
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
2018-03-08 08:50:51 +00:00
if ( canUnrecognize && ! Zotero . RecognizePDF . canUnrecognize ( item ) ) {
canUnrecognize = false ;
}
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
// Show rename option only if all items are child attachments
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( canRename && ( ! item . isAttachment ( ) || item . isTopLevelItem ( ) || item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) ) {
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
canRename = false ;
2011-01-30 09:44:01 +00:00
}
2016-02-10 16:10:55 +00:00
if ( canMarkRead && markUnread && ! item . isRead ) {
markUnread = false ;
}
2011-01-30 09:44:01 +00:00
}
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
if ( canMerge ) {
show . push ( m . mergeItems ) ;
}
2011-01-30 09:44:01 +00:00
if ( canIndex ) {
show . push ( m . reindexItem ) ;
}
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
2011-01-30 09:44:01 +00:00
if ( canRecognize ) {
show . push ( m . recognizePDF ) ;
}
2011-08-04 06:31:14 +00:00
2018-03-08 08:50:51 +00:00
if ( canUnrecognize ) {
show . push ( m . unrecognize ) ;
}
2016-02-10 16:10:55 +00:00
if ( canMarkRead ) {
show . push ( m . toggleRead ) ;
if ( markUnread ) {
2016-02-11 11:02:38 +00:00
menu . childNodes [ m . toggleRead ] . setAttribute ( 'label' , Zotero . getString ( 'pane.item.markAsUnread' ) ) ;
2016-02-10 16:10:55 +00:00
} else {
2016-02-11 11:02:38 +00:00
menu . childNodes [ m . toggleRead ] . setAttribute ( 'label' , Zotero . getString ( 'pane.item.markAsRead' ) ) ;
2016-02-10 16:10:55 +00:00
}
}
2018-10-11 00:04:35 +00:00
// "Find Available PDFs"
if ( collectionTreeRow . filesEditable
&& ! collectionTreeRow . isDuplicates ( )
&& ! collectionTreeRow . isFeed ( )
&& items . some ( item => item . isRegularItem ( ) ) ) {
2018-08-07 08:08:47 +00:00
show . push ( m . findPDF , m . sep3 ) ;
}
2020-12-23 22:37:08 +00:00
let canCreateParent = true ;
for ( let i = 0 ; i < items . length ; i ++ ) {
let item = items [ i ] ;
if ( ! item . isTopLevelItem ( ) || ! item . isAttachment ( ) || item . isFeedItem ) {
canCreateParent = false ;
break ;
}
}
if ( canCreateParent ) {
show . push ( m . createParent ) ;
}
2018-08-07 08:08:47 +00:00
2011-01-30 09:44:01 +00:00
if ( canRename ) {
show . push ( m . renameAttachments ) ;
}
// Add in attachment separator
2020-12-23 22:37:08 +00:00
if ( canCreateParent || canRecognize || canUnrecognize || canRename || canIndex ) {
2018-08-07 08:08:47 +00:00
show . push ( m . sep5 ) ;
2011-01-30 09:44:01 +00:00
}
2019-08-18 20:22:39 +00:00
// Block certain actions on files if no access and at least one item is a file
// attachment
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( ! collectionTreeRow . filesEditable ) {
2019-08-18 20:22:39 +00:00
for ( let item of items ) {
if ( item . isFileAttachment ( ) ) {
disable . push (
m . moveToTrash ,
2020-12-23 22:37:08 +00:00
m . createParent ,
2019-08-18 20:22:39 +00:00
m . renameAttachments
) ;
2011-01-30 09:44:01 +00:00
break ;
}
}
}
2019-03-28 18:52:22 +00:00
2011-01-30 09:44:01 +00:00
}
// Single item selected
else
{
2017-05-27 22:38:28 +00:00
let item = items [ 0 ] ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
menu . setAttribute ( 'itemID' , item . id ) ;
menu . setAttribute ( 'itemKey' , item . key ) ;
2011-01-30 09:44:01 +00:00
2015-11-03 22:01:07 +00:00
if ( ! isTrash ) {
// Show in Library
if ( ! collectionTreeRow . isLibrary ( true ) ) {
show . push ( m . showInLibrary , m . sep1 ) ;
2011-01-30 09:44:01 +00:00
}
2016-02-10 16:10:55 +00:00
if ( item . isRegularItem ( ) && ! item . isFeedItem ) {
2015-11-03 22:01:07 +00:00
show . push ( m . addNote , m . addAttachments , m . sep2 ) ;
2021-02-24 06:38:15 +00:00
// Create Note from Annotations
let popup = document . getElementById ( 'create-note-from-annotations-popup' ) ;
popup . textContent = '' ;
let eligibleAttachments = Zotero . Items . get ( item . getAttachments ( ) )
. filter ( item => item . isPDFAttachment ( ) ) ;
let attachmentsWithAnnotations = eligibleAttachments . filter ( x => x . numAnnotations ( ) ) ;
if ( attachmentsWithAnnotations . length ) {
// Display submenu if there's more than one PDF attachment, even if
// there's only attachment with annotations, so it's clear which one
// the annotations are coming from
if ( eligibleAttachments . length > 1 ) {
show . push ( m . createNoteFromAnnotationsMenu ) ;
for ( let attachment of attachmentsWithAnnotations ) {
let menuitem = document . createElement ( 'menuitem' ) ;
menuitem . setAttribute ( 'label' , attachment . getDisplayTitle ( ) ) ;
menuitem . onclick = ( ) => {
ZoteroPane . createNoteFromAnnotationsForAttachment ( attachment ) ;
} ;
popup . appendChild ( menuitem ) ;
}
}
// Single attachment with annotations
else {
show . push ( m . createNoteFromAnnotations ) ;
}
}
2011-01-30 09:44:01 +00:00
}
2018-08-25 21:00:53 +00:00
if ( Zotero . Attachments . canFindPDFForItem ( item ) ) {
2018-08-07 08:08:47 +00:00
show . push ( m . findPDF , m . sep3 ) ;
}
2018-03-08 08:50:51 +00:00
if ( Zotero . RecognizePDF . canUnrecognize ( item ) ) {
2018-08-07 08:08:47 +00:00
show . push ( m . sep5 , m . unrecognize , m . reportMetadata ) ;
2018-03-08 08:50:51 +00:00
}
2015-11-03 22:01:07 +00:00
if ( item . isAttachment ( ) ) {
2018-08-07 08:08:47 +00:00
var showSep5 = false ;
2015-11-03 22:01:07 +00:00
2018-01-20 08:45:00 +00:00
if ( Zotero . RecognizePDF . canRecognize ( item ) ) {
2015-11-03 22:01:07 +00:00
show . push ( m . recognizePDF ) ;
2018-08-07 08:08:47 +00:00
showSep5 = true ;
2015-11-03 22:01:07 +00:00
}
// Allow parent item creation for standalone attachments
if ( item . isTopLevelItem ( ) ) {
show . push ( m . createParent ) ;
2018-08-07 08:08:47 +00:00
showSep5 = true ;
2015-11-03 22:01:07 +00:00
}
// Attachment rename option
if ( ! item . isTopLevelItem ( ) && item . attachmentLinkMode != Zotero . Attachments . LINK _MODE _LINKED _URL ) {
show . push ( m . renameAttachments ) ;
2018-08-07 08:08:47 +00:00
showSep5 = true ;
2015-11-03 22:01:07 +00:00
}
// If not linked URL, show reindex line
2018-01-15 17:09:38 +00:00
if ( yield Zotero . Fulltext . canReindex ( item ) ) {
2015-11-03 22:01:07 +00:00
show . push ( m . reindexItem ) ;
2018-08-07 08:08:47 +00:00
showSep5 = true ;
2015-11-03 22:01:07 +00:00
}
2018-08-07 08:08:47 +00:00
if ( showSep5 ) {
show . push ( m . sep5 ) ;
2015-11-03 22:01:07 +00:00
}
2011-01-30 09:44:01 +00:00
}
2016-02-10 16:10:55 +00:00
else if ( item . isFeedItem ) {
show . push ( m . toggleRead ) ;
if ( item . isRead ) {
2016-02-11 11:02:38 +00:00
menu . childNodes [ m . toggleRead ] . setAttribute ( 'label' , Zotero . getString ( 'pane.item.markAsUnread' ) ) ;
2016-02-10 16:10:55 +00:00
} else {
2016-02-11 11:02:38 +00:00
menu . childNodes [ m . toggleRead ] . setAttribute ( 'label' , Zotero . getString ( 'pane.item.markAsRead' ) ) ;
2016-02-10 16:10:55 +00:00
}
}
2017-04-12 04:56:37 +00:00
else if ( ! collectionTreeRow . isPublications ( ) ) {
2015-11-03 22:01:07 +00:00
show . push ( m . duplicateItem ) ;
2011-01-30 09:44:01 +00:00
}
}
// Update attachment submenu
var popup = document . getElementById ( 'zotero-add-attachment-popup' )
this . updateAttachmentButtonMenu ( popup ) ;
// Block certain actions on files if no access
2019-08-18 20:22:39 +00:00
if ( item . isFileAttachment ( ) && ! collectionTreeRow . filesEditable ) {
[ m . moveToTrash , m . createParent , m . renameAttachments ]
. forEach ( function ( x ) {
disable . push ( x ) ;
} ) ;
2011-01-30 09:44:01 +00:00
}
}
}
// No items selected
else
{
// Show in Library
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( ! collectionTreeRow . isLibrary ( ) ) {
2011-01-30 09:44:01 +00:00
show . push ( m . showInLibrary , m . sep1 ) ;
}
2017-04-12 04:56:37 +00:00
disable . push ( m . showInLibrary , m . duplicateItem , m . removeItems ,
2015-11-03 22:01:07 +00:00
m . moveToTrash , m . deleteFromLibrary , m . exportItems , m . createBib , m . loadReport ) ;
2011-01-30 09:44:01 +00:00
}
2016-02-11 11:02:38 +00:00
if ( ( ! collectionTreeRow . editable || collectionTreeRow . isPublications ( ) ) && ! collectionTreeRow . isFeed ( ) ) {
2015-11-03 22:01:07 +00:00
for ( let i in m ) {
2017-04-12 04:56:37 +00:00
// Still allow some options for non-editable views
2015-11-03 22:01:07 +00:00
switch ( i ) {
2017-04-12 04:56:37 +00:00
case 'showInLibrary' :
2015-11-03 22:01:07 +00:00
case 'exportItems' :
case 'createBib' :
case 'loadReport' :
2016-02-11 11:02:38 +00:00
case 'toggleRead' :
2015-11-03 22:01:07 +00:00
continue ;
}
if ( isTrash ) {
switch ( i ) {
case 'restoreToLibrary' :
case 'deleteFromLibrary' :
continue ;
}
}
else if ( collectionTreeRow . isPublications ( ) ) {
2011-01-30 09:44:01 +00:00
switch ( i ) {
2015-11-03 22:01:07 +00:00
case 'addNote' :
2017-04-12 04:56:37 +00:00
case 'removeItems' :
case 'moveToTrash' :
2015-11-03 22:01:07 +00:00
continue ;
2011-01-30 09:44:01 +00:00
}
}
disable . push ( m [ i ] ) ;
}
}
// Remove from collection
2017-05-27 22:38:28 +00:00
if ( collectionTreeRow . isCollection ( ) && items . every ( item => item . isTopLevelItem ( ) ) ) {
2017-04-12 04:56:37 +00:00
menu . childNodes [ m . removeItems ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.remove' + multiple ) ) ;
show . push ( m . removeItems ) ;
}
else if ( collectionTreeRow . isPublications ( ) ) {
menu . childNodes [ m . removeItems ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.removeFromPublications' + multiple ) ) ;
show . push ( m . removeItems ) ;
2011-01-30 09:44:01 +00:00
}
2015-11-03 22:01:07 +00:00
// Set labels, plural if necessary
2018-08-07 08:08:47 +00:00
menu . childNodes [ m . findPDF ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.findAvailablePDF' + multiple ) ) ;
2015-11-03 22:01:07 +00:00
menu . childNodes [ m . moveToTrash ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.moveToTrash' + multiple ) ) ;
menu . childNodes [ m . deleteFromLibrary ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.delete' + multiple ) ) ;
2011-01-30 09:44:01 +00:00
menu . childNodes [ m . exportItems ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.export' + multiple ) ) ;
menu . childNodes [ m . createBib ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.createBib' + multiple ) ) ;
menu . childNodes [ m . loadReport ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.generateReport' + multiple ) ) ;
2020-12-23 22:37:08 +00:00
menu . childNodes [ m . createParent ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.createParent' + multiple ) ) ;
2011-01-30 09:44:01 +00:00
menu . childNodes [ m . recognizePDF ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.recognizePDF' + multiple ) ) ;
menu . childNodes [ m . renameAttachments ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.renameAttachments' + multiple ) ) ;
menu . childNodes [ m . reindexItem ] . setAttribute ( 'label' , Zotero . getString ( 'pane.items.menu.reindexItem' + multiple ) ) ;
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
// Hide and enable all actions by default (so if they're shown they're enabled)
2015-03-17 19:14:17 +00:00
for ( let i in m ) {
let pos = m [ i ] ;
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
menu . childNodes [ pos ] . setAttribute ( 'hidden' , true ) ;
menu . childNodes [ pos ] . setAttribute ( 'disabled' , false ) ;
2011-01-30 09:44:01 +00:00
}
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
for ( var i in disable )
2011-01-30 09:44:01 +00:00
{
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
menu . childNodes [ disable [ i ] ] . setAttribute ( 'disabled' , true ) ;
2011-01-30 09:44:01 +00:00
}
for ( var i in show )
{
menu . childNodes [ show [ i ] ] . setAttribute ( 'hidden' , false ) ;
}
2011-02-22 00:02:05 +00:00
// add locate menu options
2015-10-31 07:46:47 +00:00
yield Zotero _LocateMenu . buildContextMenu ( menu , true ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
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
this . onTreeMouseDown = function ( event ) {
2011-10-12 18:41:23 +00:00
var t = event . originalTarget ;
var tree = t . parentNode ;
2013-03-04 23:25:44 +00:00
// Ignore click on column headers
if ( ! tree . treeBoxObject ) {
return ;
}
2012-12-11 20:16:40 +00:00
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
if ( row . value == - 1 ) {
return ;
}
if ( tree . id == 'zotero-collections-tree' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let collectionTreeRow = ZoteroPane _Local . collectionsView . getRow ( row . value ) ;
2013-02-22 23:41:49 +00:00
// Prevent the tree's select event from being called for a click
// on a library sync error icon
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isLibrary ( true ) ) {
2012-12-11 20:16:40 +00:00
if ( col . value . id == 'zotero-collections-sync-status-column' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var errors = Zotero . Sync . Runner . getErrors ( collectionTreeRow . ref . libraryID ) ;
2012-12-11 20:16:40 +00:00
if ( errors ) {
event . stopPropagation ( ) ;
return ;
}
}
}
}
2013-02-22 23:41:49 +00:00
else if ( tree . id == 'zotero-items-tree' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let collectionTreeRow = ZoteroPane _Local . getCollectionTreeRow ( ) ;
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
2015-10-31 07:46:47 +00:00
// Automatically select all equivalent items when clicking on an item
// in duplicates view
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isDuplicates ( ) ) {
2013-05-20 02:01:50 +00:00
// Trigger only on primary-button single clicks without modifiers
2013-02-22 23:41:49 +00:00
// (so that items can still be selected and deselected manually)
2013-05-20 02:01:50 +00:00
if ( ! event || event . detail != 1 || event . button != 0 || event . metaKey
|| event . shiftKey || event . altKey || event . ctrlKey ) {
2013-02-22 23:41:49 +00:00
return ;
}
var t = event . originalTarget ;
if ( t . localName != 'treechildren' ) {
return ;
}
var tree = t . parentNode ;
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
// obj.value == 'cell'/'text'/'image'/'twisty'
if ( ! obj . value ) {
return ;
}
// Duplicated in itemTreeView.js::notify()
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var itemID = ZoteroPane _Local . itemsView . getRow ( row . value ) . ref . id ;
var setItemIDs = collectionTreeRow . ref . getSetItemsByItemID ( itemID ) ;
2013-02-22 23:41:49 +00:00
ZoteroPane _Local . itemsView . selectItems ( setItemIDs ) ;
// Prevent the tree's select event from being called here,
// since it's triggered by the multi-select
event . stopPropagation ( ) ;
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
}
}
}
2011-01-30 09:44:01 +00:00
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
this . onTreeClick = function ( event ) {
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
var t = event . originalTarget ;
if ( t . localName != 'treechildren' ) {
return ;
}
2011-10-12 18:41:23 +00:00
var tree = t . parentNode ;
2012-12-11 20:16:40 +00:00
var row = { } , col = { } , obj = { } ;
tree . treeBoxObject . getCellAt ( event . clientX , event . clientY , row , col , obj ) ;
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
// We care only about primary-button double and triple clicks
2011-01-30 09:44:01 +00:00
if ( ! event || ( event . detail != 2 && event . detail != 3 ) || event . button != 0 ) {
2012-12-11 20:16:40 +00:00
if ( row . value == - 1 ) {
return ;
}
2013-02-22 23:41:49 +00:00
if ( tree . id == 'zotero-collections-tree' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let collectionTreeRow = ZoteroPane _Local . collectionsView . getRow ( row . value ) ;
2013-02-22 23:41:49 +00:00
// Show the error panel when clicking a library-specific
// sync error icon
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isLibrary ( true ) ) {
2013-02-22 23:41:49 +00:00
if ( col . value . id == 'zotero-collections-sync-status-column' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var errors = Zotero . Sync . Runner . getErrors ( collectionTreeRow . ref . libraryID ) ;
2013-02-22 23:41:49 +00:00
if ( ! errors ) {
return ;
}
var panel = Zotero . Sync . Runner . updateErrorPanel ( window . document , errors ) ;
var anchor = document . getElementById ( 'zotero-collections-tree-shim' ) ;
var x = { } , y = { } , width = { } , height = { } ;
tree . treeBoxObject . getCoordsForCellItem ( row . value , col . value , 'image' , x , y , width , height ) ;
x = x . value + Math . round ( width . value / 2 ) ;
y = y . value + height . value + 3 ;
panel . openPopup ( anchor , "after_start" , x , y , false , false ) ;
2012-12-11 20:16:40 +00:00
}
2013-02-22 23:41:49 +00:00
return ;
2012-12-11 20:16:40 +00:00
}
}
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
// The Mozilla tree binding fires select() in mousedown(),
// but if when it gets to click() the selection differs from
// what it expects (say, because multiple items had been
2012-12-11 20:16:40 +00:00
// selected during mousedown(), as is the case in duplicates mode),
// it fires select() again. We prevent that here.
2013-02-22 23:41:49 +00:00
else if ( tree . id == 'zotero-items-tree' ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let collectionTreeRow = ZoteroPane _Local . getCollectionTreeRow ( ) ;
if ( collectionTreeRow . isDuplicates ( ) ) {
2013-05-20 09:39:19 +00:00
if ( event . button != 0 || event . metaKey || event . shiftKey
|| event . altKey || event . ctrlKey ) {
2013-02-22 23:41:49 +00:00
return ;
}
if ( obj . value == 'twisty' ) {
return ;
}
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
2011-10-12 18:41:23 +00:00
}
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
}
2011-01-30 09:44:01 +00:00
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = ZoteroPane _Local . getCollectionTreeRow ( ) ;
2011-01-30 09:44:01 +00:00
2011-10-12 18:41:23 +00:00
// Ignore double-clicks in duplicates view on everything except attachments
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isDuplicates ( ) ) {
2011-10-12 18:41:23 +00:00
var items = ZoteroPane _Local . getSelectedItems ( ) ;
if ( items . length != 1 || ! items [ 0 ] . isAttachment ( ) ) {
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
}
// obj.value == 'cell'/'text'/'image'
if ( ! obj . value ) {
return ;
}
if ( tree . id == 'zotero-collections-tree' ) {
// Ignore triple clicks for collections
if ( event . detail != 2 ) {
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isLibrary ( ) ) {
2011-01-30 09:44:01 +00:00
var uri = Zotero . URI . getCurrentUserLibraryURI ( ) ;
if ( uri ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isSearch ( ) ) {
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . editSelectedCollection ( ) ;
2011-01-30 09:44:01 +00:00
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isGroup ( ) ) {
var uri = Zotero . URI . getGroupURI ( collectionTreeRow . ref , true ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
return ;
}
2019-06-10 06:37:54 +00:00
// Ignore double-clicks on Unfiled/Retracted Items source rows
if ( collectionTreeRow . isUnfiled ( ) || collectionTreeRow . isRetracted ( ) ) {
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
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isHeader ( ) ) {
if ( collectionTreeRow . ref . id == 'group-libraries-header' ) {
2011-01-30 09:44:01 +00:00
var uri = Zotero . URI . getGroupsURL ( ) ;
2011-03-08 23:46:01 +00:00
ZoteroPane _Local . loadURI ( uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow . isBucket ( ) ) {
ZoteroPane _Local . loadURI ( collectionTreeRow . ref . uri ) ;
2011-01-30 09:44:01 +00:00
event . stopPropagation ( ) ;
}
}
else if ( tree . id == 'zotero-items-tree' ) {
2012-11-20 10:34:38 +00:00
var viewOnDoubleClick = Zotero . Prefs . get ( 'viewOnDoubleClick' ) ;
if ( viewOnDoubleClick ) {
// Expand/collapse on triple-click, though the double-click
// will still trigger
if ( event . detail == 3 ) {
tree . view . toggleOpenState ( tree . view . selection . currentIndex ) ;
return ;
}
// Don't expand/collapse on double-click
event . stopPropagation ( ) ;
2011-01-30 09:44:01 +00:00
}
if ( tree . view && tree . view . selection . currentIndex > - 1 ) {
2011-03-08 23:46:01 +00:00
var item = ZoteroPane _Local . getSelectedItems ( ) [ 0 ] ;
2011-01-30 09:44:01 +00:00
if ( item ) {
2012-11-20 10:34:38 +00:00
if ( ! viewOnDoubleClick && item . isRegularItem ( ) ) {
return ;
}
2012-11-01 05:53:31 +00:00
ZoteroPane _Local . viewItems ( [ item ] , event ) ;
2011-01-30 09:44:01 +00:00
}
}
}
}
this . openPreferences = function ( paneID , action ) {
2016-09-06 23:10:51 +00:00
Zotero . warn ( "ZoteroPane.openPreferences() is deprecated"
+ " -- use Zotero.Utilities.Internal.openPreferences() instead" ) ;
Zotero . Utilities . Internal . openPreferences ( paneID , { action } ) ;
2011-01-30 09:44:01 +00:00
}
/ *
* Loads a URL following the standard modifier key behavior
* ( e . g . meta - click == new background tab , meta - shift - click == new front tab ,
* shift - click == new window , no modifier == frontmost tab
* /
2017-01-30 19:01:04 +00:00
this . loadURI = function ( uris , event ) {
2011-02-09 03:22:06 +00:00
if ( typeof uris === "string" ) {
uris = [ uris ] ;
2011-01-30 09:44:01 +00:00
}
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < uris . length ; i ++ ) {
let uri = uris [ i ] ;
2011-02-09 03:22:06 +00:00
// Ignore javascript: and data: URIs
if ( uri . match ( /^(javascript|data):/ ) ) {
return ;
2011-01-30 09:44:01 +00:00
}
2019-12-16 19:49:47 +00:00
if ( uri . match ( /^(chrome|resource):/ ) ) {
Zotero . openInViewer ( uri ) ;
2018-08-17 06:18:35 +00:00
continue ;
2011-02-09 03:22:06 +00:00
}
2011-01-30 09:44:01 +00:00
2018-08-17 06:18:35 +00:00
// Handle no-content zotero: URLs (e.g., zotero://select) without opening viewer
if ( uri . startsWith ( 'zotero:' ) ) {
let nsIURI = Services . io . newURI ( uri , null , null ) ;
let handler = Components . classes [ "@mozilla.org/network/protocol;1?name=zotero" ]
. getService ( ) ;
let extension = handler . wrappedJSObject . getExtension ( nsIURI ) ;
if ( extension . noContent ) {
extension . doAction ( nsIURI ) ;
return ;
2011-02-09 03:22:06 +00:00
}
}
2018-08-17 06:18:35 +00:00
2020-04-06 08:52:37 +00:00
try {
Zotero . launchURL ( uri ) ;
}
catch ( e ) {
Zotero . logError ( e ) ;
}
2011-01-30 09:44:01 +00:00
}
}
2016-03-24 12:55:32 +00:00
function setItemsPaneMessage ( content , lock ) {
2011-01-30 09:44:01 +00:00
var elem = document . getElementById ( 'zotero-items-pane-message-box' ) ;
if ( elem . getAttribute ( 'locked' ) == 'true' ) {
return ;
}
2016-03-24 12:55:32 +00:00
elem . textContent = '' ;
if ( typeof content == 'string' ) {
let contentParts = content . split ( "\n\n" ) ;
for ( let part of contentParts ) {
var desc = document . createElement ( 'description' ) ;
desc . appendChild ( document . createTextNode ( part ) ) ;
elem . appendChild ( desc ) ;
}
2011-01-30 09:44:01 +00:00
}
2016-03-24 12:55:32 +00:00
else {
elem . appendChild ( content ) ;
2011-01-30 09:44:01 +00:00
}
// Make message permanent
if ( lock ) {
elem . setAttribute ( 'locked' , true ) ;
}
document . getElementById ( 'zotero-items-pane-content' ) . selectedIndex = 1 ;
}
function clearItemsPaneMessage ( ) {
// If message box is locked, don't clear
var box = document . getElementById ( 'zotero-items-pane-message-box' ) ;
if ( box . getAttribute ( 'locked' ) == 'true' ) {
return ;
}
document . getElementById ( 'zotero-items-pane-content' ) . selectedIndex = 0 ;
}
2016-03-24 12:55:32 +00:00
this . setItemPaneMessage = function ( content ) {
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
document . getElementById ( 'zotero-item-pane-content' ) . selectedIndex = 0 ;
2016-03-24 12:55:32 +00:00
var elem = document . getElementById ( 'zotero-item-pane-message-box' ) ;
elem . textContent = '' ;
if ( typeof content == 'string' ) {
let contentParts = content . split ( "\n\n" ) ;
for ( let part of contentParts ) {
let desc = document . createElement ( 'description' ) ;
desc . appendChild ( document . createTextNode ( part ) ) ;
elem . appendChild ( desc ) ;
}
}
else {
elem . appendChild ( content ) ;
}
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
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
/ * *
2015-05-26 01:47:06 +00:00
* @ return { Promise < Integer | null | false > } - The id of the new note in non - popup mode , null in
* popup mode ( where a note isn 't created immediately), or false if library isn' t editable
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
* /
this . newNote = Zotero . Promise . coroutine ( function * ( popup , parentKey , text , citeURI ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
2015-05-26 01:47:06 +00:00
return false ;
2011-01-30 09:44:01 +00:00
}
2015-05-26 01:47:06 +00:00
if ( popup ) {
2011-01-30 09:44:01 +00:00
// TODO: _text_
var c = this . getSelectedCollection ( ) ;
if ( c ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . openNoteWindow ( null , c . id , parentKey ) ;
2011-01-30 09:44:01 +00:00
}
else {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . openNoteWindow ( null , null , parentKey ) ;
2011-01-30 09:44:01 +00:00
}
2015-05-26 01:47:06 +00:00
return null ;
}
if ( ! text ) {
text = '' ;
2011-01-30 09:44:01 +00:00
}
2015-05-26 01:47:06 +00:00
text = text . trim ( ) ;
if ( text ) {
text = '<blockquote'
+ ( citeURI ? ' cite="' + citeURI + '"' : '' )
+ '>' + Zotero . Utilities . text2html ( text ) + "</blockquote>" ;
}
var item = new Zotero . Item ( 'note' ) ;
item . libraryID = this . getSelectedLibraryID ( ) ;
item . setNote ( text ) ;
if ( parentKey ) {
item . parentKey = parentKey ;
}
2015-11-15 22:41:21 +00:00
else if ( this . collectionsView . selectedTreeRow . isCollection ( ) ) {
item . addToCollection ( this . collectionsView . selectedTreeRow . ref . id ) ;
2015-05-26 01:47:06 +00:00
}
2021-05-12 07:17:06 +00:00
var itemID = yield item . saveTx ( {
notifierData : {
autoSyncDelay : Zotero . Notes . AUTO _SYNC _DELAY
}
} ) ;
2015-05-26 01:47:06 +00:00
yield this . selectItem ( itemID ) ;
document . getElementById ( 'zotero-note-editor' ) . focus ( ) ;
return itemID ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
/ * *
* Creates a child note for the selected item or the selected item ' s parent
*
* @ return { Promise }
* /
this . newChildNote = function ( popup ) {
var selected = this . getSelectedItems ( ) [ 0 ] ;
var parentKey = selected . parentItemKey ;
parentKey = parentKey ? parentKey : selected . key ;
this . newNote ( popup , parentKey ) ;
2011-01-30 09:44:01 +00:00
}
2018-08-17 06:18:35 +00:00
// TODO: Move to server_connector
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . addSelectedTextToCurrentNote = Zotero . Promise . coroutine ( function * ( ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var text = event . currentTarget . ownerDocument . popupNode . ownerDocument . defaultView . getSelection ( ) . toString ( ) ;
var uri = event . currentTarget . ownerDocument . popupNode . ownerDocument . location . href ;
2011-01-30 09:44:01 +00:00
if ( ! text ) {
return false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
text = text . trim ( ) ;
2011-01-30 09:44:01 +00:00
if ( ! text . length ) {
return false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
text = '<blockquote' + ( uri ? ' cite="' + uri + '"' : '' ) + '>'
+ Zotero . Utilities . text2html ( text ) + "</blockquote>" ;
2011-01-30 09:44:01 +00:00
var items = this . getSelectedItems ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2011-01-30 09:44:01 +00:00
if ( this . itemsView . selection . count == 1 && items [ 0 ] && items [ 0 ] . isNote ( ) ) {
2020-08-25 18:22:23 +00:00
var note = items [ 0 ] . note ;
2011-01-30 09:44:01 +00:00
items [ 0 ] . setNote ( note + text ) ;
2015-05-10 08:20:47 +00:00
yield items [ 0 ] . saveTx ( ) ;
2011-01-30 09:44:01 +00:00
var noteElem = document . getElementById ( 'zotero-note-editor' )
noteElem . focus ( ) ;
return true ;
}
return false ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2017-12-11 07:23:15 +00:00
this . openNoteWindow = function ( itemID , col , parentKey ) {
2021-06-30 13:26:14 +00:00
var item = Zotero . Items . get ( itemID ) ;
var type = Zotero . Libraries . get ( item . libraryID ) . libraryType ;
2021-06-30 13:48:55 +00:00
if ( ! this . canEdit ( ) && ( type == 'group' && ! Zotero . enablePDFBuildForGroups || ! Zotero . isPDFBuild ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var name = null ;
if ( itemID ) {
2017-12-11 07:23:15 +00:00
let w = this . findNoteWindow ( itemID ) ;
if ( w ) {
w . focus ( ) ;
return ;
}
2011-01-30 09:44:01 +00:00
// Create a name for this window so we can focus it later
//
// Collection is only used on new notes, so we don't need to
// include it in the name
name = 'zotero-note-' + itemID ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var io = { itemID : itemID , collectionID : col , parentItemKey : parentKey } ;
2014-06-05 04:53:44 +00:00
window . openDialog ( 'chrome://zotero/content/note.xul' , name , 'chrome,resizable,centerscreen,dialog=false' , io ) ;
2011-01-30 09:44:01 +00:00
}
2017-12-11 07:23:15 +00:00
this . findNoteWindow = function ( itemID ) {
var name = 'zotero-note-' + itemID ;
var wm = Services . wm ;
var e = wm . getEnumerator ( 'zotero:note' ) ;
while ( e . hasMoreElements ( ) ) {
var w = e . getNext ( ) ;
if ( w . name == name ) {
return w ;
}
}
} ;
2021-02-09 13:11:49 +00:00
this . onNoteWindowClosed = async function ( itemID , noteText ) {
var item = Zotero . Items . get ( itemID ) ;
item . setNote ( noteText ) ;
await item . saveTx ( ) ;
// If note is still selected, show the editor again when the note window closes
var selectedItems = this . getSelectedItems ( true ) ;
if ( selectedItems . length == 1 && itemID == selectedItems [ 0 ] ) {
ZoteroItemPane . onNoteSelected ( item , this . collectionsView . editable ) ;
}
} ;
2017-12-11 07:23:15 +00:00
2020-08-26 14:58:03 +00:00
this . openBackupNoteWindow = function ( itemID ) {
2021-06-30 13:26:14 +00:00
var item = Zotero . Items . get ( itemID ) ;
var type = Zotero . Libraries . get ( item . libraryID ) . libraryType ;
2021-06-30 13:48:55 +00:00
if ( ! this . canEdit ( ) && ( type == 'group' && ! Zotero . enablePDFBuildForGroups || ! Zotero . isPDFBuild ) ) {
2020-08-26 14:58:03 +00:00
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var name = null ;
if ( itemID ) {
let w = this . findBackupNoteWindow ( itemID ) ;
if ( w ) {
w . focus ( ) ;
return ;
2019-03-28 18:52:22 +00:00
}
2020-08-26 14:58:03 +00:00
// Create a name for this window so we can focus it later
//
// Collection is only used on new notes, so we don't need to
// include it in the name
name = 'zotero-backup-note-' + itemID ;
2019-03-28 18:52:22 +00:00
}
2017-12-11 07:23:15 +00:00
2020-08-26 14:58:03 +00:00
var io = { itemID : itemID } ;
window . openDialog ( 'chrome://zotero/content/noteBackup.xul' , name , 'chrome,resizable,centerscreen,dialog=false' , io ) ;
}
this . findBackupNoteWindow = function ( itemID ) {
var name = 'zotero-backup-note-' + itemID ;
var wm = Services . wm ;
var e = wm . getEnumerator ( 'zotero:note' ) ;
while ( e . hasMoreElements ( ) ) {
var w = e . getNext ( ) ;
if ( w . name == name ) {
return w ;
}
2017-12-11 07:23:15 +00:00
}
} ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . addAttachmentFromURI = Zotero . Promise . method ( function ( link , itemID ) {
2011-06-16 18:17:06 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2014-12-16 16:20:55 +00:00
var io = { } ;
2015-03-16 19:17:45 +00:00
window . openDialog ( 'chrome://zotero/content/attachLink.xul' ,
2014-12-16 16:20:55 +00:00
'zotero-attach-uri-dialog' , 'centerscreen, modal' , io ) ;
2015-03-16 19:17:45 +00:00
if ( ! io . out ) return ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
return Zotero . Attachments . linkFromURL ( {
2015-03-16 19:17:45 +00:00
url : io . out . link ,
parentItemID : itemID ,
title : io . out . title
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
} ) ;
2011-06-16 18:17:06 +00:00
2019-08-24 08:25:51 +00:00
this . addAttachmentFromDialog = async function ( link , parentItemID ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . getCollectionTreeRow ( ) ;
2015-04-26 06:22:46 +00:00
if ( link ) {
if ( collectionTreeRow . isWithinGroup ( ) ) {
Zotero . alert ( null , "" , "Linked files cannot be added to group libraries." ) ;
2015-05-29 05:07:23 +00:00
return ;
2015-04-26 06:22:46 +00:00
}
else if ( collectionTreeRow . isPublications ( ) ) {
Zotero . alert (
null ,
Zotero . getString ( 'general.error' ) ,
Zotero . getString ( 'publications.error.linkedFilesCannotBeAdded' )
) ;
2015-05-29 05:07:23 +00:00
return ;
2015-04-26 06:22:46 +00:00
}
2011-01-30 09:44:01 +00:00
}
// TODO: disable in menu
if ( ! this . canEditFiles ( ) ) {
this . displayCannotEditLibraryFilesMessage ( ) ;
return ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var libraryID = collectionTreeRow . ref . libraryID ;
2011-01-30 09:44:01 +00:00
2019-08-24 08:25:51 +00:00
var fp = new FilePicker ( ) ;
fp . init ( window , Zotero . getString ( 'pane.item.attachments.select' ) , fp . modeOpenMultiple ) ;
fp . appendFilters ( fp . filterAll ) ;
2011-01-30 09:44:01 +00:00
2019-08-24 08:25:51 +00:00
if ( await fp . show ( ) != fp . returnOK ) {
2018-02-27 06:40:07 +00:00
return ;
}
2019-08-24 08:25:51 +00:00
var files = fp . files ;
2018-03-01 02:43:18 +00:00
var addedItems = [ ] ;
2018-02-27 06:40:07 +00:00
var collection ;
var fileBaseName ;
if ( parentItemID ) {
// If only one item is being added, automatic renaming is enabled, and the parent item
// doesn't have any other non-HTML file attachments, rename the file.
// This should be kept in sync with itemTreeView::drop().
2019-02-27 03:23:43 +00:00
if ( files . length == 1 && Zotero . Attachments . shouldAutoRenameFile ( link ) ) {
2018-02-27 06:40:07 +00:00
let parentItem = Zotero . Items . get ( parentItemID ) ;
if ( ! parentItem . numNonHTMLFileAttachments ( ) ) {
2019-08-24 08:25:51 +00:00
fileBaseName = await Zotero . Attachments . getRenamedFileBaseNameIfAllowedType (
2018-02-27 06:40:07 +00:00
parentItem , files [ 0 ]
) ;
2015-05-23 08:25:47 +00:00
}
2018-02-27 06:40:07 +00:00
}
}
// If not adding to an item, add to the current collection
else {
collection = this . getSelectedCollection ( true ) ;
}
for ( let file of files ) {
2018-03-01 02:43:18 +00:00
let item ;
2018-02-27 06:40:07 +00:00
if ( link ) {
// Rename linked file, with unique suffix if necessary
try {
if ( fileBaseName ) {
let ext = Zotero . File . getExtension ( file ) ;
2019-08-24 08:25:51 +00:00
let newName = await Zotero . File . rename (
2018-02-27 06:40:07 +00:00
file ,
fileBaseName + ( ext ? '.' + ext : '' ) ,
{
unique : true
}
) ;
// Update path in case the name was changed to be unique
file = OS . Path . join ( OS . Path . dirname ( file ) , newName ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
}
2011-01-30 09:44:01 +00:00
}
2018-02-27 06:40:07 +00:00
catch ( e ) {
Zotero . logError ( e ) ;
}
2019-08-24 08:25:51 +00:00
item = await Zotero . Attachments . linkFromFile ( {
2018-02-27 06:40:07 +00:00
file ,
parentItemID ,
collections : collection ? [ collection ] : undefined
} ) ;
}
else {
if ( file . endsWith ( ".lnk" ) ) {
let win = Services . wm . getMostRecentWindow ( "navigator:browser" ) ;
win . ZoteroPane . displayCannotAddShortcutMessage ( file ) ;
continue ;
}
2019-08-24 08:25:51 +00:00
item = await Zotero . Attachments . importFromFile ( {
2018-02-27 06:40:07 +00:00
file ,
libraryID ,
fileBaseName ,
parentItemID ,
collections : collection ? [ collection ] : undefined
} ) ;
2011-01-30 09:44:01 +00:00
}
2018-03-01 02:43:18 +00:00
addedItems . push ( item ) ;
}
// Automatically retrieve metadata for top-level PDFs
if ( ! parentItemID ) {
Zotero . RecognizePDF . autoRecognizeItems ( addedItems ) ;
2011-01-30 09:44:01 +00:00
}
2019-08-24 08:25:51 +00:00
} ;
2011-01-30 09:44:01 +00:00
2018-08-07 19:40:19 +00:00
this . findPDFForSelectedItems = async function ( ) {
2018-08-07 08:08:47 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2018-10-06 04:17:08 +00:00
await Zotero . Attachments . addAvailablePDFs ( this . getSelectedItems ( ) ) ;
2018-08-07 08:08:47 +00:00
} ;
2011-08-13 04:51:40 +00:00
/ * *
* Shows progress dialog for a webpage / snapshot save request
* /
function _showPageSaveStatus ( title ) {
var progressWin = new Zotero . ProgressWindow ( ) ;
progressWin . changeHeadline ( Zotero . getString ( 'ingester.scraping' ) ) ;
var icon = 'chrome://zotero/skin/treeitem-webpage.png' ;
progressWin . addLines ( title , icon )
progressWin . show ( ) ;
progressWin . startCloseTimer ( ) ;
}
2011-01-30 09:44:01 +00:00
/ * *
* @ param { Document } doc
* @ param { String | Integer } [ itemType = 'webpage' ] Item type id or name
* @ param { Boolean } [ saveSnapshot ] Force saving or non - saving of a snapshot ,
* regardless of automaticSnapshots pref
2015-11-15 22:41:21 +00:00
* @ return { Promise < Zotero . Item > | false }
2011-01-30 09:44:01 +00:00
* /
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . addItemFromDocument = Zotero . Promise . coroutine ( function * ( doc , itemType , saveSnapshot , row ) {
2011-08-13 04:51:40 +00:00
_showPageSaveStatus ( doc . title ) ;
2011-01-30 09:44:01 +00:00
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
saveSnapshot = saveSnapshot || ( saveSnapshot !== false && Zotero . Prefs . get ( 'automaticSnapshots' ) ) ;
// TODO: this, needless to say, is a temporary hack
if ( itemType == 'temporaryPDFHack' ) {
itemType = null ;
var isPDF = false ;
2013-04-21 01:48:28 +00:00
if ( doc . title . indexOf ( 'application/pdf' ) != - 1 || Zotero . Attachments . isPDFJS ( doc )
|| doc . contentType == 'application/pdf' ) {
2011-01-30 09:44:01 +00:00
isPDF = true ;
}
else {
var ios = Components . classes [ "@mozilla.org/network/io-service;1" ] .
getService ( Components . interfaces . nsIIOService ) ;
try {
var uri = ios . newURI ( doc . location , null , null ) ;
if ( uri . fileName && uri . fileName . match ( /pdf$/ ) ) {
isPDF = true ;
}
}
catch ( e ) {
Zotero . debug ( e ) ;
Components . utils . reportError ( e ) ;
}
}
if ( isPDF && saveSnapshot ) {
//
// Duplicate newItem() checks here
//
2017-01-14 23:01:51 +00:00
if ( Zotero . DB . inTransaction ( ) ) {
yield Zotero . DB . waitForTransaction ( ) ;
}
2011-01-30 09:44:01 +00:00
// Currently selected row
2011-08-13 04:51:40 +00:00
if ( row === undefined && this . collectionsView && this . collectionsView . selection ) {
2011-01-30 09:44:01 +00:00
row = this . collectionsView . selection . currentIndex ;
}
2011-08-13 04:51:40 +00:00
if ( row && ! this . canEdit ( row ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryMessage ( ) ;
2015-11-15 22:41:21 +00:00
return false ;
2011-01-30 09:44:01 +00:00
}
if ( row !== undefined ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . getRow ( row ) ;
var libraryID = collectionTreeRow . ref . libraryID ;
2011-01-30 09:44:01 +00:00
}
else {
2015-03-10 06:27:56 +00:00
var libraryID = Zotero . Libraries . userLibraryID ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = null ;
2011-01-30 09:44:01 +00:00
}
//
//
//
2015-07-23 05:24:37 +00:00
if ( row && ! this . canEditFiles ( row ) ) {
2011-01-30 09:44:01 +00:00
this . displayCannotEditLibraryFilesMessage ( ) ;
2015-11-15 22:41:21 +00:00
return false ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( collectionTreeRow && collectionTreeRow . isCollection ( ) ) {
var collectionID = collectionTreeRow . ref . id ;
2011-01-30 09:44:01 +00:00
}
else {
var collectionID = false ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let item = yield Zotero . Attachments . importFromDocument ( {
libraryID : libraryID ,
document : doc ,
2016-03-21 05:30:16 +00:00
collections : collectionID ? [ collectionID ] : [ ]
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield this . selectItem ( item . id ) ;
2015-11-15 22:41:21 +00:00
return false ;
2011-01-30 09:44:01 +00:00
}
}
// Save web page item by default
if ( ! itemType ) {
itemType = 'webpage' ;
}
var data = {
title : doc . title ,
url : doc . location . href ,
accessDate : "CURRENT_TIMESTAMP"
}
itemType = Zotero . ItemTypes . getID ( itemType ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var item = yield this . newItem ( itemType , data , row ) ;
2016-10-26 06:27:31 +00:00
var filesEditable = Zotero . Libraries . get ( item . libraryID ) . filesEditable ;
2011-01-30 09:44:01 +00:00
if ( saveSnapshot ) {
var link = false ;
if ( link ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield Zotero . Attachments . linkFromDocument ( {
document : doc ,
parentItemID : item . id
} ) ;
2011-01-30 09:44:01 +00:00
}
else if ( filesEditable ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield Zotero . Attachments . importFromDocument ( {
document : doc ,
parentItemID : item . id
} ) ;
2011-01-30 09:44:01 +00:00
}
}
2015-11-15 22:41:21 +00:00
return item ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2018-03-01 02:43:18 +00:00
/ * *
* @ return { Zotero . Item | false } - The saved item , or false if item can ' t be saved
* /
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . addItemFromURL = Zotero . Promise . coroutine ( function * ( url , itemType , saveSnapshot , row ) {
2012-01-17 04:07:56 +00:00
url = Zotero . Utilities . resolveIntermediateURL ( url ) ;
2014-08-09 22:01:28 +00:00
let [ mimeType , hasNativeHandler ] = yield Zotero . MIME . getMIMETypeFromURL ( url ) ;
// If native type, save using a hidden browser
if ( hasNativeHandler ) {
var deferred = Zotero . Promise . defer ( ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2014-08-09 22:01:28 +00:00
var processor = function ( doc ) {
2017-08-19 10:57:54 +00:00
return ZoteroPane _Local . addItemFromDocument ( doc , itemType , saveSnapshot , row )
2018-03-01 02:43:18 +00:00
. then ( function ( item ) {
deferred . resolve ( item )
2017-08-19 10:57:54 +00:00
} ) ;
2014-08-09 22:01:28 +00:00
} ;
2018-08-16 08:39:50 +00:00
try {
yield Zotero . HTTP . processDocuments ( [ url ] , processor ) ;
} catch ( e ) {
2014-08-09 22:01:28 +00:00
Zotero . debug ( e , 1 ) ;
deferred . reject ( e ) ;
}
return deferred . promise ;
}
// Otherwise create placeholder item, attach attachment, and update from that
else {
// TODO: this, needless to say, is a temporary hack
if ( itemType == 'temporaryPDFHack' ) {
itemType = null ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2014-08-09 22:01:28 +00:00
if ( mimeType == 'application/pdf' ) {
//
// Duplicate newItem() checks here
//
2017-01-14 23:01:51 +00:00
if ( Zotero . DB . inTransaction ( ) ) {
yield Zotero . DB . waitForTransaction ( ) ;
}
2011-01-30 09:44:01 +00:00
2014-08-09 22:01:28 +00:00
// Currently selected row
if ( row === undefined ) {
row = ZoteroPane _Local . collectionsView . selection . currentIndex ;
}
if ( ! ZoteroPane _Local . canEdit ( row ) ) {
ZoteroPane _Local . displayCannotEditLibraryMessage ( ) ;
2018-03-01 02:43:18 +00:00
return false ;
2011-01-30 09:44:01 +00:00
}
2014-08-09 22:01:28 +00:00
if ( row !== undefined ) {
var collectionTreeRow = ZoteroPane _Local . collectionsView . getRow ( row ) ;
var libraryID = collectionTreeRow . ref . libraryID ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
}
else {
2015-03-10 06:27:56 +00:00
var libraryID = Zotero . Libraries . userLibraryID ;
2014-08-09 22:01:28 +00:00
var collectionTreeRow = null ;
2011-01-30 09:44:01 +00:00
}
2014-08-09 22:01:28 +00:00
//
//
//
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2014-08-09 22:01:28 +00:00
if ( ! ZoteroPane _Local . canEditFiles ( row ) ) {
ZoteroPane _Local . displayCannotEditLibraryFilesMessage ( ) ;
2018-03-01 02:43:18 +00:00
return false ;
2014-08-09 22:01:28 +00:00
}
if ( collectionTreeRow && collectionTreeRow . isCollection ( ) ) {
var collectionID = collectionTreeRow . ref . id ;
}
else {
var collectionID = false ;
2011-01-30 09:44:01 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
2016-04-23 02:45:37 +00:00
let attachmentItem = yield Zotero . Attachments . importFromURL ( {
libraryID ,
url ,
collections : collectionID ? [ collectionID ] : undefined ,
contentType : mimeType
} ) ;
this . selectItem ( attachmentItem . id )
2018-03-01 02:43:18 +00:00
return attachmentItem ;
2014-08-09 22:01:28 +00:00
}
2011-01-30 09:44:01 +00:00
}
2014-08-09 22:01:28 +00:00
if ( ! itemType ) {
itemType = 'webpage' ;
}
var item = yield ZoteroPane _Local . newItem ( itemType , { } , row )
2016-10-26 06:27:31 +00:00
var filesEditable = Zotero . Libraries . get ( item . libraryID ) . filesEditable ;
2014-08-09 22:01:28 +00:00
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
if ( saveSnapshot || ( saveSnapshot !== false && Zotero . Prefs . get ( 'automaticSnapshots' ) ) ) {
var link = false ;
if ( link ) {
//Zotero.Attachments.linkFromURL(doc, item.id);
}
else if ( filesEditable ) {
2016-04-23 02:45:37 +00:00
var attachmentItem = yield Zotero . Attachments . importFromURL ( {
url ,
parentItemID : item . id ,
contentType : mimeType
} ) ;
2014-08-09 22:01:28 +00:00
if ( attachmentItem ) {
item . setField ( 'title' , attachmentItem . getField ( 'title' ) ) ;
item . setField ( 'url' , attachmentItem . getField ( 'url' ) ) ;
item . setField ( 'accessDate' , attachmentItem . getField ( 'accessDate' ) ) ;
2015-05-10 08:20:47 +00:00
yield item . saveTx ( ) ;
2014-08-09 22:01:28 +00:00
}
}
}
2018-03-01 02:43:18 +00:00
return item ;
2014-08-09 22:01:28 +00:00
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . viewItems = Zotero . Promise . coroutine ( function * ( items , event ) {
2012-11-01 05:53:31 +00:00
if ( items . length > 1 ) {
if ( ! event || ( ! event . metaKey && ! event . shiftKey ) ) {
2021-04-26 19:49:52 +00:00
event = { metaKey : true , shiftKey : true , originalEvent : event } ;
2012-11-01 05:53:31 +00:00
}
}
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < items . length ; i ++ ) {
let item = items [ i ] ;
2012-11-01 05:53:31 +00:00
if ( item . isRegularItem ( ) ) {
2013-01-31 22:44:51 +00:00
// Prefer local file attachments
2012-11-01 05:53:31 +00:00
var uri = Components . classes [ "@mozilla.org/network/standard-url;1" ]
. createInstance ( Components . interfaces . nsIURI ) ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let attachment = yield item . getBestAttachment ( ) ;
if ( attachment ) {
yield this . viewAttachment ( attachment . id , event ) ;
2012-11-02 02:14:08 +00:00
continue ;
2012-11-01 05:53:31 +00:00
}
2013-01-31 22:44:51 +00:00
// Fall back to URI field, then DOI
2012-11-01 05:53:31 +00:00
var uri = item . getField ( 'url' ) ;
if ( ! uri ) {
var doi = item . getField ( 'DOI' ) ;
if ( doi ) {
// Pull out DOI, in case there's a prefix
doi = Zotero . Utilities . cleanDOI ( doi ) ;
if ( doi ) {
uri = "http://dx.doi.org/" + encodeURIComponent ( doi ) ;
}
}
}
2013-01-31 22:17:53 +00:00
2013-01-31 22:44:51 +00:00
// Fall back to first attachment link
if ( ! uri ) {
2014-08-11 04:34:20 +00:00
let attachmentID = item . getAttachments ( ) [ 0 ] ;
if ( attachmentID ) {
let attachment = yield Zotero . Items . getAsync ( attachmentID ) ;
if ( attachment ) uri = attachment . getField ( 'url' ) ;
2013-01-31 22:17:53 +00:00
}
}
2012-11-01 05:53:31 +00:00
if ( uri ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . loadURI ( uri , event ) ;
2012-11-01 05:53:31 +00:00
}
}
else if ( item . isNote ( ) ) {
2021-06-30 13:26:14 +00:00
var type = Zotero . Libraries . get ( item . libraryID ) . libraryType ;
2021-06-30 13:48:55 +00:00
if ( ! this . collectionsView . editable && ( type == 'group' && ! Zotero . enablePDFBuildForGroups || ! Zotero . isPDFBuild ) ) {
2012-11-01 05:53:31 +00:00
continue ;
}
2020-11-03 16:29:51 +00:00
document . getElementById ( 'zotero-view-note-button' ) . doCommand ( ) ;
2012-11-01 05:53:31 +00:00
}
else if ( item . isAttachment ( ) ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
yield this . viewAttachment ( item . id , event ) ;
2012-11-01 05:53:31 +00:00
}
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2012-11-01 05:53:31 +00:00
2018-08-19 05:36:23 +00:00
this . viewAttachment = Zotero . serial ( async function ( itemIDs , event , noLocateOnMissing , forceExternalViewer ) {
2011-10-15 05:50:30 +00:00
// If view isn't editable, don't show Locate button, since the updated
// path couldn't be sent back up
2011-11-16 22:55:18 +00:00
if ( ! this . collectionsView . editable ) {
2011-10-15 05:50:30 +00:00
noLocateOnMissing = true ;
}
2011-07-11 22:19:10 +00:00
if ( typeof itemIDs != "object" ) itemIDs = [ itemIDs ] ;
2011-01-30 09:44:01 +00:00
2011-07-11 22:19:10 +00:00
// If multiple items, set up event so we open in new tab
if ( itemIDs . length > 1 ) {
if ( ! event || ( ! event . metaKey && ! event . shiftKey ) ) {
event = { "metaKey" : true , "shiftKey" : true } ;
}
2011-01-30 09:44:01 +00:00
}
2019-03-28 18:52:22 +00:00
var launchFile = async ( path , contentType , itemID ) => {
2020-12-14 10:23:26 +00:00
// Fix blank PDF attachment MIME type
if ( ! contentType ) {
let item = await Zotero . Items . getAsync ( itemID ) ;
let path = await item . getFilePathAsync ( ) ;
let type = 'application/pdf' ;
if ( Zotero . MIME . sniffForMIMEType ( await Zotero . File . getSample ( path ) ) == type ) {
contentType = type ;
item . attachmentContentType = type ;
await item . saveTx ( ) ;
}
}
2018-08-19 05:36:23 +00:00
// Custom PDF handler
if ( contentType === 'application/pdf' ) {
2021-02-10 08:24:42 +00:00
let item = await Zotero . Items . getAsync ( itemID ) ;
let library = Zotero . Libraries . get ( item . libraryID ) ;
// TEMP
2021-06-30 13:48:55 +00:00
if ( Zotero . isPDFBuild && ( library . libraryType == 'user' || Zotero . enablePDFBuildForGroups ) ) {
2021-04-26 19:49:52 +00:00
let originalEvent = event && event . originalEvent || event ;
this . viewPDF ( itemID , originalEvent && originalEvent . shiftKey ) ;
2021-02-10 08:24:42 +00:00
return ;
}
2018-08-19 05:36:23 +00:00
let pdfHandler = Zotero . Prefs . get ( "fileHandler.pdf" ) ;
if ( pdfHandler ) {
if ( await OS . File . exists ( pdfHandler ) ) {
Zotero . launchFileWithApplication ( path , pdfHandler ) ;
return ;
}
else {
Zotero . logError ( ` ${ pdfHandler } not found -- launching file normally ` ) ;
}
}
}
Zotero . launchFile ( path ) ;
} ;
2015-03-17 19:14:17 +00:00
for ( let i = 0 ; i < itemIDs . length ; i ++ ) {
let itemID = itemIDs [ i ] ;
2018-08-19 05:36:23 +00:00
let item = await Zotero . Items . getAsync ( itemID ) ;
2011-11-14 08:42:06 +00:00
if ( ! item . isAttachment ( ) ) {
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
throw new Error ( "Item " + itemID + " is not an attachment" ) ;
2011-07-11 22:19:10 +00:00
}
2020-03-07 07:25:44 +00:00
Zotero . debug ( "Viewing attachment " + item . libraryKey ) ;
2011-11-14 08:42:06 +00:00
if ( item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) {
this . loadURI ( item . getField ( 'url' ) , event ) ;
2011-07-11 22:19:10 +00:00
continue ;
}
2020-09-10 08:34:10 +00:00
let isLinkedFile = ! item . isStoredFileAttachment ( ) ;
2018-08-19 05:36:23 +00:00
let path = item . getFilePath ( ) ;
2019-06-11 10:46:46 +00:00
if ( ! path ) {
2019-10-19 03:33:40 +00:00
ZoteroPane _Local . showAttachmentNotFoundDialog (
item . id ,
path ,
{
noLocate : true ,
notOnServer : true ,
linkedFile : isLinkedFile
}
) ;
2019-06-11 10:46:46 +00:00
return ;
}
2018-08-19 05:36:23 +00:00
let fileExists = await OS . File . exists ( path ) ;
// If the file is an evicted iCloud Drive file, launch that to trigger a download.
// As of 10.13.6, launching an .icloud file triggers the download and opens the
// associated program (e.g., Preview) but won't actually open the file, so we wait a bit
// for the original file to exist and then continue with regular file opening below.
//
// To trigger eviction for testing, use Cirrus from https://eclecticlight.co/downloads/
if ( ! fileExists && Zotero . isMac && isLinkedFile ) {
// Get the path to the .icloud file
2018-08-19 06:41:45 +00:00
let iCloudPath = Zotero . File . getEvictedICloudPath ( path ) ;
2018-08-19 05:36:23 +00:00
if ( await OS . File . exists ( iCloudPath ) ) {
Zotero . debug ( "Triggering download of iCloud file" ) ;
2019-03-28 18:52:22 +00:00
await launchFile ( iCloudPath , item . attachmentContentType , itemID ) ;
2018-08-19 05:36:23 +00:00
let time = new Date ( ) ;
let maxTime = 5000 ;
let revealed = false ;
while ( true ) {
// If too much time has elapsed, just reveal the file in Finder instead
if ( new Date ( ) - time > maxTime ) {
Zotero . debug ( ` File not available after ${ maxTime } -- revealing instead ` ) ;
try {
Zotero . File . reveal ( iCloudPath ) ;
revealed = true ;
2018-03-06 00:29:03 +00:00
}
2018-08-19 05:36:23 +00:00
catch ( e ) {
Zotero . logError ( e ) ;
// In case the main file became available
try {
Zotero . File . reveal ( path ) ;
revealed = true ;
}
catch ( e ) {
Zotero . logError ( e ) ;
}
2018-03-06 00:29:03 +00:00
}
2018-08-19 05:36:23 +00:00
break ;
}
// Wait a bit for the download and check again
await Zotero . Promise . delay ( 250 ) ;
Zotero . debug ( "Checking for downloaded file" ) ;
if ( await OS . File . exists ( path ) ) {
Zotero . debug ( "File is ready" ) ;
fileExists = true ;
break ;
2018-03-06 00:29:03 +00:00
}
}
2018-08-19 05:36:23 +00:00
if ( revealed ) {
continue ;
}
2011-01-30 09:44:01 +00:00
}
}
2018-08-19 05:36:23 +00:00
2020-03-07 07:25:44 +00:00
let fileSyncingEnabled = Zotero . Sync . Storage . Local . getEnabledForLibrary ( item . libraryID ) ;
let redownload = false ;
// TEMP: If file is queued for download, download first. Starting in 5.0.85, files
// modified remotely get marked as SYNC_STATE_FORCE_DOWNLOAD, causing them to get
// downloaded at sync time even in download-as-needed mode, but this causes files
// modified previously to be downloaded on open.
if ( fileExists
&& ! isLinkedFile
&& fileSyncingEnabled
&& ( item . attachmentSyncState == Zotero . Sync . Storage . Local . SYNC _STATE _TO _DOWNLOAD ) ) {
Zotero . debug ( "File exists but is queued for download -- re-downloading" ) ;
redownload = true ;
}
if ( fileExists && ! redownload ) {
2018-08-19 05:36:23 +00:00
Zotero . debug ( "Opening " + path ) ;
Zotero . Notifier . trigger ( 'open' , 'file' , item . id ) ;
2020-12-28 05:19:23 +00:00
await launchFile ( path , item . attachmentContentType , item . id ) ;
2018-08-19 05:36:23 +00:00
continue ;
2011-07-11 22:19:10 +00:00
}
2018-08-19 05:36:23 +00:00
2020-03-07 07:25:44 +00:00
if ( isLinkedFile || ! fileSyncingEnabled ) {
2019-10-19 03:33:40 +00:00
this . showAttachmentNotFoundDialog (
itemID ,
path ,
{
noLocate : noLocateOnMissing ,
notOnServer : false ,
linkedFile : isLinkedFile
}
) ;
2018-08-19 05:36:23 +00:00
return ;
}
try {
2020-03-07 07:25:44 +00:00
let results = await Zotero . Sync . Runner . downloadFile ( item ) ;
if ( ! results || ! results . localChanges ) {
Zotero . debug ( "Download failed -- opening existing file" ) ;
}
2018-08-19 05:36:23 +00:00
}
catch ( e ) {
// TODO: show error somewhere else
Zotero . debug ( e , 1 ) ;
ZoteroPane _Local . syncAlert ( e ) ;
return ;
}
if ( ! await item . getFilePathAsync ( ) ) {
2019-10-19 03:33:40 +00:00
ZoteroPane _Local . showAttachmentNotFoundDialog (
item . id ,
path ,
{
noLocate : noLocateOnMissing ,
notOnServer : true
}
) ;
2018-08-19 05:36:23 +00:00
return ;
}
Zotero . Notifier . trigger ( 'redraw' , 'item' , [ ] ) ;
2020-03-07 07:25:44 +00:00
Zotero . debug ( "Opening " + path ) ;
Zotero . Notifier . trigger ( 'open' , 'file' , item . id ) ;
2020-12-28 05:19:23 +00:00
await launchFile ( path , item . attachmentContentType , item . id ) ;
2011-01-30 09:44:01 +00:00
}
2018-08-19 05:36:23 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2020-09-24 14:47:47 +00:00
this . viewPDF = function ( itemID , openWindow ) {
Zotero . Reader . open ( itemID , null , openWindow ) ;
2019-03-28 18:52:22 +00:00
} ;
2011-01-30 09:44:01 +00:00
2012-01-20 20:23:06 +00:00
/ * *
2013-04-11 08:28:38 +00:00
* @ deprecated
2012-01-20 20:23:06 +00:00
* /
this . launchFile = function ( file ) {
2013-04-11 08:28:38 +00:00
Zotero . debug ( "ZoteroPane.launchFile() is deprecated -- use Zotero.launchFile()" , 2 ) ;
Zotero . launchFile ( file ) ;
2012-01-20 20:23:06 +00:00
}
/ * *
2017-08-10 02:49:42 +00:00
* @ deprecated
2012-01-20 20:23:06 +00:00
* /
this . launchURL = function ( url ) {
2017-08-11 09:50:31 +00:00
Zotero . debug ( "ZoteroPane.launchURL() is deprecated -- use Zotero.launchURL()" , 2 ) ;
return Zotero . launchURL ( url ) ;
2012-01-20 20:23:06 +00:00
}
2011-01-30 09:44:01 +00:00
function viewSelectedAttachment ( event , noLocateOnMissing )
{
if ( this . itemsView && this . itemsView . selection . count == 1 ) {
this . viewAttachment ( this . getSelectedItems ( true ) [ 0 ] , event , noLocateOnMissing ) ;
}
}
2018-08-19 06:41:45 +00:00
this . showAttachmentInFilesystem = async function ( itemID , noLocateOnMissing ) {
var attachment = await Zotero . Items . getAsync ( itemID )
if ( attachment . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) return ;
var path = attachment . getFilePath ( ) ;
var fileExists = await OS . File . exists ( path ) ;
// If file doesn't exist but an evicted iCloud Drive file does, reveal that instead
2020-09-10 08:34:10 +00:00
if ( ! fileExists && Zotero . isMac && ! attachment . isStoredFileAttachment ( ) ) {
2018-08-19 06:41:45 +00:00
let iCloudPath = Zotero . File . getEvictedICloudPath ( path ) ;
if ( await OS . File . exists ( iCloudPath ) ) {
path = iCloudPath ;
fileExists = true ;
2011-01-30 09:44:01 +00:00
}
}
2018-08-19 06:41:45 +00:00
if ( ! fileExists ) {
2019-10-19 03:33:40 +00:00
this . showAttachmentNotFoundDialog (
attachment . id ,
path ,
{
noLocate : noLocateOnMissing ,
notOnServer : false ,
linkedFile : attachment . isLinkedFileAttachment ( )
}
) ;
2018-08-19 06:41:45 +00:00
return ;
}
let file = Zotero . File . pathToFile ( path ) ;
try {
Zotero . debug ( "Revealing " + file . path ) ;
file . reveal ( ) ;
}
catch ( e ) {
2019-08-25 10:51:11 +00:00
// On platforms that don't support nsIFile.reveal() (e.g. Linux),
2018-08-19 06:41:45 +00:00
// launch the parent directory
2019-08-25 10:51:11 +00:00
Zotero . launchFile ( file . parent ) ;
2018-08-19 06:41:45 +00:00
}
Zotero . Notifier . trigger ( 'open' , 'file' , attachment . id ) ;
} ;
2011-01-30 09:44:01 +00:00
Deasyncification :back: :cry:
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).
What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.
The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).
If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 21:05:51 +00:00
this . showPublicationsWizard = function ( items ) {
2015-04-26 06:22:46 +00:00
var io = {
hasFiles : false ,
hasNotes : false ,
hasRights : null // 'all', 'some', or 'none'
} ;
var allItemsHaveRights = true ;
var noItemsHaveRights = true ;
// Determine whether any/all items have files, notes, or Rights values
for ( let i = 0 ; i < items . length ; i ++ ) {
let item = items [ i ] ;
// Files
if ( ! io . hasFiles && item . numAttachments ( ) ) {
Deasyncification :back: :cry:
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).
What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.
The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).
If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 21:05:51 +00:00
let attachmentIDs = item . getAttachments ( ) ;
io . hasFiles = Zotero . Items . get ( attachmentIDs ) . some (
attachment => attachment . isFileAttachment ( )
) ;
2015-04-26 06:22:46 +00:00
}
// Notes
if ( ! io . hasNotes && item . numNotes ( ) ) {
io . hasNotes = true ;
}
// Rights
if ( item . getField ( 'rights' ) ) {
noItemsHaveRights = false ;
}
else {
allItemsHaveRights = false ;
}
}
io . hasRights = allItemsHaveRights ? 'all' : ( noItemsHaveRights ? 'none' : 'some' ) ;
window . openDialog ( 'chrome://zotero/content/publicationsDialog.xul' , '' , 'chrome,modal' , io ) ;
return io . license ? io : false ;
Deasyncification :back: :cry:
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).
What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.
The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).
If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 21:05:51 +00:00
} ;
2015-04-26 06:22:46 +00:00
2011-01-30 09:44:01 +00:00
/ * *
2012-10-31 09:22:58 +00:00
* Test if the user can edit the currently selected view
2011-01-30 09:44:01 +00:00
*
* @ param { Integer } [ row ]
*
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEdit = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . getRow ( row ) ;
return collectionTreeRow . editable ;
2011-01-30 09:44:01 +00:00
}
/ * *
2012-10-31 09:22:58 +00:00
* Test if the user can edit the parent library of the selected view
*
* @ param { Integer } [ row ]
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEditLibrary = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . getRow ( row ) ;
2016-07-17 19:13:05 +00:00
return Zotero . Libraries . get ( collectionTreeRow . ref . libraryID ) . editable ;
2012-10-31 09:22:58 +00:00
}
/ * *
* Test if the user can edit the currently selected library / collection
2011-01-30 09:44:01 +00:00
*
* @ param { Integer } [ row ]
*
* @ return { Boolean } TRUE if user can edit , FALSE if not
* /
this . canEditFiles = function ( row ) {
// Currently selected row
if ( row === undefined ) {
row = this . collectionsView . selection . currentIndex ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
var collectionTreeRow = this . collectionsView . getRow ( row ) ;
return collectionTreeRow . filesEditable ;
2011-01-30 09:44:01 +00:00
}
this . displayCannotEditLibraryMessage = function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
2012-01-20 22:51:00 +00:00
ps . alert ( null , "" , Zotero . getString ( 'save.error.cannotMakeChangesToCollection' ) ) ;
2011-01-30 09:44:01 +00:00
}
this . displayCannotEditLibraryFilesMessage = function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
2012-01-20 22:51:00 +00:00
ps . alert ( null , "" , Zotero . getString ( 'save.error.cannotAddFilesToCollection' ) ) ;
2011-01-30 09:44:01 +00:00
}
2015-12-10 06:09:40 +00:00
this . displayCannotAddToMyPublicationsMessage = function ( ) {
var ps = Components . classes [ "@mozilla.org/embedcomp/prompt-service;1" ]
. getService ( Components . interfaces . nsIPromptService ) ;
ps . alert ( null , "" , Zotero . getString ( 'save.error.cannotAddToMyPublications' ) ) ;
}
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
// TODO: Figure out a functioning way to get the original path and just copy the real file
this . displayCannotAddShortcutMessage = function ( path ) {
Zotero . alert (
null ,
Zotero . getString ( "general.error" ) ,
Zotero . getString ( "file.error.cannotAddShortcut" ) + ( path ? "\n\n" + path : "" )
) ;
}
2019-10-19 03:33:40 +00:00
this . showAttachmentNotFoundDialog = function ( itemID , path , options = { } ) {
var { noLocate , notOnServer , linkedFile } = options ;
2011-01-30 09:44:01 +00:00
2016-05-15 08:24:00 +00:00
var title = Zotero . getString ( 'pane.item.attachments.fileNotFound.title' ) ;
2019-10-19 03:33:40 +00:00
var text = Zotero . getString (
'pane.item.attachments.fileNotFound.text1' + ( path ? '.path' : '' )
)
+ ( path ? "\n\n" + path : '' )
+ "\n\n"
2016-05-15 08:24:00 +00:00
+ Zotero . getString (
2019-10-19 03:33:40 +00:00
'pane.item.attachments.fileNotFound.text2.'
+ ( options . linkedFile
? 'linked'
: 'stored' + ( notOnServer ? '.notOnServer' : '' )
) ,
2016-05-15 08:24:00 +00:00
[ ZOTERO _CONFIG . CLIENT _NAME , ZOTERO _CONFIG . DOMAIN _NAME ]
) ;
2019-10-19 03:33:40 +00:00
var supportURL = options . linkedFile
? 'https://www.zotero.org/support/kb/missing_linked_file'
: 'https://www.zotero.org/support/kb/files_not_syncing' ;
var ps = Services . prompt ;
2011-01-30 09:44:01 +00:00
// Don't show Locate button
if ( noLocate ) {
2019-10-19 03:33:40 +00:00
let buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _OK
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _IS _STRING ;
2016-05-15 08:24:00 +00:00
let index = ps . confirmEx ( null ,
title ,
text ,
buttonFlags ,
null ,
Zotero . getString ( 'general.moreInformation' ) ,
null , null , { }
2011-01-30 09:44:01 +00:00
) ;
2016-05-15 08:24:00 +00:00
if ( index == 1 ) {
this . loadURI ( supportURL , { metaKey : true , shiftKey : true } ) ;
}
2011-01-30 09:44:01 +00:00
return ;
}
2019-10-19 03:33:40 +00:00
var buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _CANCEL
+ ps . BUTTON _POS _2 * ps . BUTTON _TITLE _IS _STRING ;
2011-01-30 09:44:01 +00:00
var index = ps . confirmEx ( null ,
2016-05-15 08:24:00 +00:00
title ,
text ,
buttonFlags ,
Zotero . getString ( 'general.locate' ) ,
null ,
2019-10-19 03:33:40 +00:00
Zotero . getString ( 'general.moreInformation' )
, null , { }
2016-05-15 08:24:00 +00:00
) ;
2011-01-30 09:44:01 +00:00
if ( index == 0 ) {
this . relinkAttachment ( itemID ) ;
}
2016-05-15 08:24:00 +00:00
else if ( index == 2 ) {
this . loadURI ( supportURL , { metaKey : true , shiftKey : true } ) ;
}
2011-01-30 09:44:01 +00:00
}
2012-12-11 20:16:40 +00:00
this . syncAlert = function ( e ) {
2015-10-29 07:41:54 +00:00
e = Zotero . Sync . Runner . parseError ( e ) ;
2018-08-12 06:29:58 +00:00
var ps = Services . prompt ;
var buttonText = e . dialogButtonText ;
var buttonCallback = e . dialogButtonCallback ;
if ( e . errorType == 'warning' || e . errorType == 'error' ) {
let title = Zotero . getString ( 'general.' + e . errorType ) ;
// TODO: Display header in bold
let msg = ( e . dialogHeader ? e . dialogHeader + '\n\n' : '' ) + e . message ;
2012-12-11 20:16:40 +00:00
2018-08-12 06:29:58 +00:00
if ( e . errorType == 'warning' || buttonText === null ) {
2012-12-11 20:16:40 +00:00
ps . alert ( null , title , e . message ) ;
return ;
}
2018-08-12 06:29:58 +00:00
if ( ! buttonText ) {
buttonText = Zotero . getString ( 'errorReport.reportError' ) ;
buttonCallback = function ( ) {
2012-12-11 20:16:40 +00:00
ZoteroPane . reportErrors ( ) ;
} ;
}
2018-08-12 06:29:58 +00:00
let buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _OK
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _IS _STRING ;
let index = ps . confirmEx (
2012-12-11 20:16:40 +00:00
null ,
title ,
2018-08-12 06:29:58 +00:00
msg ,
2012-12-11 20:16:40 +00:00
buttonFlags ,
"" ,
buttonText ,
"" , null , { }
) ;
if ( index == 1 ) {
2018-08-12 06:29:58 +00:00
setTimeout ( buttonCallback , 1 ) ;
2012-12-11 20:16:40 +00:00
}
}
2018-08-12 06:29:58 +00:00
// Upgrade message
2015-07-20 21:27:55 +00:00
else if ( e . errorType == 'upgrade' ) {
2012-12-11 20:16:40 +00:00
ps . alert ( null , "" , e . message ) ;
2018-08-12 06:29:58 +00:00
return ;
2012-12-11 20:16:40 +00:00
}
} ;
2018-03-01 02:43:18 +00:00
this . recognizeSelected = function ( ) {
Zotero . RecognizePDF . recognizeItems ( ZoteroPane . getSelectedItems ( ) ) ;
2018-10-05 05:56:46 +00:00
Zotero . ProgressQueues . get ( 'recognize' ) . getDialog ( ) . open ( ) ;
2018-03-01 02:43:18 +00:00
} ;
2018-03-08 08:50:51 +00:00
this . unrecognizeSelected = async function ( ) {
var items = ZoteroPane . getSelectedItems ( ) ;
for ( let item of items ) {
await Zotero . RecognizePDF . unrecognize ( item ) ;
}
} ;
this . reportMetadataForSelected = async function ( ) {
2018-04-19 08:35:03 +00:00
let items = ZoteroPane . getSelectedItems ( ) ;
if ( ! items . length ) return ;
2018-03-08 08:50:51 +00:00
2018-04-19 08:35:03 +00:00
let input = { value : '' } ;
2018-08-13 15:14:18 +00:00
let confirmed ;
do {
confirmed = Services . prompt . prompt (
null ,
Zotero . getString ( 'recognizePDF.reportMetadata' ) ,
Zotero . getString ( 'general.describeProblem' ) ,
input , null , { }
) ;
} while ( confirmed && ! input . value ) ;
if ( ! confirmed ) return ;
2018-04-19 08:35:03 +00:00
try {
await Zotero . RecognizePDF . report ( items [ 0 ] , input . value ) ;
2018-03-08 08:50:51 +00:00
Zotero . alert (
window ,
Zotero . getString ( 'general.submitted' ) ,
Zotero . getString ( 'general.thanksForHelpingImprove' , Zotero . clientName )
) ;
}
2018-04-19 08:35:03 +00:00
catch ( e ) {
Zotero . logError ( e ) ;
2018-03-08 08:50:51 +00:00
Zotero . alert (
window ,
Zotero . getString ( 'general.error' ) ,
Zotero . getString ( 'general.invalidResponseServer' )
) ;
}
} ;
2020-11-20 21:17:48 +00:00
this . createParentItemsFromSelected = async function ( ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2020-12-23 22:37:08 +00:00
let items = this . getSelectedItems ( ) ;
2020-11-20 21:17:48 +00:00
2020-12-23 22:37:08 +00:00
if ( items . length > 1 ) {
for ( let i = 0 ; i < items . length ; i ++ ) {
let item = items [ i ] ;
if ( ! item . isTopLevelItem ( ) || item . isRegularItem ( ) ) {
throw new Error ( 'Item ' + item . id + ' is not a top-level attachment' ) ;
}
2020-11-20 21:17:48 +00:00
2020-12-23 22:37:08 +00:00
await this . createEmptyParent ( item ) ;
}
2020-11-20 21:17:48 +00:00
}
else {
2020-12-23 22:37:08 +00:00
// Ask for an identifier if there is only one item
let item = items [ 0 ] ;
if ( ! item . isAttachment ( ) || ! item . isTopLevelItem ( ) ) {
throw new Error ( 'Item ' + item . id + ' is not a top-level attachment' ) ;
}
let io = { dataIn : { item } , dataOut : null } ;
window . openDialog ( 'chrome://zotero/content/createParentDialog.xul' , '' , 'chrome,modal,centerscreen' , io ) ;
if ( ! io . dataOut ) {
return false ;
}
// If we made a parent, attach the child
if ( io . dataOut . parent ) {
await Zotero . DB . executeTransaction ( async function ( ) {
item . parentID = io . dataOut . parent . id ;
await item . save ( ) ;
} ) ;
}
// If they clicked manual entry then make a dummy parent
else {
this . createEmptyParent ( item ) ;
}
2011-01-30 09:44:01 +00:00
}
2020-11-20 21:17:48 +00:00
} ;
2021-02-24 06:38:15 +00:00
this . createNoteFromAnnotationsForAttachment = async function ( attachment ) {
2021-01-12 08:39:30 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2021-02-24 06:38:15 +00:00
var note = await Zotero . EditorInstance . createNoteFromAnnotations (
attachment . getAnnotations ( ) , attachment . parentID
) ;
await this . selectItem ( note . id ) ;
} ;
this . createNoteFromAnnotationsFromSelected = async function ( ) {
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var item = this . getSelectedItems ( ) [ 0 ] ;
var attachment ;
if ( item . isRegularItem ( ) ) {
attachment = Zotero . Items . get ( item . getAttachments ( ) )
. find ( x => x . isPDFAttachment ( ) && x . numAnnotations ( ) ) ;
}
else if ( item . isFileAttachment ( ) ) {
attachment = item ;
}
else {
throw new Error ( "Not a regular item or file attachment" ) ;
}
return this . createNoteFromAnnotationsForAttachment ( attachment ) ;
2021-01-12 08:39:30 +00:00
} ;
2019-03-28 18:52:22 +00:00
2020-12-23 22:37:08 +00:00
this . createEmptyParent = async function ( item ) {
await Zotero . DB . executeTransaction ( async function ( ) {
// TODO: remove once there are no top-level web attachments
if ( item . isWebAttachment ( ) ) {
var parent = new Zotero . Item ( 'webpage' ) ;
}
else {
var parent = new Zotero . Item ( 'document' ) ;
}
parent . libraryID = item . libraryID ;
parent . setField ( 'title' , item . getField ( 'title' ) ) ;
if ( item . isWebAttachment ( ) ) {
parent . setField ( 'accessDate' , item . getField ( 'accessDate' ) ) ;
parent . setField ( 'url' , item . getField ( 'url' ) ) ;
}
let itemID = await parent . save ( ) ;
item . parentID = itemID ;
await item . save ( ) ;
} ) ;
} ;
2019-03-28 18:52:22 +00:00
this . exportPDF = async function ( itemID ) {
let item = await Zotero . Items . getAsync ( itemID ) ;
2021-03-03 20:30:29 +00:00
if ( ! item || ! item . isPDFAttachment ( ) ) {
throw new Error ( 'Item ' + itemID + ' is not a PDF attachment' ) ;
2019-03-28 18:52:22 +00:00
}
let filename = item . attachmentFilename ;
var fp = new FilePicker ( ) ;
2021-03-03 20:30:29 +00:00
// TODO: Localize
fp . init ( window , "Export File" , fp . modeSave ) ;
2019-03-28 18:52:22 +00:00
fp . appendFilter ( "PDF" , "*.pdf" ) ;
fp . defaultString = filename ;
var rv = await fp . show ( ) ;
if ( rv === fp . returnOK || rv === fp . returnReplace ) {
let outputFile = fp . file ;
2020-09-21 11:33:11 +00:00
await Zotero . PDFWorker . export ( item . id , outputFile , true ) ;
2019-03-28 18:52:22 +00:00
}
} ;
2011-01-30 09:44:01 +00:00
2021-03-03 20:30:29 +00:00
// TEMP: Quick implementation
this . exportSelectedFiles = async function ( ) {
var items = ZoteroPane . getSelectedItems ( )
. reduce ( ( arr , item ) => {
if ( item . isPDFAttachment ( ) ) {
return arr . concat ( [ item ] ) ;
}
if ( item . isRegularItem ( ) ) {
return arr . concat ( item . getAttachments ( )
. map ( x => Zotero . Items . get ( x ) )
. filter ( x => x . isPDFAttachment ( ) ) ) ;
}
return arr ;
} , [ ] ) ;
// Deduplicate, in case parent and child items are both selected
items = [ ... new Set ( items ) ] ;
if ( ! items . length ) return ;
if ( items . length == 1 ) {
await this . exportPDF ( items [ 0 ] . id ) ;
return ;
}
var fp = new FilePicker ( ) ;
// TODO: Localize
fp . init ( window , "Export Files" , fp . modeGetFolder ) ;
var rv = await fp . show ( ) ;
if ( rv === fp . returnOK || rv === fp . returnReplace ) {
let folder = fp . file ;
for ( let item of items ) {
let outputFile = OS . Path . join ( folder , item . attachmentFilename ) ;
if ( await OS . File . exists ( outputFile ) ) {
let newNSIFile = Zotero . File . pathToFile ( outputFile ) ;
newNSIFile . createUnique ( Components . interfaces . nsIFile . NORMAL _FILE _TYPE , 0o644 ) ;
outputFile = newNSIFile . path ;
newNSIFile . remove ( null ) ;
}
await Zotero . PDFWorker . export ( item . id , outputFile , true ) ;
}
}
} ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
this . renameSelectedAttachmentsFromParents = Zotero . Promise . coroutine ( function * ( ) {
// TEMP: fix
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var items = this . getSelectedItems ( ) ;
for ( var i = 0 ; i < items . length ; i ++ ) {
var item = items [ i ] ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
if ( ! item . isAttachment ( ) || item . isTopLevelItem ( ) || item . attachmentLinkMode == Zotero . Attachments . LINK _MODE _LINKED _URL ) {
2011-03-08 23:46:01 +00:00
throw ( 'Item ' + itemID + ' is not a child file attachment in ZoteroPane_Local.renameAttachmentFromParent()' ) ;
2011-01-30 09:44:01 +00:00
}
var file = item . getFile ( ) ;
if ( ! file ) {
continue ;
}
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
let parentItemID = item . parentItemID ;
let parentItem = yield Zotero . Items . getAsync ( parentItemID ) ;
var newName = Zotero . Attachments . getFileBaseNameFromItem ( parentItem ) ;
2011-01-30 09:44:01 +00:00
2012-04-04 08:44:04 +00:00
var ext = file . leafName . match ( /\.[^\.]+$/ ) ;
2011-01-30 09:44:01 +00:00
if ( ext ) {
2012-04-04 08:44:04 +00:00
newName = newName + ext ;
2011-01-30 09:44:01 +00:00
}
2017-11-01 05:02:23 +00:00
var renamed = yield item . renameAttachmentFile ( newName , false , true ) ;
2011-01-30 09:44:01 +00:00
if ( renamed !== true ) {
Zotero . debug ( "Could not rename file (" + renamed + ")" ) ;
continue ;
}
item . setField ( 'title' , newName ) ;
2015-05-10 08:20:47 +00:00
yield item . saveTx ( ) ;
2011-01-30 09:44:01 +00:00
}
return true ;
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
} ) ;
2011-01-30 09:44:01 +00:00
2019-08-18 20:22:39 +00:00
this . convertLinkedFilesToStoredFiles = async function ( ) {
if ( ! this . canEdit ( ) || ! this . canEditFiles ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
var items = this . getSelectedItems ( ) ;
var attachments = new Set ( ) ;
for ( let item of items ) {
// Add all child link attachments of regular items
if ( item . isRegularItem ( ) ) {
for ( let id of item . getAttachments ( ) ) {
let attachment = await Zotero . Items . getAsync ( id ) ;
if ( attachment . isLinkedFileAttachment ( ) ) {
attachments . add ( attachment ) ;
}
}
}
// And all selected link attachments
else if ( item . isLinkedFileAttachment ( ) ) {
attachments . add ( item ) ;
}
}
var num = attachments . size ;
var ps = Services . prompt ;
var buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _CANCEL ;
var deleteOriginal = { } ;
var index = ps . confirmEx ( null ,
Zotero . getString ( 'attachment.convertToStored.title' , [ num ] , num ) ,
Zotero . getString ( 'attachment.convertToStored.text' , [ num ] , num ) ,
buttonFlags ,
Zotero . getString ( 'general.continue' ) ,
null ,
null ,
Zotero . getString ( 'attachment.convertToStored.deleteOriginal' , [ num ] , num ) ,
deleteOriginal
) ;
if ( index != 0 ) {
return ;
}
for ( let item of attachments ) {
try {
let converted = await Zotero . Attachments . convertLinkedFileToStoredFile (
item ,
{
move : deleteOriginal . value
}
) ;
if ( ! converted ) {
// Not found
continue ;
}
}
catch ( e ) {
Zotero . logError ( e ) ;
continue ;
}
}
} ;
2019-08-24 08:25:51 +00:00
this . relinkAttachment = async function ( itemID ) {
2011-01-30 09:44:01 +00:00
if ( ! this . canEdit ( ) ) {
this . displayCannotEditLibraryMessage ( ) ;
return ;
}
2016-10-22 19:02:15 +00:00
var item = Zotero . Items . get ( itemID ) ;
2011-01-30 09:44:01 +00:00
if ( ! item ) {
2016-10-22 19:02:15 +00:00
throw new Error ( 'Item ' + itemID + ' not found in ZoteroPane_Local.relinkAttachment()' ) ;
2011-01-30 09:44:01 +00:00
}
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
while ( true ) {
2019-08-24 08:25:51 +00:00
let fp = new FilePicker ( ) ;
fp . init ( window , Zotero . getString ( 'pane.item.attachments.select' ) , fp . modeOpen ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
2016-10-22 19:02:15 +00:00
var file = item . getFilePath ( ) ;
if ( ! file ) {
Zotero . debug ( "Invalid path" , 2 ) ;
break ;
}
2017-07-21 22:33:36 +00:00
2019-08-24 08:25:51 +00:00
var dir = await Zotero . File . getClosestDirectory ( file ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
if ( dir ) {
2019-08-24 08:25:51 +00:00
fp . displayDirectory = dir ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
}
2019-08-24 08:25:51 +00:00
fp . appendFilters ( fp . filterAll ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
2019-08-24 08:25:51 +00:00
if ( await fp . show ( ) == fp . returnOK ) {
let file = Zotero . File . pathToFile ( fp . file ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
// Disallow hidden files
// TODO: Display a message
if ( file . leafName . startsWith ( '.' ) ) {
continue ;
}
// Disallow Windows shortcuts
if ( file . leafName . endsWith ( ".lnk" ) ) {
this . displayCannotAddShortcutMessage ( file . path ) ;
continue ;
}
2019-08-24 08:25:51 +00:00
await item . relinkAttachmentFile ( file . path ) ;
File Issues: Greatest Hits, 2006-2015
- When relinking a missing stored file, copy it into the attachment's
storage directory automatically
- Previously, selecting a file outside the attachment subdir would
just result in a missing attachment, since it only looks for stored
files within the subdir
- Display an error message if a Windows shortcut (.lnk) is added via
drag-and-drop or via a file dialog on non-Windows systems, until we
can figure out how to determine the original file
- Shortcuts can cause errors during syncing, for unclear reasons
- Neither nsIFile::copyToFollowingLinks() nor nsIFile::target work for
me to get the original file, even when nsIFile::isSymlink() returns
true
- Windows file dialogs seem to automatically resolve shortcuts, so
it's only an issue there for drag-and-drop
- Disallow hidden files from being selected in relink dialog
- I think some people on Windows with hidden files shown relink the
.zotero* files that show up when they click Locate, which causes
file sync errors. Which brings us to...
- Fix file sync errors for *.lnk and .zotero* files
- Ignore existing .zotero* attachment files, treating the files as
missing instead to encourage relinking
- Strip leading period in getValidFileName() to prevent added files from
being hidden
- This allows hidden files to be added explicitly; they just won't
stay that way in the storage directory
(These things should have tests, but that will have to happen on the 5.0
branch.)
2015-06-24 09:38:41 +00:00
break ;
}
break ;
2011-01-30 09:44:01 +00:00
}
2019-08-24 08:25:51 +00:00
} ;
2011-01-30 09:44:01 +00:00
2017-11-03 08:36:42 +00:00
this . updateReadLabel = function ( ) {
var items = this . getSelectedItems ( ) ;
var isUnread = false ;
for ( let item of items ) {
if ( ! item . isRead ) {
isUnread = true ;
break ;
}
}
ZoteroItemPane . setReadLabel ( ! isUnread ) ;
} ;
var itemReadPromise ;
this . startItemReadTimeout = function ( feedItemID ) {
if ( itemReadPromise ) {
itemReadPromise . cancel ( ) ;
2014-11-07 04:10:59 +00:00
}
2017-11-03 08:36:42 +00:00
const FEED _READ _TIMEOUT = 1000 ;
itemReadPromise = Zotero . Promise . delay ( FEED _READ _TIMEOUT )
. then ( async function ( ) {
itemReadPromise = null ;
// Check to make sure we're still on the same item
var items = this . getSelectedItems ( ) ;
if ( items . length != 1 || items [ 0 ] . id != feedItemID ) {
Zotero . debug ( items . length ) ;
Zotero . debug ( items [ 0 ] . id ) ;
Zotero . debug ( feedItemID ) ;
return ;
}
var feedItem = items [ 0 ] ;
if ( ! ( feedItem instanceof Zotero . FeedItem ) ) {
2014-12-15 05:07:37 +00:00
throw new Zotero . Promise . CancellationError ( 'Not a FeedItem' ) ;
}
2017-11-03 08:36:42 +00:00
if ( feedItem . isRead ) {
return ;
}
2014-11-07 04:10:59 +00:00
2017-11-03 08:36:42 +00:00
await feedItem . toggleRead ( true ) ;
ZoteroItemPane . setReadLabel ( true ) ;
} . bind ( this ) )
. catch ( function ( e ) {
2014-12-15 05:07:37 +00:00
if ( e instanceof Zotero . Promise . CancellationError ) {
Zotero . debug ( e . message ) ;
return ;
}
2017-11-03 08:36:42 +00:00
Zotero . logError ( e ) ;
2014-11-07 04:10:59 +00:00
} ) ;
}
2011-01-30 09:44:01 +00:00
function reportErrors ( ) {
var ww = Components . classes [ "@mozilla.org/embedcomp/window-watcher;1" ]
. getService ( Components . interfaces . nsIWindowWatcher ) ;
var data = {
2014-05-27 00:07:41 +00:00
msg : Zotero . getString ( 'errorReport.followingReportWillBeSubmitted' ) ,
errorData : Zotero . getErrors ( true ) ,
2011-01-30 09:44:01 +00:00
askForSteps : true
} ;
var io = { wrappedJSObject : { Zotero : Zotero , data : data } } ;
var win = ww . openWindow ( null , "chrome://zotero/content/errorReport.xul" ,
"zotero-error-report" , "chrome,centerscreen,modal" , io ) ;
}
2020-03-13 21:17:02 +00:00
this . displayErrorMessage = function ( popup ) {
Zotero . debug ( "ZoteroPane.displayErrorMessage() is deprecated -- use Zotero.crash() instead" ) ;
Zotero . crash ( popup ) ;
2011-01-30 09:44:01 +00:00
}
2011-02-10 01:53:15 +00:00
this . displayStartupError = function ( asPaneMessage ) {
2013-08-12 00:51:16 +00:00
if ( Zotero ) {
var errMsg = Zotero . startupError ;
var errFunc = Zotero . startupErrorHandler ;
}
2013-11-27 21:08:31 +00:00
var stringBundleService = Components . classes [ "@mozilla.org/intl/stringbundle;1" ]
. getService ( Components . interfaces . nsIStringBundleService ) ;
2017-05-26 05:37:54 +00:00
var src = 'chrome://zotero/locale/zotero.properties' ;
2017-07-09 10:56:56 +00:00
var stringBundle = stringBundleService . createBundle ( src ) ;
2013-11-27 21:08:31 +00:00
var title = stringBundle . GetStringFromName ( 'general.error' ) ;
2013-08-12 00:51:16 +00:00
if ( ! errMsg ) {
var errMsg = stringBundle . GetStringFromName ( 'startupError' ) ;
}
if ( errFunc ) {
errFunc ( ) ;
}
else {
// TODO: Add a better error page/window here with reporting
// instructions
// window.loadURI('chrome://zotero/content/error.xul');
//if(asPaneMessage) {
// ZoteroPane_Local.setItemsPaneMessage(errMsg, true);
//} else {
2020-03-13 21:17:02 +00:00
Zotero . alert ( null , title , errMsg ) ;
2013-08-12 00:51:16 +00:00
//}
2011-02-10 01:53:15 +00:00
}
}
2019-06-07 05:13:42 +00:00
/ * *
* Show a retraction banner if there are retracted items that we haven ' t warned about
* /
this . showRetractionBanner = async function ( items ) {
var items ;
try {
items = JSON . parse ( Zotero . Prefs . get ( 'retractions.recentItems' ) ) ;
}
catch ( e ) {
Zotero . Prefs . clear ( 'retractions.recentItems' ) ;
Zotero . logError ( e ) ;
return ;
}
if ( ! items . length ) {
return ;
}
items = await Zotero . Items . getAsync ( items ) ;
if ( ! items . length ) {
return ;
}
document . getElementById ( 'retracted-items-container' ) . removeAttribute ( 'collapsed' ) ;
var message = document . getElementById ( 'retracted-items-message' ) ;
var link = document . getElementById ( 'retracted-items-link' ) ;
var close = document . getElementById ( 'retracted-items-close' ) ;
var suffix = items . length > 1 ? 'multiple' : 'single' ;
message . textContent = Zotero . getString ( 'retraction.alert.' + suffix ) ;
link . textContent = Zotero . getString ( 'retraction.alert.view.' + suffix ) ;
2019-06-10 06:37:54 +00:00
link . onclick = async function ( ) {
2019-06-07 12:21:15 +00:00
this . hideRetractionBanner ( ) ;
2019-06-10 06:37:54 +00:00
// Select newly detected item if only one
if ( items . length == 1 ) {
await this . selectItem ( items [ 0 ] . id ) ;
}
2019-06-13 03:46:22 +00:00
// Otherwise select Retracted Items collection
else {
let libraryID = this . getSelectedLibraryID ( ) ;
await this . collectionsView . selectByID ( "R" + libraryID ) ;
}
2019-06-07 05:13:42 +00:00
} . bind ( this ) ;
close . onclick = function ( ) {
this . hideRetractionBanner ( ) ;
} . bind ( this ) ;
} ;
this . hideRetractionBanner = function ( ) {
document . getElementById ( 'retracted-items-container' ) . setAttribute ( 'collapsed' , true ) ;
Zotero . Prefs . clear ( 'retractions.recentItems' ) ;
} ;
2019-07-04 11:11:53 +00:00
this . promptToHideRetractionForReplacedItem = function ( item ) {
var ps = Services . prompt ;
var buttonFlags = ps . BUTTON _POS _0 * ps . BUTTON _TITLE _IS _STRING
+ ps . BUTTON _POS _1 * ps . BUTTON _TITLE _CANCEL ;
let index = ps . confirmEx (
null ,
Zotero . getString ( 'retraction.replacedItem.title' ) ,
Zotero . getString ( 'retraction.replacedItem.text1' )
+ "\n\n"
+ Zotero . getString ( 'retraction.replacedItem.text2' ) ,
buttonFlags ,
Zotero . getString ( 'retraction.replacedItem.button' ) ,
null ,
null ,
null ,
{ }
) ;
if ( index == 0 ) {
Zotero . Retractions . hideRetraction ( item ) ;
this . hideRetractionBanner ( ) ;
}
} ;
2016-05-28 00:57:29 +00:00
/ * *
* Sets the layout to either a three - vertical - pane layout and a layout where itemsPane is above itemPane
* /
this . updateLayout = function ( ) {
var layoutSwitcher = document . getElementById ( "zotero-layout-switcher" ) ;
var itemsSplitter = document . getElementById ( "zotero-items-splitter" ) ;
if ( Zotero . Prefs . get ( "layout" ) === "stacked" ) { // itemsPane above itemPane
layoutSwitcher . setAttribute ( "orient" , "vertical" ) ;
itemsSplitter . setAttribute ( "orient" , "vertical" ) ;
} else { // three-vertical-pane
layoutSwitcher . setAttribute ( "orient" , "horizontal" ) ;
itemsSplitter . setAttribute ( "orient" , "horizontal" ) ;
}
this . updateToolbarPosition ( ) ;
2019-11-13 10:28:03 +00:00
this . updateTagsBoxSize ( ) ;
2020-11-10 08:59:34 +00:00
ZoteroContextPane . update ( ) ;
2016-05-28 00:57:29 +00:00
}
2019-08-26 04:34:06 +00:00
2011-02-11 22:16:32 +00:00
/ * *
* Unserializes zotero - persist elements from preferences
* /
2016-04-04 10:33:15 +00:00
this . unserializePersist = function ( ) {
2011-09-06 01:26:13 +00:00
_unserialized = true ;
2011-02-11 22:16:32 +00:00
var serializedValues = Zotero . Prefs . get ( "pane.persist" ) ;
if ( ! serializedValues ) return ;
serializedValues = JSON . parse ( serializedValues ) ;
2020-04-10 19:50:19 +00:00
// Somehow all the columns can end up non-hidden, so fix that if it happens
var maxColumns = 30 ; // 31 as of 4/2020
var numColumns = Object . keys ( serializedValues )
. filter ( id => id . startsWith ( 'zotero-items-column-' ) && serializedValues [ id ] . hidden != "true" )
. length ;
var fixColumns = numColumns > maxColumns ;
if ( fixColumns ) {
Zotero . logError ( "Repairing corrupted pane.persist" ) ;
}
2011-02-11 22:16:32 +00:00
for ( var id in serializedValues ) {
var el = document . getElementById ( id ) ;
if ( ! el ) return ;
2020-04-10 19:50:19 +00:00
// In one case where this happened, all zotero-items-column- elements were present
// with just "ordinal" (and no "hidden"), and "zotero-items-tree" was set to
// {"current-view-group":"default"}. Clearing only the columns didn't work for some reason.
if ( fixColumns && ( id . startsWith ( 'zotero-items-column-' ) || id == 'zotero-items-tree' ) ) {
continue ;
}
2011-02-11 22:16:32 +00:00
var elValues = serializedValues [ id ] ;
for ( var attr in elValues ) {
2019-10-24 05:36:01 +00:00
// Ignore persisted collapsed state for collection and item pane splitters, since
// people close them by accident and don't know how to get them back
// TODO: Add a hidden pref to allow them to stay closed if people really want that?
if ( ( el . id == 'zotero-collections-splitter' || el . id == 'zotero-items-splitter' )
2019-11-22 06:51:11 +00:00
&& attr == 'state'
&& Zotero . Prefs . get ( 'reopenPanesOnRestart' ) ) {
2019-10-24 05:36:01 +00:00
continue ;
}
2011-02-11 22:16:32 +00:00
el . setAttribute ( attr , elValues [ attr ] ) ;
}
}
2011-02-11 22:39:13 +00:00
if ( this . itemsView ) {
// may not yet be initialized
try {
2016-04-04 10:33:15 +00:00
this . itemsView . sort ( ) ;
2011-02-11 22:39:13 +00:00
} catch ( e ) { } ;
}
2016-04-04 10:33:15 +00:00
} ;
2011-02-11 22:16:32 +00:00
/ * *
* Serializes zotero - persist elements to preferences
* /
2011-02-22 18:43:05 +00:00
this . serializePersist = function ( ) {
2011-09-06 01:26:13 +00:00
if ( ! _unserialized ) return ;
2011-02-11 22:16:32 +00:00
var serializedValues = { } ;
2015-03-17 19:14:17 +00:00
for ( let el of document . getElementsByAttribute ( "zotero-persist" , "*" ) ) {
2011-02-11 22:16:32 +00:00
if ( ! el . getAttribute ) continue ;
var id = el . getAttribute ( "id" ) ;
if ( ! id ) continue ;
var elValues = { } ;
2015-03-17 19:14:17 +00:00
for ( let attr of el . getAttribute ( "zotero-persist" ) . split ( /[\s,]+/ ) ) {
2016-06-13 08:56:39 +00:00
if ( el . hasAttribute ( attr ) ) {
elValues [ attr ] = el . getAttribute ( attr ) ;
}
2011-02-11 22:16:32 +00:00
}
serializedValues [ id ] = elValues ;
}
Zotero . Prefs . set ( "pane.persist" , JSON . stringify ( serializedValues ) ) ;
}
2011-02-13 03:51:24 +00:00
2017-07-07 07:20:06 +00:00
this . updateWindow = function ( ) {
var zoteroPane = document . getElementById ( 'zotero-pane' ) ;
// Must match value in overlay.css
var breakpoint = 1000 ;
var className = ` width- ${ breakpoint } ` ;
if ( window . innerWidth >= breakpoint ) {
zoteroPane . classList . add ( className ) ;
}
else {
zoteroPane . classList . remove ( className ) ;
}
} ;
2011-02-13 03:51:24 +00:00
/ * *
* Moves around the toolbar when the user moves around the pane
* /
this . updateToolbarPosition = function ( ) {
2016-05-28 00:57:29 +00:00
var paneStack = document . getElementById ( "zotero-pane-stack" ) ;
if ( paneStack . hidden ) return ;
var stackedLayout = Zotero . Prefs . get ( "layout" ) === "stacked" ;
2015-01-04 11:47:41 +00:00
var collectionsPane = document . getElementById ( "zotero-collections-pane" ) ;
var collectionsToolbar = document . getElementById ( "zotero-collections-toolbar" ) ;
var itemsPane = document . getElementById ( "zotero-items-pane" ) ;
var itemsToolbar = document . getElementById ( "zotero-items-toolbar" ) ;
var itemPane = document . getElementById ( "zotero-item-pane" ) ;
var itemToolbar = document . getElementById ( "zotero-item-toolbar" ) ;
2018-12-12 10:34:39 +00:00
var tagSelector = document . getElementById ( "zotero-tag-selector" ) ;
2015-01-04 11:47:41 +00:00
2019-03-28 09:19:41 +00:00
var collectionsPaneWidth = collectionsPane . boxObject . width + 'px' ;
collectionsToolbar . style . width = collectionsPaneWidth ;
tagSelector . style . maxWidth = collectionsPaneWidth ;
2015-01-04 11:47:41 +00:00
2016-05-28 00:57:29 +00:00
if ( stackedLayout || itemPane . collapsed ) {
// The itemsToolbar and itemToolbar share the same space, and it seems best to use some flex attribute from right (because there might be other icons appearing or vanishing).
2015-01-04 11:47:41 +00:00
itemsToolbar . setAttribute ( "flex" , "1" ) ;
itemToolbar . setAttribute ( "flex" , "0" ) ;
} else {
2016-05-28 00:57:29 +00:00
var itemsToolbarWidth = itemsPane . boxObject . width ;
if ( collectionsPane . collapsed ) {
itemsToolbarWidth -= collectionsToolbar . boxObject . width ;
}
2016-12-27 18:52:50 +00:00
// Not sure why this is necessary, but it keeps the search bar from overflowing into the
// right-hand pane
else {
itemsToolbarWidth -= 8 ;
}
2016-05-28 00:57:29 +00:00
itemsToolbar . style . width = itemsToolbarWidth + "px" ;
2015-01-04 11:47:41 +00:00
itemsToolbar . setAttribute ( "flex" , "0" ) ;
itemToolbar . setAttribute ( "flex" , "1" ) ;
}
2016-09-24 00:15:00 +00:00
// Allow item pane to shrink to available height in stacked mode, but don't expand to be too
// wide when there's no persisted width in non-stacked mode
2020-10-05 07:00:17 +00:00
itemPane . setAttribute ( "flex" , stackedLayout ? 1 : 0 ) ;
2019-03-28 09:19:41 +00:00
this . handleTagSelectorResize ( ) ;
2011-02-13 03:51:24 +00:00
}
2011-05-31 06:34:21 +00:00
2019-11-13 10:28:03 +00:00
/ * *
* Set an explicit height on the tags list to show a scroll bar if necessary
*
* This really should be be possible via CSS alone , but I couldn ' t get it to work , either
* because I was doing something wrong or because the XUL layout engine was messing with me .
* Revisit when we ' re all HTML .
* /
this . updateTagsBoxSize = function ( ) {
2020-11-03 16:29:51 +00:00
// TODO: We can probably remove this function
return ;
2019-11-13 10:28:03 +00:00
var pane = document . querySelector ( '#zotero-item-pane' ) ;
var header = document . querySelector ( '#zotero-item-pane .tags-box-header' ) ;
var list = document . querySelector ( '#zotero-item-pane .tags-box-list' ) ;
if ( pane && header && list ) {
let height = pane . getBoundingClientRect ( ) . height
- header . getBoundingClientRect ( ) . height
- 35 ; // a little padding
list . style . height = height + 'px' ;
}
} ;
2011-05-31 06:34:21 +00:00
/ * *
* Opens the about dialog
* /
this . openAboutDialog = function ( ) {
2021-03-29 05:34:24 +00:00
window . openDialog ( 'chrome://zotero/content/about.xul' , 'about' , 'chrome,centerscreen' ) ;
2011-05-31 06:34:21 +00:00
}
2011-06-14 00:36:21 +00:00
/ * *
* Adds or removes a function to be called when Zotero is reloaded by switching into or out of
* the connector
* /
this . addReloadListener = function ( /** @param {Function} **/ func ) {
if ( _reloadFunctions . indexOf ( func ) === - 1 ) _reloadFunctions . push ( func ) ;
}
2013-11-05 20:52:40 +00:00
/ * *
* Adds or removes a function to be called just before Zotero is reloaded by switching into or
* out of the connector
* /
this . addBeforeReloadListener = function ( /** @param {Function} **/ func ) {
if ( _beforeReloadFunctions . indexOf ( func ) === - 1 ) _beforeReloadFunctions . push ( func ) ;
}
2011-06-14 00:36:21 +00:00
/ * *
2011-07-03 04:33:37 +00:00
* Implements nsIObserver for Zotero reload
2011-06-14 00:36:21 +00:00
* /
2011-07-03 04:33:37 +00:00
var _reloadObserver = {
/ * *
* Called when Zotero is reloaded ( i . e . , if it is switched into or out of connector mode )
* /
2013-11-05 20:52:40 +00:00
"observe" : function ( aSubject , aTopic , aData ) {
if ( aTopic == "zotero-reloaded" ) {
Zotero . debug ( "Reloading Zotero pane" ) ;
2015-03-17 19:14:17 +00:00
for ( let func of _reloadFunctions ) func ( aData ) ;
2013-11-05 20:52:40 +00:00
} else if ( aTopic == "zotero-before-reload" ) {
Zotero . debug ( "Zotero pane caught before-reload event" ) ;
2015-03-17 19:14:17 +00:00
for ( let func of _beforeReloadFunctions ) func ( aData ) ;
2013-11-05 20:52:40 +00:00
}
2011-07-03 04:33:37 +00:00
}
} ;
2011-03-08 23:46:01 +00:00
}
/ * *
* Keep track of which ZoteroPane was local ( since ZoteroPane object might get swapped out for a
* tab ' s ZoteroPane )
* /
2011-06-16 18:17:06 +00:00
var ZoteroPane _Local = ZoteroPane ;