mirror of
https://github.com/zotero/zotero.git
synced 2026-10-04 02:31:47 +00:00
return tags in /connector/getSelectedCollection
Together with all collections and libraries. To account for tags that may contain "," characters, expect connector to send tags as an array. If tags are sent as a string, it will be split by "," for compatibility with older connector versions. Addresses: #1706
This commit is contained in:
parent
408f1274f4
commit
e6ce021b5f
2 changed files with 13 additions and 5 deletions
|
|
@ -169,7 +169,7 @@ Zotero.Server.Connector.SaveSession = class {
|
|||
async update(targetID, tags, note) {
|
||||
var previousTargetID = this._currentTargetID;
|
||||
this._currentTargetID = targetID;
|
||||
this._currentTags = tags || "";
|
||||
this._currentTags = tags || [];
|
||||
this._currentNote = note || "";
|
||||
|
||||
// Select new destination in collections pane
|
||||
|
|
@ -206,8 +206,7 @@ Zotero.Server.Connector.SaveSession = class {
|
|||
var { library, collection } = Zotero.Server.Connector.resolveTarget(this._currentTargetID);
|
||||
var libraryID = library.libraryID;
|
||||
|
||||
var tags = this._currentTags.trim();
|
||||
tags = tags ? tags.split(/\s*,\s*/).filter(x => x) : [];
|
||||
var tags = this._currentTags.map(tag => tag.trim()).filter(tag => tag);
|
||||
|
||||
Zotero.debug("Updating items for connector save session " + this.id);
|
||||
|
||||
|
|
|
|||
|
|
@ -760,6 +760,11 @@ Zotero.Server.Connector.UpdateSession.prototype = {
|
|||
// Parse treeViewID
|
||||
var [type, id] = [data.target[0], parseInt(data.target.substr(1))];
|
||||
var tags = data.tags;
|
||||
// Older connector versions send tags as one string with comma as delimiter
|
||||
// To account for tags that contain commas, later versions send an array of strings
|
||||
if (typeof tags === 'string') {
|
||||
tags = tags.split(",");
|
||||
}
|
||||
var note = data.note;
|
||||
|
||||
if (type == 'C') {
|
||||
|
|
@ -931,7 +936,7 @@ Zotero.Server.Connector.GetSelectedCollection.prototype = {
|
|||
* @param {String} data POST data or GET query string
|
||||
* @param {Function} sendResponseCallback function to send HTTP response
|
||||
*/
|
||||
init: function(postData, sendResponseCallback) {
|
||||
init: async function(postData, sendResponseCallback) {
|
||||
let allowReadOnly = (postData.hasOwnProperty("switchToReadableLibrary")) ? !postData.switchToReadableLibrary : true;
|
||||
var { library, collection, editable } = Zotero.Server.Connector.getSaveTarget(allowReadOnly);
|
||||
var response = {
|
||||
|
|
@ -950,12 +955,14 @@ Zotero.Server.Connector.GetSelectedCollection.prototype = {
|
|||
response.name = response.libraryName;
|
||||
}
|
||||
|
||||
// Get list of editable libraries and collections
|
||||
// Get list of editable libraries, collections, and tags
|
||||
var collections = [];
|
||||
let tags = {};
|
||||
var originalLibraryID = library.libraryID;
|
||||
for (let library of Zotero.Libraries.getAll()) {
|
||||
if (!library.editable) continue;
|
||||
|
||||
tags[library.treeViewID] = await Zotero.Tags.getAll(library.libraryID);
|
||||
// Add recent: true for recent targets
|
||||
|
||||
collections.push(
|
||||
|
|
@ -974,6 +981,7 @@ Zotero.Server.Connector.GetSelectedCollection.prototype = {
|
|||
);
|
||||
}
|
||||
response.targets = collections;
|
||||
response.tags = tags;
|
||||
|
||||
// Mark recent targets
|
||||
try {
|
||||
|
|
@ -1105,6 +1113,7 @@ Zotero.Server.Connector.Ping.prototype = {
|
|||
automaticSnapshots: Zotero.Prefs.get('automaticSnapshots'),
|
||||
downloadAssociatedFiles: Zotero.Prefs.get("downloadAssociatedFiles"),
|
||||
supportsAttachmentUpload: true,
|
||||
supportsTagsAutocomplete: true,
|
||||
googleDocsAddNoteEnabled: true,
|
||||
canUserAddNote: true,
|
||||
googleDocsCitationExplorerEnabled: false,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue