Setting a library's 'editable' to false should do same for 'filesEditable'
This commit is contained in:
parent
74d1cc193a
commit
88184b341b
2 changed files with 18 additions and 0 deletions
|
@ -250,13 +250,20 @@ Zotero.Library.prototype._set = function(prop, val) {
|
||||||
throw new Error('Cannot create library of type "' + val + '"');
|
throw new Error('Cannot create library of type "' + val + '"');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '_libraryEditable':
|
case '_libraryEditable':
|
||||||
case '_libraryFilesEditable':
|
case '_libraryFilesEditable':
|
||||||
if (['user', 'publications'].indexOf(this._libraryType) != -1) {
|
if (['user', 'publications'].indexOf(this._libraryType) != -1) {
|
||||||
throw new Error('Cannot change ' + prop + ' for ' + this._libraryType + ' library');
|
throw new Error('Cannot change ' + prop + ' for ' + this._libraryType + ' library');
|
||||||
}
|
}
|
||||||
val = !!val;
|
val = !!val;
|
||||||
|
|
||||||
|
// Setting 'editable' to false should also set 'filesEditable' to false
|
||||||
|
if (prop == '_libraryEditable' && !val) {
|
||||||
|
this._set('_libraryFilesEditable', false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '_libraryVersion':
|
case '_libraryVersion':
|
||||||
var newVal = Number.parseInt(val, 10);
|
var newVal = Number.parseInt(val, 10);
|
||||||
if (newVal != val) {
|
if (newVal != val) {
|
||||||
|
|
|
@ -81,6 +81,17 @@ describe("Zotero.Library", function() {
|
||||||
assert.isFalse(Zotero.Libraries.isEditable(library.libraryID), "sets editable in cache to false");
|
assert.isFalse(Zotero.Libraries.isEditable(library.libraryID), "sets editable in cache to false");
|
||||||
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT editable FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT editable FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should also set filesEditable to false", function* () {
|
||||||
|
let library = yield createGroup({ editable: true, filesEditable: true });
|
||||||
|
assert.isTrue(library.filesEditable);
|
||||||
|
|
||||||
|
library.editable = false;
|
||||||
|
yield library.saveTx();
|
||||||
|
assert.isFalse(library.filesEditable);
|
||||||
|
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT filesEditable FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
||||||
|
});
|
||||||
|
|
||||||
it("should not be settable for user and publications libraries", function* () {
|
it("should not be settable for user and publications libraries", function* () {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
assert.throws(function() {library.editable = false}, /^Cannot change _libraryEditable for user library$/, "does not allow setting user library as not editable");
|
assert.throws(function() {library.editable = false}, /^Cannot change _libraryEditable for user library$/, "does not allow setting user library as not editable");
|
||||||
|
|
Loading…
Reference in a new issue