Commit graph

4714 commits

Author SHA1 Message Date
Dan Stillman
f8684cc9d8 Fix tag purging and Zotero.Tags.getName() 2015-06-09 16:47:04 -04:00
Dan Stillman
ac440b2b38 Don't reload collections list when sources are modified
Just update the row that changed, moving it if necessary.
2015-06-09 16:47:04 -04:00
Dan Stillman
1d45c6c882 Reselect the same row when an item is removed 2015-06-09 03:27:45 -04:00
Dan Stillman
33c19715a8 Avoid error when dragging over header row 2015-06-08 04:29:16 -04:00
Dan Stillman
9a45fa94bd Move transaction wait debug output to level 6, and strip Bluebird lines
This output is basically only useful when something hangs, so it can
stay off all other times.

For now, 6 can be the new only-use-when-something-is-actively-broken
level. At some point we may want to move DB activity to 4 and make this
sort of thing 5, because we don't have much that's 4 right now.
2015-06-08 04:14:47 -04:00
Dan Stillman
2d6143dce1 Clean up notifier debug output 2015-06-08 04:14:46 -04:00
Dan Stillman
f93e6706fa Don't refresh collections view when removing groups
Remove rows one by one
2015-06-08 04:14:46 -04:00
Dan Stillman
b43a735b93 Include libraryID in group.erase() notifier data 2015-06-08 04:05:47 -04:00
Dan Stillman
ec89a98f9d Add group.eraseTx() 2015-06-08 04:05:47 -04:00
Simon Kornblith
70f021f945 Use ISO 8601 accessDates everywhere
This uses ISO 8601 dates for generateAllTypesAndFieldsData (and
changes populateDBWithSampleData to use Item#fromJSON), and makes
translators expect ISO 8601 accessDates, although SQL accessDates are
still supported with a deprecation warning. Canonicalization happens in
Zotero.Translate, so I need to remember to update connectors as well.
2015-06-07 18:50:57 -04:00
Dan Stillman
8448203583 Expect ISO 8601 access dates in Zotero.Item::fromJSON()
This causes translator tests to fail, because the sample data currently
has SQL access dates instead.
2015-06-07 17:54:44 -04:00
Simon Kornblith
3fc38d750b Use Zotero.Item.fromJSON() for saving from translators
Also:
  - Move some canonicalization of items returned by translators to
    Zotero.Translate
  - Make Zotero.Translate#translate return a promise
  - Add tests
2015-06-07 17:30:41 -04:00
Simon Kornblith
ec5e20659b Improve error handling for attachment saving 2015-06-07 17:22:57 -04:00
Simon Kornblith
e27d907973 Throw an error if HTTP request yields non-OK in importFromURL() 2015-06-07 16:06:59 -04:00
Dan Stillman
6935310c75 Fix Zotero.Users.setCurrentUsername() 2015-06-07 15:50:07 -04:00
Dan Stillman
a22c4969e6 Move editable and filesEditable props to libraries table [DB reupgrade]
And add group.fromJSON(json, userID), which sets editable and
filesEditable properties based on the group JSON (libraryReading, role
lists, etc.) and the given user
2015-06-07 15:50:07 -04:00
Dan Stillman
53706d633a Make Zotero.HTTP exceptions instances of Error 2015-06-07 15:43:09 -04:00
Dan Stillman
16706ba481 Allow Zotero.HTTP.request() to be mocked
sinon.useFakeXMLHttpRequest() doesn't work in our case, but if
Zotero.HTTP.mock is set, Zotero.HTTP.request() will create new instances of
that object instead of the built-in XMLHttpRequest, so it can be set to
FakeXMLHttpRequest:

Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
var server = sinon.fakeServer.create();
server.autoRespond = true;
server.respondWith("GET", "/users/1",
  [200, {"Content-Type": "application/json"}, '{"userID": 1}']);
var userInfo = yield getUser();
Zotero.HTTP.mock = null;
server.restore(); // probably not necessary
2015-06-07 15:23:12 -04:00
Simon Kornblith
38eeab06a3 Some snapshot-related fixes 2015-06-07 14:02:20 -04:00
Dan Stillman
aa2e0a8582 Update Zotero.Relations.updateUser() for new relations schema
Also adds Zotero.DataObjects::getLoaded(), which returns an array of all
loaded objects of the given type. This is useful for selective
reloading, for example with item.reload(['relations'], true).
2015-06-04 20:38:49 -04:00
Dan Stillman
195a737049 Allow item.addRelatedItem() to work on unsaved item without libraryID
Production code should just assign a libraryID, but this is useful for
tests, and addCollection() does it.
2015-06-04 20:38:41 -04:00
Simon Kornblith
582799e428 Fix Zotero.Attachments.importSnapshotFromFile 2015-06-04 20:22:54 -04:00
Simon Kornblith
7253a2dd8c Map base fields to item-specific fields in Item#fromJSON() 2015-06-03 23:42:08 -04:00
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