Skip to content

Commit

Permalink
Integration refactor megacommit
Browse files Browse the repository at this point in the history
- Removed obsolete logic for citation.properties.deleted, which is no
  longer set anywhere
- Introduced a bibliography class
- BibliographyEditInterface no longer edits state
- Fields._processFields() now has linear flow because:
- Exception handling for missing items and corrupt fields reworked to be
  handled in relevant Field classes, so that the flow remains linear
- Document modifying functions (i.e. Fields.updateDocument()) now only
  called in Zotero.Integration.Interface functions instead of all over
  the place
- document.setDocPrefs() now called after every execCommand() since
  the cost is trivial, but that simplifies a bunch of logic
- Misc code cleanup

TODO at some point in the future:
- Move Integration.(init/delete)Pipe out
- Decouple references and clarify functions in Integration.Fields and
  Integration.Session
  • Loading branch information
adomasven committed Jan 3, 2018
1 parent f44d563 commit 5805c7e
Show file tree
Hide file tree
Showing 3 changed files with 647 additions and 863 deletions.
12 changes: 6 additions & 6 deletions chrome/content/zotero/integration/editBibliographyDialog.js
Expand Up @@ -74,8 +74,8 @@ var Zotero_Bibliography_Dialog = new function () {
if(selectedItemIDs.length) {
for (let itemID of selectedItemIDs) {
var itemIndexToSelect = false;
for(var i in bibEditInterface.bibliography[0].entry_ids) {
if(bibEditInterface.bibliography[0].entry_ids[i].indexOf(itemID) !== -1) {
for(var i in bibEditInterface.bib[0].entry_ids) {
if(bibEditInterface.bib[0].entry_ids[i].indexOf(itemID) !== -1) {
itemIndexToSelect = i;
continue;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ var Zotero_Bibliography_Dialog = new function () {
*/
function _getSelectedListItemIDs() {
return Array.from(_itemList.selectedItems)
.map(item => bibEditInterface.bibliography[0].entry_ids[item.value][0]);
.map(item => bibEditInterface.bib[0].entry_ids[item.value][0]);
}

/**
Expand Down Expand Up @@ -287,8 +287,8 @@ var Zotero_Bibliography_Dialog = new function () {

editor.readonly = index === undefined;
if(index !== undefined) {
var itemID = bibEditInterface.bibliography[0].entry_ids[index];
editor.value = bibEditInterface.bibliography[1][index];
var itemID = bibEditInterface.bib[0].entry_ids[index];
editor.value = bibEditInterface.bib[1][index];
_lastSelectedIndex = index;
_lastSelectedItemID = itemID;
_lastSelectedValue = editor.value;
Expand All @@ -304,7 +304,7 @@ var Zotero_Bibliography_Dialog = new function () {
* loads items from itemSet
*/
function _loadItems() {
var itemIDs = bibEditInterface.bibliography[0].entry_ids;
var itemIDs = bibEditInterface.bib[0].entry_ids;
var items = itemIDs.map(itemID => Zotero.Cite.getItem(itemID[0]));

// delete all existing items from list
Expand Down
4 changes: 2 additions & 2 deletions chrome/content/zotero/xpcom/cite.js
Expand Up @@ -16,13 +16,13 @@ Zotero.Cite = {
* Remove specified item IDs in-place from a citeproc-js bibliography object returned
* by makeBibliography()
* @param {bib} citeproc-js bibliography object
* @param {Array} itemsToRemove Array of items to remove
* @param {Set} itemsToRemove Set of items to remove
*/
"removeFromBibliography":function(bib, itemsToRemove) {
var removeItems = [];
for(let i in bib[0].entry_ids) {
for(let j in bib[0].entry_ids[i]) {
if(itemsToRemove[bib[0].entry_ids[i][j]]) {
if(itemsToRemove.has(`${bib[0].entry_ids[i][j]}`)) {
removeItems.push(i);
break;
}
Expand Down

0 comments on commit 5805c7e

Please sign in to comment.