Commit graph

6446 commits

Author SHA1 Message Date
Aurimas Vinckevicius
e02945b591 Add a centralized, modular .save() method to DataObject
.save calls ._initSave(), _saveData(), _finalizeSave() internally passing `env` object to each to act as an environment for passing around variables
* _initSave should determine if the save is possible and return a promise for either `true` or `false`. It should also set up the environment, e.g. determine if this `isNew`
* _saveData performs the actual saving to the database, but should not do any terminal steps in the save process so that any extending classes could extend this method to write additional data to the database
* _finalizeSave should perform any finalization before the data is committed to the database.

_recoverFromSaveError is called with `env` and an error that occurred. This method should perform any recovery steps, e.g. discarding the save and reloading the item from the database into the cache.
2015-01-19 10:36:42 -06:00
Aurimas Vinckevicius
56f244a4bb Add id and libraryID getters for all data objects 2015-01-19 10:36:42 -06:00
Aurimas Vinckevicius
4657c46d4b getClassForObjectType => getObjectsClassForObjectType 2015-01-19 10:36:41 -06:00
Aurimas Vinckevicius
c222a3248a Transition __defineGetter/Setter__ to Zotero.defineProperty 2015-01-19 10:36:41 -06:00
Aurimas Vinckevicius
f7d5ebc357 Default to "configurable: true" in defineProperty 2015-01-19 10:36:41 -06:00
Aurimas Vinckevicius
29e9946123 Allow to define properties for late initialization via defineProperty 2015-01-19 10:35:33 -06:00
Aurimas Vinckevicius
d4bd0ee811 Move defineProperty from ZU.Internal to Zotero 2015-01-19 10:31:39 -06:00
Aurimas Vinckevicius
aca15c0d2d Fix deleting saved searches 2014-11-14 01:50:02 -06:00
Aurimas Vinckevicius
0e31e7ca01 Wait for the item pane to initialize before focusing first field 2014-11-14 01:50:02 -06:00
Dan Stillman
e4451d9002 Merge pull request #575 from aurimasv/async_db-av
Async DB tweaks (attempt 2)
2014-10-30 01:47:49 -04:00
Dan Stillman
efa8346d37 Create user library row in libraries table when initializing DB 2014-10-30 01:22:58 -04:00
Aurimas Vinckevicius
3f85ee73b3 Don't count on 0 being the user libraryID in Zotero.Libraries
Some other minor tweaks
2014-10-29 23:52:21 -05:00
Aurimas Vinckevicius
bc8a340c30 Virtualize data objects 2014-10-29 23:51:43 -05:00
Aurimas Vinckevicius
5ee40f6601 Add ZU.dom2text and Zotero.Utilities.Internal.getDOMDocument
* getDomDocument: returns a detached DOMDocument object
* dom2text (TODO): Currently just returns Node.textContent, but is intended to return Zotero-formatted string based on text formatting in the DOM and the Zotero.Item field that the text is meant for
2014-10-29 22:16:21 -05:00
Dan Stillman
f635d82ea6 Merge pull request #553 from aurimasv/async_db_if_exists
To be safe, DROP things only IF EXISTS for database upgrade.
2014-10-23 19:38:35 -04:00
Aurimas Vinckevicius
20564dd13a To be safe, DROP INDEX only _IF EXISTS_ for database upgrade.
Triggered by DROP INDEX fulltextItems_version, which apparently doesn't always exist.
2014-10-23 13:18:00 -05:00
Dan Stillman
5c94119c70 Fixes duplicates view for async DB
It's way too slow, though, since the whole list is regenerated after
merging.

Fixes #519

Also:

- The arguments to Zotero.Item.prototype.clone() have changed, and it no
  longer takes an existing item or copies primary data. To create an
  in-memory copy of an item, use the new Zotero.Item.prototype.copy().

- Zotero.Item.prototype.getUsedFields() now gets in-memory fields rather
  than the fields in the database
2014-10-10 04:49:39 -04:00
Dan Stillman
15d28014ed Fix creator type assignment in item box 2014-10-10 04:46:10 -04:00
Dan Stillman
7fa931425a Rename Zotero.Item.prototype.getCreatorsAPIData() to getCreatorsJSON
And add Zotero.Item.prototype.setCreators()
2014-10-10 04:46:09 -04:00
Dan Stillman
3c81067961 Use DB libraryID for check in Zotero.Libraries.getType()
Before, 'user' wouldn't be returned if the real libraryID was given for
the personal library.
2014-10-10 04:44:16 -04:00
Dan Stillman
7541106641 Update Bluebird to 2.3.5
Our modifications no longer include a custom yield handler to
automatically call all() on yielded arrays (which maintained Bluebird
1.x behavior). It's now necessary to call all() or similar explicitly.

Also fixed a few incorrect yields hidden by that behavior.
2014-10-09 14:21:10 -04:00
Dan Stillman
27804bb47c Fix database backup on userdata upgrade
Also uncomment standard backup age tests
2014-09-30 23:15:34 -04:00
Dan Stillman
e2d3cc3f0d Update zotero://select to use new URLs and wait for items list load
Closes #541
2014-09-23 01:13:38 -04:00
Dan Stillman
c917d9e30e Use only keys for collections and saved searches in search conditions
Previously, 'collection' and 'savedSearch' conditions used
"[libraryID]_[key]" format. Now, the condition should contain only a
key, and the libraryID will be drawn from either the search itself or a
libraryID search condition. Old-style conditions are still parsed if
provided.
2014-09-09 02:50:56 -04:00
Dan Stillman
985a5db0da Throw error if NULL libraryID is passed to DataObjects.getByLibraryAndKey() 2014-09-09 02:31:17 -04:00
Dan Stillman
755ead2119 Update zotero:// extensions (report, timeline, etc.) for async DB, and more
- Protocol handler extensions can now handle promises and can also make
  data available as it's ready instead of all at once (e.g., reports now
  output one entry at a time)
