Commit graph

4640 commits

Author SHA1 Message Date
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