Commit graph

66 commits

Author SHA1 Message Date
Dan Stillman
e0e22225bc Fix entering date without time into Accessed
https://forums.zotero.org/discussion/65560/5-0-beta-accessed-field-changes-dates
2017-05-05 17:59:53 -04:00
Dan Stillman
2eef1702e0 Prevent items in group libraries from being added to My Publications
And remove existing group items that have been added
2017-05-04 21:18:44 -04:00
Dan Stillman
aa1fc01b31 Fix syncing of related item removal 2017-05-02 20:15:54 -04:00
Dan Stillman
9bd01af2a5 Disallow inPublications for linked-file attachments 2017-04-27 15:33:24 -04:00
Dan Stillman
5ff2a59f87 Move My Publications into My Library
Instead of My Publications being a separate library, have it be a
special collection inside My Library. Top-level items can be dragged
into it as before, and child items can be toggled off and on with a
button in the item pane. Newly added child items won't be shown by
default.

For upgraders, items in the My Publications library will be moved into
My Library, which might result in their being duplicated if the items
weren't removed from My Library. The client will then upload those new
items into My Library.

The API endpoint will continue to show items in the separate My
Publications library until My Publications items are added to My
Library, so the profile page will continue to show them.
2017-04-12 19:26:58 -04:00
Dan Stillman
bb665a56b6 Fix firstCreator for unsaved items
Necessary when editing embedded citations that don't exist in library
2017-02-15 23:15:00 -05:00
Dan Stillman
3830aa1125 Mark trashed items as unsynced and update parents (including note list)
Regression from 3a0e0cb088
2017-02-15 14:22:34 -05:00
Dan Stillman
2b9ef26c61 Fix renaming linked attachment files 2016-12-08 03:57:49 -05:00
Dan Stillman
79baac3158 Fix relinking of imported attachment with external file 2016-10-22 15:11:12 -04:00
Dan Stillman
9ba3745b94 Don't clear md5/mtime in item JSON if skipped in patch mode
The client skips synced storage properties (md5, mtime) when uploading items to
ZFS-enabled libraries, but since the API returns JSON with those values
included after writes, they do get saved to the sync cache. If the local
attachment is then modified and the client generates a diff from the cached
version with those properties skipped, they'll be included in the patch JSON as
empty strings in order to clear them. This changes Zotero.Item::toJSON() to
skip those properties in patch mode as well.

This fixes a sync error ("Cannot change 'md5' directly in group library") when
a group attachment is updated locally.
2016-08-15 04:38:04 -04:00
Dan Stillman
7b45b920fc Fix clearing of missing fields in Item::fromJSON() 2016-07-18 23:44:36 -04:00
Dan Stillman
99eb39e288 Always include 'contentType'/'charset'/'filename' in attachment JSON
And omit in ZFS file sync requests

The API previously didn't allow these properties to be set for group items,
because they were set atomically during the file upload process, but 1) that's
not really necessary (makes a little sense for 'filename', but not really a big
deal if an old file is renamed on another computer before the new file is
synced down) and 2) skipping them results in the properties getting erased
after items are uploaded and the empty values returned by the server overwrite
the local values.
2016-05-21 16:33:35 -04:00
Dan Stillman
4ffd35dff2 Fix syntax error in itemTest.js 2016-05-20 23:30:21 -04:00
Dan Stillman
d8abfa4f67 Save all item data values as string, and convert old integers to strings
Before 5.0 we performed a regexp on new item data values to determine if
they were integers and saved them natively in SQLite if so. We no longer
do that, but setField() used strict equality when checking for changes,
so an item could be marked as changed when comparing to a new string
value (e.g., from a write response from the API, which always returns
strings). To avoid that, this converts all old values in the DB to
strings and saves all incoming values as strings automatically. (This
should also help with searching and some other things.)
2016-05-18 17:25:50 -04:00
Dan Stillman
a8ea8656d2 Fix sync error after changing child item to top-level 2016-05-15 03:34:06 -04:00
Dan Stillman
14341ca16c Clear item creators when calling setCreators() with an empty array 2016-04-07 21:10:11 -04:00
Dan Stillman
79748b9132 Fix #940, UI not updating when dragging child item between parents 2016-04-07 21:10:11 -04:00
Dan Stillman
c5702abb7b Don't include 'filename' in linked_file attachment JSON 2016-03-24 22:26:50 -04:00
Dan Stillman
ae6d560a66 Fix Item::multiDiff() 2016-03-11 07:48:24 -05:00
Dan Stillman
7a03b1e527 Accept ISO dates in Item::setField() 2016-03-11 07:48:24 -05:00
Dan Stillman
208d470531 Fix test failures 2016-03-07 17:13:30 -05:00
Dan Stillman
daf4a8fe4d Deasyncification 🔙 😢
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).

What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.

The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).

If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 17:03:58 -05:00
Dan Stillman
c5a9987f37 WebDAV file sync overhaul for 5.0
Also:

- Remove last-sync-time mechanism for both WebDAV and ZFS, since it can
  be determined by storage properties (mtime/md5) in data sync
- Add option to include synced storage properties in item toJSON()
  instead of local file properties
