[interface] collection stays selected on drag-and-drop.

[interface] Collections notify() cleaned up a bit.
This commit is contained in:
David Norton 2006-06-08 21:47:33 +00:00
parent 9daa0d3303
commit 14ba1b8fbc

View file

@ -81,27 +81,20 @@ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
this._treebox.invalidate(); this._treebox.invalidate();
this._treebox.endUpdateBatch(); this._treebox.endUpdateBatch();
} }
else else if(action == 'modify')
{ {
ids = Scholar.flattenArguments(ids); var row = this._collectionRowMap[ids];
for (var i=0, len=ids.length; i<len; i++) if(row != null)
{ this._treebox.invalidateRow(row);
}
else if(action == 'add')
{
var item = Scholar.Collections.get(ids);
var row = this._collectionRowMap[ids[i]]; this._showItem(new Scholar.ItemGroup('collection',item), 0, this.rowCount);
if(action == 'modify' && row != null) //must check for null because it could legitimately be 0 this._treebox.rowCountChanged(this.rowCount-1,1);
{
this._treebox.invalidateRow(row) madeChanges = true;
}
else if(action == 'add' && row == null)
{
var item = Scholar.Collections.get(ids[i]);
this._showItem(new Scholar.ItemGroup('collection',item), 0, this.rowCount);
this._treebox.rowCountChanged(this.rowCount-1,1);
madeChanges = true;
}
}
} }
if(madeChanges) if(madeChanges)
@ -292,6 +285,16 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
targetCollectionID = this._getItemAtRow(row).ref.getID(); targetCollectionID = this._getItemAtRow(row).ref.getID();
var droppedCollection = Scholar.Collections.get(ids[0]); var droppedCollection = Scholar.Collections.get(ids[0]);
droppedCollection.changeParent(targetCollectionID); droppedCollection.changeParent(targetCollectionID);
var selectRow = this._collectionRowMap[ids[0]];
if(selectRow == null)
selectRow = this._collectionRowMap[targetCollectionID];
this.selection.selectEventsSuppressed = true;
this.selection.clearSelection();
this.selection.select(selectRow);
this.selection.selectEventsSuppressed = false;
} }
else if(dataType == 'scholar/item' && this.canDrop(row, orient)) else if(dataType == 'scholar/item' && this.canDrop(row, orient))
{ {