Make editable/filesEditable required in Zotero.Libraries.add()
This commit is contained in:
parent
6c536fc784
commit
93b5694420
|
@ -221,11 +221,7 @@ Zotero.Group.prototype.save = Zotero.Promise.coroutine(function* () {
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
let { id: libraryID } = yield Zotero.Libraries.add(
|
let { id: libraryID } = yield Zotero.Libraries.add(
|
||||||
'group',
|
'group', this.editable, this.filesEditable
|
||||||
{
|
|
||||||
editable: this.editable,
|
|
||||||
filesEditable: this.filesEditable
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
sqlColumns.push('libraryID');
|
sqlColumns.push('libraryID');
|
||||||
sqlValues.push(libraryID);
|
sqlValues.push(libraryID);
|
||||||
|
|
|
@ -80,15 +80,12 @@ Zotero.Libraries = new function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} type - Library type
|
* @param {String} type - Library type
|
||||||
* @param {Object} [options] - Library properties to set
|
* @param {Boolean} editable
|
||||||
* @param {Boolean} [options.editable]
|
* @param {Boolean} filesEditable
|
||||||
* @param {Boolean} [options.filesEditable]
|
|
||||||
*/
|
*/
|
||||||
this.add = Zotero.Promise.coroutine(function* (type, options) {
|
this.add = Zotero.Promise.coroutine(function* (type, editable, filesEditable) {
|
||||||
Zotero.DB.requireTransaction();
|
Zotero.DB.requireTransaction();
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'group':
|
case 'group':
|
||||||
break;
|
break;
|
||||||
|
@ -99,17 +96,14 @@ Zotero.Libraries = new function () {
|
||||||
|
|
||||||
var libraryID = yield Zotero.ID.get('libraries');
|
var libraryID = yield Zotero.ID.get('libraries');
|
||||||
|
|
||||||
var sql = "INSERT INTO libraries (libraryID, libraryType";
|
var sql = "INSERT INTO libraries (libraryID, libraryType, editable, filesEditable) "
|
||||||
var params = [libraryID, type];
|
+ "VALUES (?, ?, ?, ?)";
|
||||||
if (options.editable) {
|
var params = [
|
||||||
sql += ", editable";
|
libraryID,
|
||||||
params.push(options.editable ? 1 : 0);
|
type,
|
||||||
if (options.filesEditable) {
|
editable ? 1 : 0,
|
||||||
sql += ", filesEditable";
|
filesEditable ? 1 : 0
|
||||||
params.push(options.filesEditable ? 1 : 0);
|
];
|
||||||
}
|
|
||||||
}
|
|
||||||
sql += ") VALUES (" + params.map(p => "?").join(", ") + ")";
|
|
||||||
yield Zotero.DB.queryAsync(sql, params);
|
yield Zotero.DB.queryAsync(sql, params);
|
||||||
|
|
||||||
// Re-fetch from DB to get auto-filled defaults
|
// Re-fetch from DB to get auto-filled defaults
|
||||||
|
@ -236,8 +230,8 @@ Zotero.Libraries = new function () {
|
||||||
return {
|
return {
|
||||||
id: row.libraryID,
|
id: row.libraryID,
|
||||||
type: row.libraryType,
|
type: row.libraryType,
|
||||||
editable: row.editable,
|
editable: !!row.editable,
|
||||||
filesEditable: row.filesEditable,
|
filesEditable: !!row.filesEditable,
|
||||||
version: row.version,
|
version: row.version,
|
||||||
lastSyncTime: row.lastsync != 0 ? new Date(row.lastsync * 1000) : false
|
lastSyncTime: row.lastsync != 0 ? new Date(row.lastsync * 1000) : false
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user