- Set "Fake-Server-Match" header in setHTTPResponse() test support
  function, which can be used for request count assertions -- see
  resetRequestCount() and assertRequestCount() in webdavTest.js
- Allow string (e.g., 'to_download') instead of constant in
  Zotero.Sync.Data.Local.setSyncState()
- Misc storage tweaks
2015-12-30 05:14:50 -05:00
Dan Stillman
8933e3b586 Item.toJSON() should output unset mtime/md5 as null, not undefined 2015-12-22 01:49:45 -05:00
Dan Stillman
6d64526648 Ignore unknown fields in Zotero.Item::fromJSON() 2015-11-12 17:24:03 -05:00
Dan Stillman
c2ad4ceb0a Output 'deleted' as 1 instead of true in item JSON
Good idea? Not sure, but that's what the API does.
2015-10-30 19:07:12 -04:00
Dan Stillman
73f4d28ab2 ZFS file sync overhaul for API syncing
This mostly gets ZFS file syncing and file conflict resolution working
with the API sync process. WebDAV will need to be updated separately.

Known issues:

- File sync progress is temporarily gone
- File uploads can result in an unnecessary 412 loop on the next data
  sync
- This causes Firefox to crash on one of my computers during tests,
  which would be easier to debug if it produced a crash log.

Also:

- Adds httpd.js for use in tests when FakeXMLHttpRequest can't be used
  (e.g., saveURI()).
- Adds some additional test data files for attachment tests
2015-10-29 04:38:27 -04:00
Dan Stillman
7d8a1b2573 Make Zotero.DataObject#fromJSON() synchronous
When called on an identified object (i.e., one with an id or
library/key), loadAllData() must be called first. When called on a new
object (which is more common anyway), fromJSON() can be called
immediately.
2015-10-29 01:19:14 -04:00
Dan Stillman
493d37d1c7 Fix 100% CPU usage with pane open (since 9e356a7e6)
And make Zotero.Item.prototype.fileExists() check the file regardless of
whether there's a cached state.
2015-10-12 23:08:02 -04:00
Dan Stillman
9e356a7e63 Migrate relative/persistent descriptors to string paths [DB reupgrade]
Absolute paths have been stored as strings on all platforms for a while,
but old Mac persistent descriptors (Base64-encoded opaque alias records)
could still exist in the DB. Additionally, relative paths for stored
files were stored as Mozilla-specific opaque strings rather than UTF-8
strings.

This adds a schema step to convert those to strings paths in the DB.
Since Mac persistent descriptors aren't converted if the file isn't
found, we still handle and (convert) old-style persistent descriptors if
necessary when reading paths from the DB.

This also moves path string handling -- converting a path to a prefixed
string for stored or base-dir-relative files -- to the
Zotero.Item#attachmentPath setter instead of save() so that reading it
back immediately returns the correct value. One consequence is that the
attachment link mode must now be set before setting the path.

Zotero.Item#getFile() is now deprecated in favor of getFilePath() and
getFilePathAsync() (which checks file existence).

Zotero.File.directoryContains() now takes string paths instead of files.
2015-09-29 04:42:08 -04:00
Dan Stillman
cbf4876173 Fix attachment renaming
Fixes #822
2015-08-07 15:36:46 -04:00
Dan Stillman
536cd867d7 Fix toJSON for attachment items 2015-08-06 15:55:37 -04:00
Dan Stillman
0aecaad761 Update conflict resolution for API syncing
This will appear much less frequently, since non-conflicting field changes on
both sides can be resolved automatically, but genuine field conflicts still
require manual conflict resolution.

The merge pane is no longer editable, since the itembox code to do that is
async and can't run in a modal window, but it's not really necessary,
particularly with conflicts happening less frequently.

TODO:

- Remote item deletions
- File conflicts
- Maybe handle some edge cases where the conflicted items fail to save
2015-08-06 04:14:49 -04:00
Dan Stillman
4600318ad7 Support 'successful' property in upload response
Save uploaded data to cache, and update local object if necessary (which
it mostly shouldn't be except for invalid characters and HTML filtering
in notes)

Also add some upload and JSON tests
2015-08-01 05:28:42 -04:00
Dan Stillman
258b70b455 Throw an error saving an empty item with no item type 2015-07-20 04:15:27 -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
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
d476626c74 Change item.save() to item.saveTx() 2015-06-03 23:45:12 -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
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
Aurimas Vinckevicius
294f01bb3a Check if attempting to use a legacy generator function in Mocha tests 2015-06-02 13:34:51 -05: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
5a5a8a93f9 Zotero.Item::addTag() tests 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
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
a804efce67 Fix getAttachments()/getNotes() with no child items after save 2015-05-27 22:18:40 -04:00
Dan Stillman
19b8db590f Fixes #727, Duplicated items lose their creators 2015-05-24 04:55:54 -04:00
Dan Stillman
8f5d976479 Test saved version via property as well as getField() 2015-05-21 23:44:09 -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
a4e6e96d3c Use 2 seconds instead of 1 for closeTo() date tests
In case saving is real slow
2015-05-12 20:12:10 -04:00