Integration refactor megacommit
- 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
This commit is contained in:
parent
f44d563a15
commit
5805c7e562
|
@ -74,8 +74,8 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
if(selectedItemIDs.length) {
|
if(selectedItemIDs.length) {
|
||||||
for (let itemID of selectedItemIDs) {
|
for (let itemID of selectedItemIDs) {
|
||||||
var itemIndexToSelect = false;
|
var itemIndexToSelect = false;
|
||||||
for(var i in bibEditInterface.bibliography[0].entry_ids) {
|
for(var i in bibEditInterface.bib[0].entry_ids) {
|
||||||
if(bibEditInterface.bibliography[0].entry_ids[i].indexOf(itemID) !== -1) {
|
if(bibEditInterface.bib[0].entry_ids[i].indexOf(itemID) !== -1) {
|
||||||
itemIndexToSelect = i;
|
itemIndexToSelect = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
*/
|
*/
|
||||||
function _getSelectedListItemIDs() {
|
function _getSelectedListItemIDs() {
|
||||||
return Array.from(_itemList.selectedItems)
|
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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,8 +287,8 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
|
|
||||||
editor.readonly = index === undefined;
|
editor.readonly = index === undefined;
|
||||||
if(index !== undefined) {
|
if(index !== undefined) {
|
||||||
var itemID = bibEditInterface.bibliography[0].entry_ids[index];
|
var itemID = bibEditInterface.bib[0].entry_ids[index];
|
||||||
editor.value = bibEditInterface.bibliography[1][index];
|
editor.value = bibEditInterface.bib[1][index];
|
||||||
_lastSelectedIndex = index;
|
_lastSelectedIndex = index;
|
||||||
_lastSelectedItemID = itemID;
|
_lastSelectedItemID = itemID;
|
||||||
_lastSelectedValue = editor.value;
|
_lastSelectedValue = editor.value;
|
||||||
|
@ -304,7 +304,7 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
* loads items from itemSet
|
* loads items from itemSet
|
||||||
*/
|
*/
|
||||||
function _loadItems() {
|
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]));
|
var items = itemIDs.map(itemID => Zotero.Cite.getItem(itemID[0]));
|
||||||
|
|
||||||
// delete all existing items from list
|
// delete all existing items from list
|
||||||
|
|
|
@ -16,13 +16,13 @@ Zotero.Cite = {
|
||||||
* Remove specified item IDs in-place from a citeproc-js bibliography object returned
|
* Remove specified item IDs in-place from a citeproc-js bibliography object returned
|
||||||
* by makeBibliography()
|
* by makeBibliography()
|
||||||
* @param {bib} citeproc-js bibliography object
|
* @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) {
|
"removeFromBibliography":function(bib, itemsToRemove) {
|
||||||
var removeItems = [];
|
var removeItems = [];
|
||||||
for(let i in bib[0].entry_ids) {
|
for(let i in bib[0].entry_ids) {
|
||||||
for(let j in bib[0].entry_ids[i]) {
|
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);
|
removeItems.push(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user