- zotero:// URL syntaxes are now more consistent and closer to the web
  API (old URLs should work, but some may currently be broken)

Also:

- Code to generate server API, currently available for testing via
  zotero://data URLs but eventually moving to HTTP -- zotero://data URLs match
  web API URLs, with a different prefix for the personal library (/library vs.
  /users/12345)
- Miscellaneous fixes to data objects

Under the hood:

- Extensions now return an AsyncChannel, which is an nsIChannel implementation
  that takes a promise-yielding generator that returns a string,
  nsIAsyncInputStream, or file that will be used for the channel's data
- New function Zotero.Utilities.Internal.getAsyncInputStream() takes a
  generator that yields either promises or strings and returns an async input
  stream filled with the yielded strings
- Zotero.Router parsers URLs and extract parameters
- Zotero.Item.toResponseJSON()
2014-09-09 00:36:29 -04:00
Dan Stillman
c5ee3651fe Don't try to load uncommitted files 2014-09-09 00:35:35 -04:00
Dan Stillman
ff5007fdea Fix error fetching empty file via File.getContentsAsync() 2014-09-09 00:35:35 -04:00
Dan Stillman
490d24f43b Merge branch 'master' into async_db 2014-09-09 00:34:18 -04:00
Dan Stillman
3d7a35addc Merge branch '4.0'
Conflicts:
	chrome/content/zotero/xpcom/zotero.js
	install.rdf
	update.rdf
2014-09-08 20:24:44 -04:00
Simon Kornblith
431185cc3a Merge pull request #531 from aurimasv/high-contrast
Use Mozilla's colors for itembox and tagbox background
2014-09-01 23:30:35 -04:00
Simon Kornblith
57da88ac3d Fix == use 2014-09-01 23:19:12 -04:00
Simon Kornblith
9146fb03d9 Merge pull request #536 from adam3smith/coinsfix
test for presence of author's firstName before using it
2014-09-01 23:18:39 -04:00
adam3smith
17c0f44e66 fix indenting 2014-09-01 19:25:10 -05:00
Simon Kornblith
9c3ec6f0be Fix DataCite under Fx 32 2014-09-01 20:00:31 -04:00
Simon Kornblith
79ed7e503e Fix MODS under Fx 32 2014-09-01 19:29:45 -04:00
Simon Kornblith
a09ff9c9ec Don't unwrap objects passed to chrome
Unwrapping objects also waives the Xray wrappers for contained objects,
which we need.
2014-09-01 18:42:24 -04:00
adam3smith
f973897d76 test for presence of author's firstName before using it 2014-09-01 14:31:51 -05:00
Simon Kornblith
5857368131 Update citeproc-js to 1.0.539 2014-09-01 15:04:52 -04:00
Dan Stillman
14a5643f38 Update submodules, repotime, versions 2014-09-01 14:56:01 -04:00
Simon Kornblith
ee35f7df41 Small fix to copyObject 2014-09-01 12:26:36 -04:00
Aurimas Vinckevicius
dc5ccffe43 Use Mozilla's colors for itembox and tagbox background
This way, the colors play nicely with Windows themes (e.g. high contrast)
Re https://forums.zotero.org/discussion/38870/make-zotero-fully-recognize-windowsff-high-contrast-themes/ and https://twitter.com/stuffilike2know/status/504167872567189504
2014-08-26 03:11:24 -05:00
Dan Stillman
9db4927f78 Scroll to new collections, and stay on same row when deleting collections 2014-08-12 22:19:59 -04:00
Dan Stillman
6dbcdb95f4 Fix variable name 2014-08-12 22:16:53 -04:00
Dan Stillman
38531ab172 Fix "Copy as HTML" checkbox disabling in Quick Copy site editor window 2014-08-12 21:49:38 -04:00
Dan Stillman
c729dc8a54 Fixes #522, [Async DB] Quick Copy is broken
Export depends on #520 (but still with a synchronous interface, somehow)
2014-08-12 21:49:30 -04:00
Dan Stillman
a67521e9dd Closes #500, Remove DOM_VK_ENTER 2014-08-12 19:18:29 -04:00
Dan Stillman
df67de125e Remove (non-async-compatible) REGEXP UDF in Zotero.DB.getNextName()
And remove UDF setup code

Duplicates view also used REGEXP, so we'll need to figure out another approach
for the async rewrite of that (#519). There are no other current UDF consumers,
so this closes #528.
2014-08-12 03:13:00 -04:00
Dan Stillman
2856b71f0b Remove some remaining synchronous queries in data objects
Fixes collection and search saving
2014-08-12 03:11:49 -04:00
Dan Stillman
78a8e6b622 Fix breakage from 278e06e58 - Zotero.DataObject signature changed 2014-08-12 02:09:45 -04:00