Commit graph

5473 commits

Author SHA1 Message Date
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
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
c9aed60acd Rename error/warning icons 2015-05-19 22:42:43 -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
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
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
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
3a995d64a4 Fix saving of tags 2015-05-06 04:23:31 -04:00