Fix for collections not refreshing on item delete (thanks Simon) and new snapshots not getting added to the active collection (since yesterday)
This commit is contained in:
parent
9762d768e1
commit
99f7badf42
|
@ -102,7 +102,7 @@
|
||||||
textbox.inputField.QueryInterface(CI.nsIDOMNSEditableElement).editor
|
textbox.inputField.QueryInterface(CI.nsIDOMNSEditableElement).editor
|
||||||
);
|
);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
Zotero.debug(ex);
|
// this throws an error on window open...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -795,20 +795,18 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
function addAttachmentFromPage(link, id)
|
function addAttachmentFromPage(link, id)
|
||||||
{
|
{
|
||||||
|
if (itemsView && itemsView._itemGroup.isCollection())
|
||||||
|
{
|
||||||
|
var parentCollectionID = itemsView._itemGroup.ref.getID();
|
||||||
|
}
|
||||||
|
|
||||||
if(link)
|
if(link)
|
||||||
{
|
{
|
||||||
var attachmentID =
|
Zotero.Attachments.linkFromDocument(window.content.document, id, parentCollectionID);
|
||||||
Zotero.Attachments.linkFromDocument(window.content.document, id);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var attachmentID =
|
Zotero.Attachments.importFromDocument(window.content.document, id, false, parentCollectionID);
|
||||||
Zotero.Attachments.importFromDocument(window.content.document, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attachmentID && itemsView && itemsView._itemGroup.isCollection())
|
|
||||||
{
|
|
||||||
itemsView._itemGroup.ref.addItem(attachmentID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
|
|
||||||
// TODO: what if called on file:// document?
|
// TODO: what if called on file:// document?
|
||||||
function linkFromDocument(document, sourceItemID){
|
function linkFromDocument(document, sourceItemID, parentCollectionIDs){
|
||||||
Zotero.debug('Linking attachment from document');
|
Zotero.debug('Linking attachment from document');
|
||||||
|
|
||||||
var url = document.location;
|
var url = document.location;
|
||||||
|
@ -269,6 +269,13 @@ Zotero.Attachments = new function(){
|
||||||
var itemID = _addToDB(null, url, title, this.LINK_MODE_LINKED_URL,
|
var itemID = _addToDB(null, url, title, this.LINK_MODE_LINKED_URL,
|
||||||
mimeType, charsetID, sourceItemID);
|
mimeType, charsetID, sourceItemID);
|
||||||
|
|
||||||
|
// Add to collections
|
||||||
|
var ids = Zotero.flattenArguments(parentCollectionIDs);
|
||||||
|
for each(var id in ids){
|
||||||
|
var col = Zotero.Collections.get(id);
|
||||||
|
col.addItem(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
// Run the fulltext indexer asynchronously (actually, it hangs the UI
|
// Run the fulltext indexer asynchronously (actually, it hangs the UI
|
||||||
// thread, but at least it lets the menu close)
|
// thread, but at least it lets the menu close)
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
@ -279,7 +286,7 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function importFromDocument(document, sourceItemID, forceTitle){
|
function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs){
|
||||||
Zotero.debug('Importing attachment from document');
|
Zotero.debug('Importing attachment from document');
|
||||||
|
|
||||||
var url = document.location;
|
var url = document.location;
|
||||||
|
@ -331,6 +338,13 @@ Zotero.Attachments = new function(){
|
||||||
_addToDB(file, url, title, Zotero.Attachments.LINK_MODE_IMPORTED_URL, mimeType,
|
_addToDB(file, url, title, Zotero.Attachments.LINK_MODE_IMPORTED_URL, mimeType,
|
||||||
charsetID, sourceItemID, itemID);
|
charsetID, sourceItemID, itemID);
|
||||||
|
|
||||||
|
// Add to collections
|
||||||
|
var ids = Zotero.flattenArguments(parentCollectionIDs);
|
||||||
|
for each(var id in ids){
|
||||||
|
var col = Zotero.Collections.get(id);
|
||||||
|
col.addItem(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
Zotero.Fulltext.indexDocument(document, itemID);
|
Zotero.Fulltext.indexDocument(document, itemID);
|
||||||
|
|
|
@ -1515,9 +1515,19 @@ Zotero.Item.prototype.erase = function(deleteChildren){
|
||||||
// Remove item from parent collections
|
// Remove item from parent collections
|
||||||
var parentCollectionIDs = this.getCollections();
|
var parentCollectionIDs = this.getCollections();
|
||||||
if (parentCollectionIDs){
|
if (parentCollectionIDs){
|
||||||
|
var notifierState = Zotero.Notifier.isEnabled();
|
||||||
|
Zotero.Notifier.disable();
|
||||||
|
|
||||||
for (var i=0; i<parentCollectionIDs.length; i++){
|
for (var i=0; i<parentCollectionIDs.length; i++){
|
||||||
Zotero.Collections.get(parentCollectionIDs[i]).removeItem(this.getID());
|
Zotero.Collections.get(parentCollectionIDs[i]).removeItem(this.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notifierState){
|
||||||
|
Zotero.Notifier.enable();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Zotero.Notifier.disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
|
@ -2331,7 +2341,7 @@ Zotero.Collection.prototype.removeItem = function(itemID){
|
||||||
// If this was the last item, set collection to empty
|
// If this was the last item, set collection to empty
|
||||||
if (!this._childItems.length){
|
if (!this._childItems.length){
|
||||||
this._hasChildItems = false;
|
this._hasChildItems = false;
|
||||||
// DEBUG: is this necessary?
|
// DEBUG: is this necessary? if so, it's no longer called during item deletes...
|
||||||
Zotero.Notifier.trigger('modify', 'collection', this.getID());
|
Zotero.Notifier.trigger('modify', 'collection', this.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,16 +105,19 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||||
|
|
||||||
var quicksearch = this._treebox.treeBody.ownerDocument.getElementById('tb-search');
|
var quicksearch = this._treebox.treeBody.ownerDocument.getElementById('tb-search');
|
||||||
|
|
||||||
if((action == 'remove' && !this._itemGroup.isLibrary())
|
if((action == 'remove' && !this._itemGroup.isLibrary()) || action == 'delete')
|
||||||
|| (action == 'delete' && (this._itemGroup.isLibrary() || this._itemGroup.isSearch())))
|
|
||||||
{
|
{
|
||||||
//Since a remove involves shifting of rows, we have to do it in order
|
//Since a remove involves shifting of rows, we have to do it in order
|
||||||
|
|
||||||
//sort the ids by row
|
//sort the ids by row
|
||||||
var rows = new Array();
|
var rows = new Array();
|
||||||
for(var i=0, len=ids.length; i<len; i++)
|
for(var i=0, len=ids.length; i<len; i++)
|
||||||
|
{
|
||||||
if(action == 'delete' || !this._itemGroup.ref.hasItem(ids[i]))
|
if(action == 'delete' || !this._itemGroup.ref.hasItem(ids[i]))
|
||||||
|
{
|
||||||
rows.push(this._itemRowMap[ids[i]]);
|
rows.push(this._itemRowMap[ids[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(rows.length > 0)
|
if(rows.length > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user