Fix dragging to My Publications
Also: - Don't show file options if only linked files - Don't set Rights field to "All Rights Reserved" if no files
This commit is contained in:
parent
f01fe2801d
commit
02198b12fe
3 changed files with 75 additions and 110 deletions
|
@ -130,8 +130,9 @@ const Zotero_Publications_Dialog = { // eslint-disable-line no-unused-vars, came
|
||||||
onFinish() {
|
onFinish() {
|
||||||
this.io.includeFiles = id('include-files').checked;
|
this.io.includeFiles = id('include-files').checked;
|
||||||
this.io.includeNotes = id('include-notes').checked;
|
this.io.includeNotes = id('include-notes').checked;
|
||||||
this.io.keepRights = id('keep-rights-checkbox').checked;
|
this.io.keepRights = true;
|
||||||
if (this.wizard.currentPage.pageid !== 'intro') {
|
if (this.wizard.currentPage.pageid !== 'intro') {
|
||||||
|
this.io.keepRights = id('keep-rights-checkbox').checked;
|
||||||
this.io.license = getLicense(
|
this.io.license = getLicense(
|
||||||
id('sharing-radiogroup').selectedItem.value,
|
id('sharing-radiogroup').selectedItem.value,
|
||||||
id('choose-adaptations').selectedItem.value,
|
id('choose-adaptations').selectedItem.value,
|
||||||
|
|
|
@ -5009,7 +5009,7 @@ var ZoteroPane = new function()
|
||||||
if (!io.hasFiles && item.numAttachments()) {
|
if (!io.hasFiles && item.numAttachments()) {
|
||||||
let attachmentIDs = item.getAttachments();
|
let attachmentIDs = item.getAttachments();
|
||||||
io.hasFiles = Zotero.Items.get(attachmentIDs).some(
|
io.hasFiles = Zotero.Items.get(attachmentIDs).some(
|
||||||
attachment => attachment.isFileAttachment()
|
attachment => attachment.isStoredFileAttachment()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Notes
|
// Notes
|
||||||
|
@ -5026,7 +5026,7 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
io.hasRights = allItemsHaveRights ? 'all' : (noItemsHaveRights ? 'none' : 'some');
|
io.hasRights = allItemsHaveRights ? 'all' : (noItemsHaveRights ? 'none' : 'some');
|
||||||
window.openDialog('chrome://zotero/content/publicationsDialog.xhtml','','chrome,modal', io);
|
window.openDialog('chrome://zotero/content/publicationsDialog.xhtml','','chrome,modal', io);
|
||||||
return io.license ? io : false;
|
return io.keepRights !== undefined ? io : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -674,87 +674,87 @@ describe("Zotero.CollectionTree", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("My Publications", function () {
|
describe("My Publications", function () {
|
||||||
it("should add an item to My Publications", function* () {
|
function getItemModifyPromise(item) {
|
||||||
|
// Add observer to wait for item modification
|
||||||
|
return new Zotero.Promise((resolve) => {
|
||||||
|
var observerID = Zotero.Notifier.registerObserver({
|
||||||
|
notify: function (event, type, ids, extraData) {
|
||||||
|
if (type == 'item' && event == 'modify' && ids[0] == item.id) {
|
||||||
|
setTimeout(resolve);
|
||||||
|
Zotero.Notifier.unregisterObserver(observerID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 'item', 'test');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function acceptItemsWithoutFiles(win) {
|
||||||
|
var doc = win.document;
|
||||||
|
doc.getElementById('confirm-authorship-checkbox').checked = true;
|
||||||
|
var wizard = doc.getElementById('publications-dialog-wizard');
|
||||||
|
if (!doc.getElementById('include-files').disabled) {
|
||||||
|
throw new Error("Include Files checkbox isn't disabled");
|
||||||
|
}
|
||||||
|
wizard.getButton('next').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function acceptItemsWithFiles(win) {
|
||||||
|
var doc = win.document;
|
||||||
|
doc.getElementById('include-files').checked = true;
|
||||||
|
doc.getElementById('confirm-authorship-checkbox').checked = true;
|
||||||
|
var wizard = doc.getElementById('publications-dialog-wizard');
|
||||||
|
if (doc.getElementById('include-files').disabled) {
|
||||||
|
throw new Error("Include Files checkbox shouldn't be disabled");
|
||||||
|
}
|
||||||
|
wizard.getButton('next').click();
|
||||||
|
wizard.getButton('next').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should add an item to My Publications", async function () {
|
||||||
// Remove other items in My Publications
|
// Remove other items in My Publications
|
||||||
var s = new Zotero.Search();
|
var s = new Zotero.Search();
|
||||||
s.addCondition('libraryID', 'is', Zotero.Libraries.userLibraryID);
|
s.addCondition('libraryID', 'is', Zotero.Libraries.userLibraryID);
|
||||||
s.addCondition('publications', 'true');
|
s.addCondition('publications', 'true');
|
||||||
var ids = yield s.search();
|
var ids = await s.search();
|
||||||
yield Zotero.Items.erase(ids);
|
await Zotero.Items.erase(ids);
|
||||||
|
|
||||||
var item = yield createDataObject('item', false, { skipSelect: true });
|
var item = await createDataObject('item', false, { skipSelect: true });
|
||||||
var libraryID = item.libraryID;
|
var libraryID = item.libraryID;
|
||||||
|
|
||||||
var stub = sinon.stub(zp, "showPublicationsWizard")
|
var itemModifyPromise = getItemModifyPromise(item);
|
||||||
.returns({
|
var winPromise = waitForWindow('chrome://zotero/content/publicationsDialog.xhtml')
|
||||||
includeNotes: false,
|
var dropPromise = onDrop('item', 'P' + libraryID, [item.id], itemModifyPromise);
|
||||||
includeFiles: false,
|
acceptItemsWithoutFiles(await winPromise);
|
||||||
keepRights: true
|
await dropPromise;
|
||||||
});
|
|
||||||
|
|
||||||
// Add observer to wait for item modification
|
|
||||||
var deferred = Zotero.Promise.defer();
|
|
||||||
var observerID = Zotero.Notifier.registerObserver({
|
|
||||||
notify: function (event, type, ids, extraData) {
|
|
||||||
if (type == 'item' && event == 'modify' && ids[0] == item.id) {
|
|
||||||
setTimeout(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 'item', 'test');
|
|
||||||
|
|
||||||
yield onDrop('item', 'P' + libraryID, [item.id], deferred.promise);
|
|
||||||
|
|
||||||
Zotero.Notifier.unregisterObserver(observerID);
|
|
||||||
stub.restore();
|
|
||||||
|
|
||||||
// Select publications and check for item
|
// Select publications and check for item
|
||||||
yield cv.selectByID("P" + libraryID);
|
await cv.selectByID("P" + libraryID);
|
||||||
yield waitForItemsLoad(win);
|
await waitForItemsLoad(win);
|
||||||
var itemsView = win.ZoteroPane.itemsView
|
var itemsView = win.ZoteroPane.itemsView
|
||||||
assert.equal(itemsView.rowCount, 1);
|
assert.equal(itemsView.rowCount, 1);
|
||||||
var treeRow = itemsView.getRow(0);
|
var treeRow = itemsView.getRow(0);
|
||||||
assert.equal(treeRow.ref.id, item.id);
|
assert.equal(treeRow.ref.id, item.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add an item with a file attachment to My Publications", function* () {
|
it("should add an item with a file attachment to My Publications", async function () {
|
||||||
var item = yield createDataObject('item', false, { skipSelect: true });
|
var item = await createDataObject('item', false, { skipSelect: true });
|
||||||
var attachment = yield importFileAttachment('test.png', { parentItemID: item.id });
|
var attachment = await importFileAttachment('test.png', { parentItemID: item.id });
|
||||||
var libraryID = item.libraryID;
|
var libraryID = item.libraryID;
|
||||||
|
|
||||||
var stub = sinon.stub(zp, "showPublicationsWizard")
|
var itemModifyPromise = getItemModifyPromise(item);
|
||||||
.returns({
|
var winPromise = waitForWindow('chrome://zotero/content/publicationsDialog.xhtml')
|
||||||
includeNotes: false,
|
var dropPromise = onDrop('item', 'P' + libraryID, [item.id], itemModifyPromise);
|
||||||
includeFiles: true,
|
acceptItemsWithFiles(await winPromise);
|
||||||
keepRights: true
|
await dropPromise;
|
||||||
});
|
|
||||||
|
|
||||||
// Add observer to wait for modify
|
|
||||||
var deferred = Zotero.Promise.defer();
|
|
||||||
var observerID = Zotero.Notifier.registerObserver({
|
|
||||||
notify: function (event, type, ids, extraData) {
|
|
||||||
if (type == 'item' && event == 'modify' && ids[0] == item.id) {
|
|
||||||
setTimeout(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 'item', 'test');
|
|
||||||
|
|
||||||
yield onDrop('item', 'P' + libraryID, [item.id], deferred.promise);
|
|
||||||
|
|
||||||
Zotero.Notifier.unregisterObserver(observerID);
|
|
||||||
stub.restore();
|
|
||||||
|
|
||||||
assert.isTrue(item.inPublications);
|
assert.isTrue(item.inPublications);
|
||||||
// File attachment should be in My Publications
|
// File attachment should be in My Publications
|
||||||
assert.isTrue(attachment.inPublications);
|
assert.isTrue(attachment.inPublications);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add an item with a linked URL attachment to My Publications", function* () {
|
it("should add an item with a linked URL attachment to My Publications", async function () {
|
||||||
var item = yield createDataObject('item', false, { skipSelect: true });
|
var item = await createDataObject('item', false, { skipSelect: true });
|
||||||
var attachment = yield Zotero.Attachments.linkFromURL({
|
var attachment = await Zotero.Attachments.linkFromURL({
|
||||||
parentItemID: item.id,
|
parentItemID: item.id,
|
||||||
title: 'Test',
|
title: 'Test',
|
||||||
url: 'http://127.0.0.1/',
|
url: 'http://127.0.0.1/',
|
||||||
|
@ -762,38 +762,20 @@ describe("Zotero.CollectionTree", function() {
|
||||||
});
|
});
|
||||||
var libraryID = item.libraryID;
|
var libraryID = item.libraryID;
|
||||||
|
|
||||||
var stub = sinon.stub(zp, "showPublicationsWizard")
|
var itemModifyPromise = getItemModifyPromise(item);
|
||||||
.returns({
|
var winPromise = waitForWindow('chrome://zotero/content/publicationsDialog.xhtml')
|
||||||
includeNotes: false,
|
var dropPromise = onDrop('item', 'P' + libraryID, [item.id], itemModifyPromise);
|
||||||
includeFiles: false,
|
acceptItemsWithoutFiles(await winPromise);
|
||||||
keepRights: true
|
await dropPromise;
|
||||||
});
|
|
||||||
|
|
||||||
// Add observer to wait for modify
|
|
||||||
var deferred = Zotero.Promise.defer();
|
|
||||||
var observerID = Zotero.Notifier.registerObserver({
|
|
||||||
notify: function (event, type, ids, extraData) {
|
|
||||||
if (type == 'item' && event == 'modify' && ids[0] == item.id) {
|
|
||||||
setTimeout(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 'item', 'test');
|
|
||||||
|
|
||||||
yield onDrop('item', 'P' + libraryID, [item.id], deferred.promise);
|
|
||||||
|
|
||||||
Zotero.Notifier.unregisterObserver(observerID);
|
|
||||||
stub.restore();
|
|
||||||
|
|
||||||
assert.isTrue(item.inPublications);
|
assert.isTrue(item.inPublications);
|
||||||
// Link attachment should be in My Publications
|
// Link attachment should be in My Publications
|
||||||
assert.isTrue(attachment.inPublications);
|
assert.isTrue(attachment.inPublications);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shouldn't add linked file attachment to My Publications", function* () {
|
it("shouldn't add linked file attachment to My Publications", async function () {
|
||||||
var item = yield createDataObject('item', false, { skipSelect: true });
|
var item = await createDataObject('item', false, { skipSelect: true });
|
||||||
var attachment = yield Zotero.Attachments.linkFromFile({
|
var attachment = await Zotero.Attachments.linkFromFile({
|
||||||
parentItemID: item.id,
|
parentItemID: item.id,
|
||||||
title: 'Test',
|
title: 'Test',
|
||||||
file: OS.Path.join(getTestDataDirectory().path, 'test.png'),
|
file: OS.Path.join(getTestDataDirectory().path, 'test.png'),
|
||||||
|
@ -801,29 +783,11 @@ describe("Zotero.CollectionTree", function() {
|
||||||
});
|
});
|
||||||
var libraryID = item.libraryID;
|
var libraryID = item.libraryID;
|
||||||
|
|
||||||
var stub = sinon.stub(zp, "showPublicationsWizard")
|
var itemModifyPromise = getItemModifyPromise(item);
|
||||||
.returns({
|
var winPromise = waitForWindow('chrome://zotero/content/publicationsDialog.xhtml')
|
||||||
includeNotes: false,
|
var dropPromise = onDrop('item', 'P' + libraryID, [item.id], itemModifyPromise);
|
||||||
includeFiles: false,
|
acceptItemsWithoutFiles(await winPromise);
|
||||||
keepRights: true
|
await dropPromise;
|
||||||
});
|
|
||||||
|
|
||||||
// Add observer to wait for modify
|
|
||||||
var deferred = Zotero.Promise.defer();
|
|
||||||
var observerID = Zotero.Notifier.registerObserver({
|
|
||||||
notify: function (event, type, ids, extraData) {
|
|
||||||
if (type == 'item' && event == 'modify' && ids[0] == item.id) {
|
|
||||||
setTimeout(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 'item', 'test');
|
|
||||||
|
|
||||||
yield onDrop('item', 'P' + libraryID, [item.id], deferred.promise);
|
|
||||||
|
|
||||||
Zotero.Notifier.unregisterObserver(observerID);
|
|
||||||
stub.restore();
|
|
||||||
|
|
||||||
assert.isTrue(item.inPublications);
|
assert.isTrue(item.inPublications);
|
||||||
// Linked URL attachment shouldn't be in My Publications
|
// Linked URL attachment shouldn't be in My Publications
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue