Commit graph

4837 commits

Author SHA1 Message Date
Dan Stillman
4f12c71e3e Fix intermittent NS_BASE_STREAM_CLOSED error? 2015-06-02 03:51:09 -04:00
Dan Stillman
dca29a06e3 Include params in DB error messages 2015-06-02 03:51:09 -04:00
Dan Stillman
1f643c1baa Fix skipNotifier option with DataObject::erase() 2015-06-02 03:51:09 -04:00
Dan Stillman
c5cfb6adfd Ignore 'synced' in Zotero.Item.fromJSON() 2015-06-01 22:45:13 -04:00
Dan Stillman
a740658452 Relations overhaul (requires new DB upgrade from 4.0)
Relations are now properties of collections and items rather than
first-class objects, stored in separate collectionRelations and
itemRelations tables with ids for subjects, with foreign keys to the
associated data objects.

Related items now use dc:relation relations rather than a separate table
(among other reasons, because API syncing won't necessarily sync both
items at the same time, so they can't be stored by id).

The UI assigns related-item relations bidirectionally, and checks for
related-item and linked-object relations are done unidirectionally by
default.

dc:isReplacedBy is now dc:replaces, so that the subject is an existing
object, and the predicate is now named
Zotero.Attachments.replacedItemPredicate.

Some additional work is still needed, notably around following
replaced-item relations, and migration needs to be tested more fully,
but this seems to mostly work.
2015-06-01 20:28:30 -04:00
Dan Stillman
b59fa1eed9 Store copy of changed object in _markFieldChange()
Otherwise a splice() on a stored array affects the calculation of what's
new.
2015-06-01 20:23:20 -04:00
Dan Stillman
5fc524bcb2 Generalize Zotero.CachedTypes.add(), and tweak item charset handling
.attachmentCharset on an item now requires a string, not a charsetID.
(It accepted a charset before but didn't quite work right.)
2015-06-01 20:23:20 -04:00
Dan Stillman
bf0d2a1bf4 Fix collectionTreeView::expandToCollection() 2015-06-01 15:31:57 -04:00
Simon Kornblith
9bb01d737c Merge branch '4.0' into sjk/659 2015-06-01 00:03:20 -04:00
Dan Stillman
5ba344516e Update PDF tool handling in tests
The test runner now downloads and caches the PDF tools for the current
platform within the test data directory and only redownloads them when
out of date, and it updates the download URL so that the full-text code
pulls from the cache directory via a file:// URL.

The installPDFTools() support function now installs the files directly
instead of going through the prefs, and a new uninstallPDFTools()
function removes the tools. Since the presence of the PDF tools can
affect other tests, tests that need the tools should install them in a
before() and uninstall them in an after(), leaving most tests to run
without PDF indexing.

This also adds a callback to the waitForWindow() support function. If a
modal dialog is opened, it blocks the next promise handler from running,
so a callback has to be used to interact with and close the dialog
immediately.
2015-05-31 23:50:26 -04:00
Dan Stillman
55d27273fb TextEncoder is no longer required for OS.File.writeAtomic() 2015-05-31 23:01:34 -04:00
Dan Stillman
4fd65fec4c Fix charset handling in Zotero.File.getContentsAsync()
Character sets are now populated on demand, so they can't be run through
Zotero.CharacterSets.getName() in getContentsAsync(), since they might
not exist. (I'm also not sure why this was being done anyway.)
2015-05-31 22:58:11 -04:00
Dan Stillman
1979efd8ce Fix Zotero.Fulltext.getTotalPagesFromFile() call 2015-05-31 22:57:34 -04:00
Simon Kornblith
e868c758b6 Fix library/locator engine lookup
Fixes #744, closes #747. Thanks to @zuphilip for tracking down the bug
2015-05-31 18:23:11 -04:00
Dan Stillman
b8d9504a4f Missed lines from 420985661 2015-05-31 17:07:59 -04:00
Simon Kornblith
673168ea7b Don't adjust accessDate for UTC and set version to 0 in Item#toJSON
Ref discussions:
https://github.com/zotero/zotero/pull/746/files#r31394225
https://github.com/zotero/zotero/pull/746#commitcomment-11445605
2015-05-31 17:02:20 -04:00
Dan Stillman
cc3d81da93 Add Zotero.DataObjectUtilities.generateKey()
For now, this just calls Zotero.Utilities.generateObjectKey(), but this
function makes more sense in DataObjectUtilities. It does need to be
accessible to the connectors, but if it's possible to add an alias in
Zotero.Utilities just for the connectors, it'd probably be better to do
that and use Zotero.DataObjectUtilities.generateKey() elsewhere.
2015-05-31 16:59:10 -04:00
Dan Stillman
420985661b Default to user library when assigning unsaved item to collection
And fix some issues setting the libraryID property on unsaved objects

Also return .deleted as false, not an empty string
2015-05-31 02:03:53 -04:00
Dan Stillman
ed1c0a4637 Fix updating of cached child collections/items, and make more efficient 2015-05-30 19:03:42 -04:00
Dan Stillman
807c40859f Missed lines from 2154673dd 2015-05-29 21:55:47 -04:00
Dan Stillman
2154673dd3 Return a Zotero.Item from all Zotero.Attachments methods
These previously returned an itemID, but now that new saved items can be edited
without a refetch, they should just return the new item.

(Possible I missed a few spots where these are called.)
2015-05-29 05:33:54 -04:00
Dan Stillman
5a2ec43de1 Add Notifier.queue()
Notifier.trigger() needs to be async, since if it actually runs it waits for
promises returned from observers. But the vast majority of trigger() calls are
in transactions where they just queue and can therefore be synchronous. This
replaces all such calls with Notifier.queue().

This should fix a race condition that was causing the emptyTrash() test to fail
intermittently.
2015-05-29 05:03:05 -04:00
Dan Stillman
15252623d7 Log the actual number of Notifier observers for a type 2015-05-29 03:37:29 -04:00
Dan Stillman
72e0124e4e Fix tag purging with stricter DB parameter checks
Should have failed without libraryID being passed
2015-05-29 01:15:04 -04:00
Dan Stillman
4e1dd6f5b6 Restore DB parameter checking and add tests
Some parameter situations also weren't being properly handled
2015-05-29 01:15:04 -04:00
Dan Stillman
1e7c822ab0 Fix linked file creation 2015-05-29 01:09:24 -04:00
Dan Stillman
a804efce67 Fix getAttachments()/getNotes() with no child items after save 2015-05-27 22:18:40 -04:00
Dan Stillman
7eaa57562f Fix Zotero.ItemFields.getBaseIDFromTypeAndField()
Closes #741
2015-05-27 05:01:48 -04:00
Dan Stillman
80d5b74cf3 Merge 4.0 up to 28301ea45f
Conflicts:
	chrome/content/zotero/preferences/preferences_export.js
	chrome/content/zotero/xpcom/proxy.js
2015-05-26 17:48:22 -04:00
Dan Stillman
8c64d8b410 Fixes #739, Item added to "My Publications" despite choosing cancel 2015-05-26 17:20:42 -04:00
Aurimas Vinckevicius
ec786bf15c For now, use Zotero item DB ids when passing items to citeproc
citeproc-js relies on this in several locations. Seems that Zotero passes these IDs to citeproc from the item picker. We also need to consider existing embedded items in Word/LO documents, but they do have embedded URIs, so it shouldn't be a problem.
CC @fbennett
2015-05-26 16:11:44 -05:00
Aurimas Vinckevicius
c84a16984b Map note excerpt to title in itemToCSLJSON
This way notes have some sort of user-friendly way of being traced from Word documents to Zotero items in the library
2015-05-26 16:11:44 -05:00
Aurimas Vinckevicius
de0b7ba181 ItemGetter shouldn't break with an empty DB 2015-05-26 16:11:42 -05:00
Aurimas Vinckevicius
9d5d8b525a Access date in Zotero.Item::toJSON should be in ISO-8601 format 2015-05-26 16:03:35 -05:00
Aurimas Vinckevicius
47bf9c38e9 Transition item Export Format to Zotero web API item JSON
* Enable legacy mode for export translators compatible with pre-4.0.27:
   * Add compatibility mappings, so that current translators don't break if they specify minVersion lower than 4.0.27. This does introduce non-compatible changes, specifically, "version" field in legacy mode is "versionNumber" in the new format. "version" in the new format corresponds to the "version" as specified for Zotero API JSON format. New translators should expect Zotero web API JSON format and should specify minVersion 4.0.27.
* Update CSL mappings to comply with new itemToExportFormat
* CSL JSON export translator needs to be updated to be compatible with 4.0.27 to export correct CSL JSON
* Use item URI for id in CSL JSON instead of item ID
* Fix note and attachment handling in itemToCSLJSON
2015-05-26 15:48:43 -05:00
Aurimas Vinckevicius
12db2e6c51 Don't throw if checking invalid field in ItemFields.isValidForType 2015-05-26 15:39:44 -05:00
Aurimas Vinckevicius
c6151f959d Fix relations serialization in Zotero.Item::toJSON() 2015-05-26 15:39:44 -05:00
Aurimas Vinckevicius
21cd15b068 Port Zotero.Item.toJSON from api_syncing branch
* Modified to use synchronous DB access
* Take patchBase argument as an option
* Update to conform to v3 API
2015-05-26 15:32:33 -05:00
Aurimas Vinckevicius
7445f81042 Port Zotero.Date.sqlToISO8601 from 755ead2119
Copy-pasted, no modifications
2015-05-26 15:32:33 -05:00
Dan Stillman
f71140da64 Remove Zotero.Item.prototype.addTags
Can use addTag() or setTags()

Addresses #735
2015-05-26 12:13:27 -04:00
Dan Stillman
8a0b4d92a6 Fix PDF tools installation on Linux 2015-05-26 04:44:02 -04:00
Dan Stillman
3d3b817724 Allow data to be set after save() on a new object without load() calls
After saving a new object and reloading primary data and any changed
data (which we can maybe reconsider at some point), mark all other data
types as loaded, since there's no other data we don't have. For example,
this allows for item.save() to be followed by item.setField() without
needing to call item.loadItemData() first.
2015-05-26 04:08:47 -04:00
Dan Stillman
5d530e4173 Don't load item data and collections for all items in the middle pane 2015-05-26 03:19:44 -04:00
Dan Stillman
41a68af1ae Remove debug line when loading collections 2015-05-26 03:19:44 -04:00
Dan Stillman
ea1573e1c3 Don't log warning when localized string for search condition not found
Falls back to item field strings, so not sure why I added logging for
this.
2015-05-26 03:19:30 -04:00
Dan Stillman
9f4b128c14 Remove header and footer from stack trace display 2015-05-26 03:15:04 -04:00
rmzelle
06e6168cb4 Implement locale drop-down menus 2015-05-26 00:12:04 -04:00
Dan Stillman
28301ea45f Center the site-specific Quick Copy and proxy editing windows
On OS X these show up as sheets, but on Windows without this flag they
appear in the top-left of the screen.
2015-05-25 23:36:24 -04:00
Dan Stillman
c152e81bed Merge pull request #732 from rmzelle/edit-button-quickcopy
Add Edit button for site-specific Quick Copy settings
2015-05-25 23:31:44 -04:00
rmzelle
5833d87169 Add Edit button for site-specific Quick Copy settings 2015-05-25 23:21:50 -04:00
Dan Stillman
6e4eb61694 Merge pull request #673 from sendecomp/optional-proxy-redirect-notification
Add an option to not show the proxy redirection notification
2015-05-25 21:57:16 -04:00
Dan Stillman
96f5bab3a1 Cancel relatedbox loading if binding disappears 2015-05-25 21:48:47 -04:00
Dan Stillman
31af26af08 Fix selection of new items 2015-05-25 21:48:47 -04:00
Dan Stillman
2bd246e2ea Fixes #728, Tag selector refreshing 2015-05-25 21:48:46 -04:00
LinuxMercedes
34c0e746f5 Add an option to not show the proxy redirection notification 2015-05-25 17:38:24 -05:00
Dan Stillman
cbbdebc5b7 Fix hang in collectionsTreeView::selectWait() if row is already selected 2015-05-25 01:43:07 -04:00
Dan Stillman
43762248a4 Fix trash emptying, and do it in batches of 50 2015-05-25 00:14:49 -04:00
Dan Stillman
87fa51849f Accept promise-yielding generators directly in forEachChunkAsync() 2015-05-24 22:56:44 -04:00
Dan Stillman
6933f64616 Fix reselection of trash after restart 2015-05-24 22:04:40 -04:00
Dan Stillman
dd52206b37 Don't show "Loading item data" when data is cached 2015-05-24 21:34:11 -04:00
Dan Stillman
e35575e6fd If last viewed collection is set but not found, default to My Library 2015-05-24 20:00:10 -04:00
Dan Stillman
2ed04eca26 Speed up translator initialization in source installs
updateBundledStyles() already has the contents of a new/updated
translator when it copies it into the data dir, so there's no need for
Zotero.Translators.reinit() to read it again from the just-copied file.
This passes the metadata from updateBundledStyles() to reinit() to avoid
the extra file read.

(Alas, this appears to make essentially zero difference on an OS X
system with an SSD, but maybe it will help elsewhere.)
2015-05-24 20:00:10 -04:00
Dan Stillman
bd9c53b29c Fix tag selector loading (broken by 6b87c641) 2015-05-24 20:00:10 -04:00
Dan Stillman
8a93250ca1 Fix "comment.split is not a function" in item box 2015-05-24 04:56:19 -04:00
Dan Stillman
19b8db590f Fixes #727, Duplicated items lose their creators 2015-05-24 04:55:54 -04:00
Dan Stillman
ff7919553c Collections data layer cleanup
Get rid of data_access.js, at long last. Existing calls to
Zotero.getCollections() will need to be replaced with
Zotero.Collections.getByLibrary() or .getByParent().

Also removes Zotero.Collection::getCollections(), which is redundant
with Zotero.Collections.getByLibrary(), and Zotero.Collections.add().
The latter didn't didn't include a libraryID anyway, so code might as
well just use 'new Zotero.Collection' instead.
2015-05-24 04:37:34 -04:00
Dan Stillman
ef57b4e016 Relations fixes and cleanup
Relations need a complete overhaul, but this makes them generally work
again.
2015-05-24 03:08:22 -04:00
Dan Stillman
b21e07d700 Fix group saving and copying attachments between libraries 2015-05-23 21:10:07 -04:00
Dan Stillman
5e1c25f4b5 Async Zotero.File.copyDirectory() 2015-05-23 21:08:11 -04:00
Dan Stillman
e1355cef2f Show only "Export Files..." in context menu for My Publications 2015-05-23 19:07:14 -04:00
Dan Stillman
0f519dc757 Post-merge cleanup in fileInterface.js
(Though not enough to actually get it working)
2015-05-23 18:35:28 -04:00
Dan Stillman
aa730bb3bd Merge branch '4.0'
Conflicts:
	chrome/content/zotero/fileInterface.js
	chrome/content/zotero/xpcom/translation/translate_item.js
	chrome/content/zotero/xpcom/utilities_internal.js
	chrome/content/zotero/zoteroPane.js
2015-05-23 18:26:32 -04:00
Dan Stillman
ebe41ac51a Fixes #724, PDF indexing binaries not downloading
And adds Zotero.File.download(uri, path)
2015-05-23 18:03:25 -04:00
Dan Stillman
6b87c641d9 Experimental approach to cancelling unnecessary promises
If a view or other resources are destroyed while a promise is being
resolved, subsequent code can fail. This is generally harmless, but it
results in unnecessary errors being logged to the console.

To address this, promises can use a new function,
Zotero.Promise.check(), to test whether a value is truthy or 0 and
automatically throw a specific error that's ignored by the unhandled
rejection handler if not.

Example usage:

getAsync().tap(() => Zotero.Promise.check(this.win));

If this.win is cleaned up while getAsync() is being resolved, subsequent
lines won't be run, and nothing will be logged to the console.
2015-05-23 04:43:37 -04:00
Dan Stillman
3fc09add3a Attachment fixes
Change all attachment functions to take parameter objects, including a
'collections' property to assign collections. (Previously, calling code
assigned collections separately, which required a nested transaction,
which is no longer possible.)

Fixes #723, Can't attach files by dragging
2015-05-23 04:43:37 -04:00
Simon Kornblith
6e2d1f683a Get translation at least partly working
I'm pretty sure I've only scratched the surface here, but at least
basic things work.
2015-05-22 22:24:46 -04:00
Dan Stillman
61cb01b7c2 Collection/item tree selection improvements
Wait for the pane's collectionSelected() to finish before returning from
collectionTreeView select methods (e.g., selectLibrary()), and wait for
previous items view to finish loading before creating a new one in
collectionSelected(). This ensures that the items view has been created (though
not loaded) before returning from a select. The tree can still get a bit
confused switching between collections, but I think we're getting closer to
fixing that.

Also switch the items tree to use the same pattern.

This also fixes dragging items to collections (#731).
2015-05-22 19:22:00 -04:00
Dan Stillman
23e4e54c29 Add extra newline between lines in error reports 2015-05-22 16:03:06 -04:00
Dan Stillman
f164fef3d2 Skip Quick Copy until #520 is done 2015-05-22 16:00:22 -04:00
Dan Stillman
22e0ba3a22 Fix hangs related to data object purging 2015-05-22 15:59:15 -04:00
Dan Stillman
cf010d7748 Fix collection collapse/expand issues
Fixes #722, Everything disappears
2015-05-22 14:43:09 -04:00
Dan Stillman
432d89af24 Group data layer fixes 2015-05-22 14:41:59 -04:00
Dan Stillman
32abbe7c25 Load groups at startup, and make Zotero.Groups functions synchronous
Groups were already being loaded for the collections list, so we might
as well just store them initially and let Zotero.Libraries.getName() be
a synchronous call.
2015-05-22 04:52:05 -04:00
Dan Stillman
f4446e268d Use more concise 1-line format for SQL logging
SELECT * FROM foo WHERE bar=? AND qux=? ['foo', 1]

Not sure why I didn't do this years ago...
2015-05-21 23:44:10 -04:00
Dan Stillman
ada657fcb8 Functions to modify 'version'/'synced' efficiently, plus some other fixes 2015-05-21 23:44:10 -04:00
Dan Stillman
a3f4fe181f More data layer changes
- Moved ::_get() and _set() from Collection/Search into DataObject, and
  disabled in Item
- Don't disable new items after save. We now put new objects into the
  DataObjects cache from save() so that changes made post-save are
  picked up by other code using .get().
- Added 'skipCache' save() option to avoid reloading data on new objects
  and adding them to the cache. (This will be used in syncing, where
  objects might be in another library where they're not needed right
  away.) Objects created with this option are instead disabled to
  prevent reuse.
- Modified some tests to try to make sure we're reloading everything properly
  after a save.
- Documented save() options
2015-05-21 23:39:00 -04:00
Dan Stillman
8352934009 Merge pull request #671 from gracile-fr/localize-locators-labels
Add localized locator labels
2015-05-21 02:19:16 -04:00
Dan Stillman
4792b7cd48 Data layer fixes
- Fixes some saving and erasing issues with collections and searches
- Adds Zotero.DataObject::eraseTx() to automatically start transaction,
  and have .erase() log a warning like .save()
- Adds createUnsavedDataObject() and createDataObject() helper functions
  for tests
2015-05-20 23:16:18 -04:00
Dan Stillman
e8a04dffd0 Relations support for Z.DataObjectUtilities.diff() and applyChanges() 2015-05-20 23:16:18 -04:00
Dan Stillman
0e73b1cc61 Remove code to check for changes after note reselection
No longer necessary, since items aren't reselected on change, and the
dateModified check was insufficient
2015-05-19 22:34:49 -04:00
Dan Stillman
8cfca53b48 Register itembox and noteeditor with notifier and refresh on update
Since selected items are no longer reselected, the boxes now need to
refresh themselves.
2015-05-19 17:08:45 -04:00
rmzelle
4bdef75074 Add DOI-field context-menu 2015-05-19 16:25:02 -04:00
Aurimas Vinckevicius
f7868be884 Consolidate _saveAttachment error and callback handling 2015-05-19 03:12:37 -05:00
Aurimas Vinckevicius
ed734bfdf3 Merge 849803473a into api_syncing
Fixes #677
2015-05-19 02:41:03 -05:00
Dan Stillman
eee0e22bf6 Add 'version' to sync cache primary key
The sync cache will have pristine copies of the existing versions of
local objects for better conflict resolution, but downloads will get
saved to the sync cache first before processing, so the cache needs to
be able to hold more than one version.
2015-05-19 01:25:31 -04:00
Dan Stillman
ab4320df07 Add Zotero.Libraries.getAll() 2015-05-19 01:20:12 -04:00
Dan Stillman
e0ea3ca99b Don't show "[object Object]" in varDump() output 2015-05-19 01:17:12 -04:00
Dan Stillman
3b0b2c59b7 Always show HTTP request resolution, even without debug flag 2015-05-19 01:17:12 -04:00
Dan Stillman
abaa4da5ab Much better data object change detection
Replace Z.DataObjects::diff() with Z.DataObjectUtilities.diff(). Instead
of just returning two objects with the differing fields, the new diff()
generates a changeset with operations to apply with applyChanges(),
including at the array member level for collections and tags. This,
combined with cached pristine copies of objects, will allow for vastly
better conflict resolution, with automatic merging of non-conflicting
changes.

Creators currently don't show granular changes, and ordering might make
it too tough to do so. Relations diffing isn't yet implemented.
2015-05-19 01:17:12 -04:00
Dan Stillman
f727b224e7 Fix tag diffing 2015-05-15 01:47:20 -04:00
Dan Stillman
7a93b132b3 Merge pull request #715 from rmzelle/proxylist-editbutton
Add Edit button to proxy list
2015-05-14 13:10:20 -04:00
rmzelle
bd8db988f3 Add Edit button to proxy list 2015-05-14 09:26:38 -04:00
Dan Stillman
3f4eebe51c Set 'synced' to false automatically on save, unless value is changed
And add 'skipSyncedUpdate' option to leave untouched

Also move some save logic into Zotero.DataObject.prototype._saveData(),
and call that first.
2015-05-13 19:32:53 -04:00
Dan Stillman
fa039971e6 Fixes #714, Zotero.defineProperty() lazy mode doesn't work
Patch from @aurimasv
2015-05-13 13:43:55 -04:00
Dan Stillman
f376db0705 Remove duplicate Zotero.defineProperty() function
Ended up in two places somehow
2015-05-13 12:35:26 -04:00
Dan Stillman
27ab9869be Fix DB upgrading (broken in 14d435b8d) 2015-05-13 11:20:12 -04:00
Dan Stillman
3eed76698c clearUserPref no longer throws on an invalid pref 2015-05-13 11:20:12 -04:00
Dan Stillman
1f8b6fad61 Don't include collections in child item JSON export
But handle it in Zotero.Items.diff() if it's there for one item
2015-05-13 11:20:11 -04:00
Dan Stillman
24022623a1 Move patchBase into options in Zotero.Item.prototype.toJSON()
Also:

- Make .mode == 'patch' optional if .patchBase is provided.
- Remove requirement for item to be unchanged, which hopefully wasn't there for
  a good reason
- Add a few tests, though more are needed
2015-05-12 20:12:10 -04:00
Dan Stillman
1578675ace Change 'finite' param to 'maxTime' in delayGenerator
Allows delaying up to a specified amount of time before yielding false
2015-05-12 20:12:05 -04:00
Dan Stillman
27899c85b5 Add setter and tests for dateAdded
Setting dateAdded is necessary for syncing
2015-05-12 19:55:14 -04:00
Dan Stillman
1558ed8a27 Update Zotero.DataObjects.prototype.diff() to handle API JSON 2015-05-12 19:51:02 -04:00
Dan Stillman
50f627c0cd Replace CollectionTreeView::getLastViewedRow() with selectByID() 2015-05-12 19:45:14 -04:00
retorquere
47ffa1188a export groups, unify library export 2015-05-12 17:52:35 +02:00
Dan Stillman
4d37b3d4c9 Temporary debugging of ItemTreeView::notify() yielding 2015-05-10 18:33:44 -04:00
Dan Stillman
c83bc1b01d Don't reload skipped data types 2015-05-10 18:32:11 -04:00
Dan Stillman
14d435b8d8 Closes #711, Remove support for nested transactions 2015-05-10 18:32:10 -04:00
Dan Stillman
e584dbf5dd Wait for items list to refresh before handling notifications
This fixes an error if New Item is used before the items list has
loaded.
2015-05-10 18:30:07 -04:00
Dan Stillman
6faa2caff8 Add queryTx() to a run a single query in a transaction
Otherwise a write statement could run in the middle of an unrelated open
transaction.
2015-05-10 18:30:06 -04:00
Dan Stillman
03da4a9d52 Restore unselecting of last row in tree if removed
If no other rows are selected, select the row before the removed row
2015-05-10 18:30:06 -04:00
Dan Stillman
af7da366c9 Get connection without yielding if available in executeTransaction 2015-05-10 18:30:05 -04:00
Dan Stillman
a39a42546f Add missing yield in restoreSelectedItems() 2015-05-10 18:30:05 -04:00
Dan Stillman
a64282118b Fix items-count updating in right-hand pane
And some other tweaks to ZoteroPane.itemSelected()
2015-05-10 18:30:05 -04:00
Dan Stillman
e2b62580d1 Fix errorHandler check in DataObject.save() 2015-05-08 13:35:04 -04:00
Dan Stillman
3349930483 Allow fromJSON to be called on unsaved items 2015-05-08 13:35:04 -04:00
Dan Stillman
5635fec4e3 Various creator-saving fixes 2015-05-08 13:35:01 -04:00
Dan Stillman
9f8510c821 Throw ZoteroUnknownTypeError on unknown item type in getItemTypeFields
This needs to be done in additional places as well.
2015-05-08 03:38:28 -04:00
Dan Stillman
3214e37d92 Ignore empty 'filename' property in Item.fromJSON() 2015-05-08 03:38:27 -04:00
Dan Stillman
e3da547c81 Avoid error if item tree disappeared during refresh 2015-05-08 03:38:27 -04:00
Dan Stillman
2a69885b11 Fix placement of saved searches in collections tree
And unify row add/remove handling between collections tree and items
tree
2015-05-07 18:20:26 -04:00
Dan Stillman
67abbc8c4a Add errorHandler option to DataObject.prototype.save()
This allows calling code to do something other than call Zotero.debug()
on errors (like, say, nothing, in order to avoid logging certain
expected errors) before throwing.
2015-05-07 18:20:26 -04:00
Dan Stillman
47f3c1efe6 Don't reselect items unnecessarily
Store and check the last selected items in ZoteroPane.itemSelected() to
see if it's necessary to refresh the item pane. This prevents loss of
textbox focus if another write occurs while editing a field.

Also optimize row adding/removing in itemTreeView.js
2015-05-07 15:09:41 -04:00
Dan Stillman
afface4fba Fix Zotero.Utilities.arrayEquals() for nested array comparisons 2015-05-07 15:09:41 -04:00
Dan Stillman
37f5669319 Fix making an item a child item if it's in any collections 2015-05-07 15:09:40 -04:00
Dan Stillman
2525f8e532 Fix dragging items to collections 2015-05-07 15:09:40 -04:00
Dan Stillman
45b3cd8a53 Replace non-breaking spaces in tested lines in recognizePDF
Fixes "PDF does not contain OCRed text" message for
http://pdfserver.amlaw.com/nlj/NSA_ca2_20150507.pdf
2015-05-07 13:41:13 -04:00
Dan Stillman
3587bb0f6b Fix error if a synced filename begins with a dot (".pdf") 2015-05-07 13:40:05 -04:00
Dan Stillman
3a995d64a4 Fix saving of tags 2015-05-06 04:23:31 -04:00
Dan Stillman
26e1372f46 Throw an error if item type isn't set when saving
And add a test for throwing from setField(), which already happens.
2015-05-06 04:20:47 -04:00
Dan Stillman
7879e5432a Fix new attachment charset saving, which I definitely didn't test before 2015-05-06 04:20:45 -04:00
Dan Stillman
33eaaffd83 Fix Date Modified handling when saving items 2015-05-06 04:19:20 -04:00
Dan Stillman
e5cbfb71a6 Throw ZoteroMissingObjectError for missing item errors
And don't log in DataObject.saveData() before rethrowing, since the
calling code will probably take care of it
2015-05-06 04:19:20 -04:00
Dan Stillman
d67fd9fda2 Don't send add notifications for collections if skipNotifier is passed 2015-05-05 15:57:37 -04:00
Dan Stillman
01f04802f0 Fix loadAllData() on regular items without notes
Set a flag when setting the item type that instructs loadAllData()
whether to attempt to call loadNote()
2015-05-05 15:57:37 -04:00
Dan Stillman
beb17436f8 Don't mark parentKey as changed when set to false for an unsaved item
And return undefined for search objects
2015-05-05 15:57:37 -04:00
Dan Stillman
b0f52a0f07 Allow attachmentLinkMode to be specified as a string ('linked_url') 2015-05-05 15:57:36 -04:00
Dan Stillman
93a6a4ffdb Don't mark an empty field set to an empty string as changed
And some tests
2015-05-05 15:57:36 -04:00
Dan Stillman
18714a4fcb Default to user library for saved searches
For consistency with collections and items
2015-05-05 03:17:51 -04:00
Dan Stillman
bb760707d4 Get id values directly in Zotero.DataObject.prototype.loadPrimaryData 2015-05-05 02:56:56 -04:00
Dan Stillman
02a36eab9b Fix various issues with rapid UI/data changes due to asyncification 2015-05-05 02:53:06 -04:00
Dan Stillman
fc428f8e1b Insert new saved search rows without refreshing collections list
And some other selection-related tweaks
2015-05-05 02:52:26 -04:00
Dan Stillman
2ca53677f8 Don't resave collection with no parent after .parentKey = false 2015-05-05 02:52:26 -04:00
Dan Stillman
aa512f0f8d Miscellaneous data layer fixes and tweaks 2015-05-04 03:19:58 -04:00
Dan Stillman
53e40bb0f4 Miscellaneous tweaks 2015-05-04 02:46:40 -04:00
Dan Stillman
ef91299951 Asyncify Zotero.CollectionTreeCache.clear() 2015-05-04 02:46:39 -04:00
Dan Stillman
8ec248f7ec Remove some unnecessary asyncness in tree views
E.g., closing a container doesn't need to yield
2015-05-04 02:46:39 -04:00
Dan Stillman
d22f762bb6 Add new collection rows without reloading the collections list 2015-05-04 02:46:34 -04:00
Dan Stillman
6328d1f39b CollectionTreeView::selectLibrary() doesn't need to be async 2015-05-04 02:45:56 -04:00
Dan Stillman
8fec5ace3a Fix post-save textbox focusing bugs in right-hand pane
Fix a couple cases of lost text field focus after an edit, including
focusing of the Title field after using New Item when a field is already
being edited and has a changed value.

Also, in tests, select My Library and wait for items to load when using
the loadZoteroPane() support function. We could add a parameter to skip
that or move it to a separate function, but the code to detect it is a
bit convoluted and it's a prerequisite for many tests, so it's handy to
have a function for it.
2015-05-04 02:45:55 -04:00
Dan Stillman
590649fd49 Ignore blur events from html:textarea
If a new item is created manually when a text field is already open, the
hideEditor is run first on the html:textarea before bubbling up to the
textbox. During a normal blur, the event only happens on the textbox,
though I haven't looked into the reason for the difference.
2015-05-04 02:45:55 -04:00
Dan Stillman
bdd44e9a44 DB isolation changes and item selection tweaks
- Add an 'exclusive' option to transactions that causes them to block other
  transactions and wait for other transactions to finish before starting,
  instead of nesting
- Resolve Zotero.DB.waitForTransaction() promise before returning from
  executeTransaction()
- A side effect of the above: wait for a newly created item to be selected in
  the middle pane and rendered in the right-hand pane before returning from
  executeTransaction()
- Don't save items multiple times when adding/removing a non-final creator in
  the Info pane
- Use a simpler, non-recursive method for focusing the next field in the Info
  pane; this prevents "too much recursion" errors if something causes the
  right-hand pane not to be rendered when expected
2015-05-04 02:45:55 -04:00
Dan Stillman
4a0018ec63 Fix transaction detection
This fixes an issue where two transactions started around the same time
could run separately instead of nesting, causing the statements from one
to end up running not within a transaction
2015-05-04 02:45:55 -04:00
Dan Stillman
43a2045aec Change computerProgram 'version' to 'versionNumber'
And use 'version' instead of 'itemVersion' for object version for items

Also add deferred foreign key checking to system.sql so that DROP TABLE
commands don't fail mid-transaction
2015-05-04 02:45:53 -04:00
Dan Stillman
5070c04af6 Ignore invalid fields in Zotero.ItemFields.isValidForType() 2015-05-04 02:45:28 -04:00
Dan Stillman
805df39869 Remove extra debugging in Zotero.ItemFields.getLocalizedString() 2015-05-04 02:45:28 -04:00
Dan Stillman
285995807d fromJSON() methods for data objects
Tests needed
2015-05-04 02:45:25 -04:00
Dan Stillman
afe0412c58 Collection/item tree view updates
- Pass .skipSelect option to data object .save() to prevent new objects
  from being selected
- Fix miscellaneous bugs
- Selection-related tests
2015-05-04 02:43:32 -04:00
Dan Stillman
322339876e Add Zotero.Date.isISODate() and Zotero.Date.isoToSQL() 2015-05-04 02:41:14 -04:00
Dan Stillman
e8d4b3e840 Add Zotero.Item.prototype.attachmentFilename 2015-05-04 02:41:14 -04:00
Dan Stillman
40e86147a4 Allow loadChildItems() to be called on note/attachment items
Otherwise loadAllData() doesn't work
2015-05-04 02:41:14 -04:00
Dan Stillman
453e7bd090 Fix size of 2x icons in progress window 2015-05-02 19:00:42 -04:00
Dan Stillman
fbef911cb7 Add wizard for My Publications
Show a wizard after items are dragged to My Publications choosing
whether to include files and notes and choosing sharing settings for the
items. Sharing options are Creative Commons licenses, CC0, "All rights
reserved", or keeping the existing Rights field if available.

Also blocks collections, searches, linked file attachments, and
top-level attachments/notes from My Publications at the data layer, but
not yet from the UI in all places (so it can crash if you try).

Todo:

- Block certain UI actions with nice messages
- Show a nice scrollable list of items in the wizard to allow selecting
  specific files/notes, instead of just having checkboxes for files and
  notes that apply to all dragged items
- Show an explanation of My Publications in the right-hand pane when no
  items are selected
- Maybe adjust handling when no attached files/notes, since it might be
  a bit alarming at the moment to see sharing options for metadata
  entries
2015-04-26 19:41:45 -04:00
Dan Stillman
944d298af7 Make retrieving transactionDate with no transaction fatal
I think the places where we retrieve it are always within transactions,
and this helps catch promises that aren't waited for.
2015-04-26 19:36:08 -04:00
Dan Stillman
0471a393eb Always return promise from Zotero.Attachments._postProcessFile() 2015-04-26 18:08:26 -04:00
Dan Stillman
1179d4c142 Fix Zotero.File.getBinaryContentsAsync() with no maxLength
And properly reject promise on failure
2015-04-26 18:08:25 -04:00
Dan Stillman
311ed7a71d Fix some old-style generators passed to executeTransaction()
And some missing yields
2015-04-26 18:08:25 -04:00
Dan Stillman
99dfc72a18 Fix collection saving 2015-04-26 18:08:25 -04:00
Dan Stillman
694896273a Properly detect group in Zotero.CollectionTreeRow::isWithinGroup()
More follow-up from 1c8abf384
2015-04-26 17:51:30 -04:00
Dan Stillman
1f00e99e71 Fix 'this' binding in ZoteroPane.selectItem(), but this time for real 2015-04-26 17:51:30 -04:00
Dan Stillman
a2b572665d Make libraryID optional for DataObjects, defaulting to user library 2015-04-26 17:51:29 -04:00
Dan Stillman
30535653a6 Fix error saving single attachment files from document 2015-04-26 17:51:29 -04:00
Dan Stillman
8ff258fe03 Don't require parent item to be loaded when setting item parent 2015-04-25 03:17:41 -04:00
Dan Stillman
6126a49fea Don't require non-identified items to have loaded data in getField()
This allows getField() on an unsaved item to work properly without a pointless
loadItemData() call.
2015-04-25 03:17:41 -04:00
Dan Stillman
5c8209da5c Fix 'this' binding in ZoteroPane.selectItem() 2015-04-25 03:17:41 -04:00
Dan Stillman
2f556d0da1 Adjust identifier registration on object save
Previously, object identifiers were registered in a commit callback, but that
meant that they wouldn't be available to getLibraryAndKeyFromID/
getIDFromLibraryAndKey within a transaction. Instead, register them before
saving and clear them in a tranasction rollback if necessary.

This changes Zotero.DataObject to call its own _finalizeSave() in addition to a
descendent one.
2015-04-25 03:17:41 -04:00
Dan Stillman
f8ac21d891 Return object instead of array from Zotero.DataObjects.getLibraryAndKeyFromID()
Object contains 'libraryID' and 'key' properties

This is due to changed array destructuring behavior in Firefox. Previously,
`var [foo, bar] = maybeArrayMaybeFalse()` always worked, leaving foo and bar
undefined if the function returned false. Now (with ES6, I assume), if the
function returns false it results in a "false[Symbol.iterator] is not a
function" error. But `var {libraryID, key} = false` works as expected, leaving
both values undefined, so instead we can just return an object with those
properties from getLibraryAndKeyFromID(). To assign to different variables, use
`var {libraryID, key: parentItemKey} = ...`.
2015-04-25 03:17:41 -04:00
Dan Stillman
9e3e680be8 Rework DB transaction handling
Rollback callbacks weren't being properly called, and some other things were in
the wrong place, particularly with nested transactions.
2015-04-25 03:17:41 -04:00
Dan Stillman
4cb5e7e4d5 Remove check for ES5 generators in Zotero.DB.executeTransaction()
This doesn't work properly in some contexts and can break things. There might
be a better test, but we probably don't need this anymore.
2015-04-25 03:17:40 -04:00
Dan Stillman
0e800f350c Throw errors instead of logging for some item load calls
Reverts a change in b83bc404, and changes one debug line introduced
there into an error
2015-04-25 03:17:40 -04:00
Dan Stillman
f68a595a2b Remove Zotero.DataObject._eraseRecoverFromFailure() 2015-04-25 03:17:40 -04:00
Dan Stillman
4b040c78a7 Fix various saved search bugs, and add tests
Search condition ids are now indexed from 0, and always saved
contiguously (no more 'fixGaps' option), since they're just in an array
in the API. (They're still returned as an object from
Zotero.Search.prototype.getConditions() because it's easier for the
advanced search window to not have to deal with shifting ids between
saves.)
2015-04-17 19:29:37 -04:00
Dan Stillman
d9c32a8e90 Fix search saving, and add some unit tests
Also:

- Return an object from `Zotero.Search.prototype.getConditions()`
  instead of an array.
- Add support function `getPromiseError(promise)` to return the error
  thrown from a chain of promises, or false if none. (We could make an
  `assert.throwsAsync()`, but this allows testing of various properties
  such as `.name`, which even the built-in `assert.throws()` can't
  test.)
- Clarify some search save errors
2015-04-17 00:25:09 -04:00
Dan Stillman
59773f3f6d Zotero.Search.getSearchCondition(s) -> getCondition(s) 2015-04-17 00:25:09 -04:00
Dan Stillman
1952fbccd4 Wait for Zotero.Searches initialization 2015-04-16 20:50:15 -04:00
Dan Stillman
51c7ae6e5c Add -b option to skip translator/style installation in tests
'b' for *b*undled files

Translators and styles take a long time to install and initialize in
source installations, and they're unnecessary for many tests.

This shaves about 10 seconds off each test run for me on one system (and
that's with some help from filesystem caching).
2015-04-16 20:50:15 -04:00
Dan Stillman
0154e44c2f Mark all data as loaded when loading primary data for nonexistent object 2015-04-16 20:49:18 -04:00
Dan Stillman
293f7c6dd4 Zotero.Search.prototype.addCondition() doesn't need to be async 2015-04-16 20:48:59 -04:00
Dan Stillman
a2b6df1014 Include both DB version numbers in "newer than SQL file" dialog 2015-04-15 16:03:47 -04:00
Dan Stillman
384a547693 Merge branch '4.0' into api_syncing
Conflicts:
	chrome/content/zotero/lookup.js
2015-04-15 00:56:25 -04:00
Dan Stillman
a8d1080cd6 Unpromisify a couple Zotero.Translator.get() calls
More to be done to fix translation
2015-04-15 00:50:22 -04:00