Fix group.fromJSON() with no 'admins' or 'members' arrays
This commit is contained in:
parent
79f0e4761f
commit
4f155e3432
2 changed files with 7 additions and 3 deletions
|
@ -192,6 +192,10 @@ Zotero.Group.prototype.save = Zotero.Promise.coroutine(function* () {
|
|||
throw new Error("Group id not set");
|
||||
}
|
||||
|
||||
if (!this.name) {
|
||||
throw new Error("Group name not set");
|
||||
}
|
||||
|
||||
if (!this._changed) {
|
||||
Zotero.debug("Group " + this.id + " has not changed");
|
||||
return false;
|
||||
|
@ -319,14 +323,14 @@ Zotero.Group.prototype.fromJSON = function (json, userID) {
|
|||
if (userID) {
|
||||
// If user is owner or admin, make library editable, and make files editable unless they're
|
||||
// disabled altogether
|
||||
if (json.owner == userID || json.admins.indexOf(userID) != -1) {
|
||||
if (json.owner == userID || (json.admins && json.admins.indexOf(userID) != -1)) {
|
||||
editable = true;
|
||||
if (json.fileEditing != 'none') {
|
||||
filesEditable = true;
|
||||
}
|
||||
}
|
||||
// If user is member, make library and files editable if they're editable by all members
|
||||
else if (json.members.indexOf(userID) != -1) {
|
||||
else if (json.members && json.members.indexOf(userID) != -1) {
|
||||
if (json.libraryEditing == 'members') {
|
||||
editable = true;
|
||||
if (json.fileEditing == 'members') {
|
||||
|
|
|
@ -133,7 +133,7 @@ describe("Zotero.Group", function () {
|
|||
owner: 1,
|
||||
libraryEditing: 'members',
|
||||
fileEditing: 'none',
|
||||
admins: [2],
|
||||
// No admins
|
||||
members: [3]
|
||||
}, 3);
|
||||
assert.isTrue(group.editable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue