Commit graph

5571 commits

Author SHA1 Message Date
Dan Stillman
20ca8edf87 Fix getContentsAsync() with invalid characters 2015-06-02 20:32:31 -04:00
Dan Stillman
424cae173b Fix getField/setField behavior/tests with regard to falsy values
In particular, 0 is kept as a value, and passing undefined to setField
now throws an error.

I'm not sure if we actually want to return an empty string in all cases
for missing/invalid fields, but that's what we do currently.
2015-06-02 19:09:58 -04:00
Dan Stillman
3ad15f7b59 Use Zotero.Utilities.Internal.exec() for PDF tool calls 2015-06-02 14:58:44 -04:00
Dan Stillman
77f12527aa Fix NS_BASE_STREAM_CLOSED error, for real
The input stream produced by asyncFetch is closed automatically at EOL,
so the available() call throws this for an empty file.
2015-06-02 14:58:43 -04:00
Dan Stillman
ef3bf8d596 Fix a few test failures/warnings
And simplify tree view load event handling, which may or may not have
been contributing to intermittent test failures, but is cleaner this way
regardless.
2015-06-02 03:51:09 -04:00
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