Connector server: respond with collection editability status

This commit is contained in:
Adomas Venčkauskas 2017-07-18 17:13:22 +03:00
parent cd35962435
commit ece3491e21

View File

@ -348,16 +348,8 @@ Zotero.Server.Connector.SaveItem.prototype = {
// My Library if present and editable, and otherwise fail // My Library if present and editable, and otherwise fail
var library = Zotero.Libraries.get(libraryID); var library = Zotero.Libraries.get(libraryID);
if (!library.editable || library.libraryType == 'publications') { if (!library.editable || library.libraryType == 'publications') {
let userLibrary = Zotero.Libraries.userLibrary;
if (userLibrary && userLibrary.editable) {
yield zp.collectionsView.selectLibrary(userLibrary.id);
libraryID = userLibrary.id;
collection = null;
}
else {
Zotero.logError("Can't add item to read-only library " + library.name); Zotero.logError("Can't add item to read-only library " + library.name);
return 500; return [500, "application/json", JSON.stringify({libraryEditable: false})];
}
} }
var cookieSandbox = data.uri var cookieSandbox = data.uri
@ -730,7 +722,9 @@ Zotero.Server.Connector.GetSelectedCollection.prototype = {
}; };
if (libraryID) { if (libraryID) {
response.libraryName = Zotero.Libraries.getName(libraryID); let library = Zotero.Libraries.get(libraryID);
response.libraryName = library.name;
response.libraryEditable = library.editable;
} else { } else {
response.libraryName = Zotero.getString("pane.collections.library"); response.libraryName = Zotero.getString("pane.collections.library");
} }