[interface] itemsTreeView correctly handles notify(erase)
[data access] Collection.removeItem() calls trigger() with the right type
This commit is contained in:
parent
14ba1b8fbc
commit
9f7437f5ca
2 changed files with 19 additions and 27 deletions
|
@ -191,20 +191,20 @@ Scholar.ItemTreeView.prototype.getCollectionID = function()
|
|||
//CALLED BY DATA LAYER ON CHANGE:
|
||||
Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||
{
|
||||
ids = Scholar.flattenArguments(ids);
|
||||
var madeChanges = false;
|
||||
|
||||
this.selection.selectEventsSuppressed = true;
|
||||
this.saveSelection();
|
||||
|
||||
if(action == 'remove')
|
||||
if((action == 'remove' && !this._itemGroup.isLibrary()) || (action == 'delete' && this._itemGroup.isLibrary()))
|
||||
{
|
||||
ids = Scholar.flattenArguments(ids);
|
||||
//Since a remove involves shifting of rows, we have to do it in order
|
||||
|
||||
//sort the ids by row
|
||||
var rows = new Array();
|
||||
for(var i=0, len=ids.length; i<len; i++)
|
||||
if(this._itemRowMap[ids[i]] != null)
|
||||
if(action == 'delete' || !this._itemGroup.ref.hasItem(ids[i]))
|
||||
rows.push(this._itemRowMap[ids[i]]);
|
||||
|
||||
if(rows.length > 0)
|
||||
|
@ -222,32 +222,24 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
}
|
||||
|
||||
}
|
||||
else
|
||||
else if(action == 'modify') //must check for null because it could legitimately be 0
|
||||
{
|
||||
for (var i=0, len=ids.length; i<len; i++)
|
||||
if(this._itemRowMap[ids])
|
||||
{
|
||||
|
||||
var row = this._itemRowMap[ids[i]];
|
||||
if(action == 'modify' && row != null) //must check for null because it could legitimately be 0
|
||||
{
|
||||
var item = Scholar.Items.get(ids[i]);
|
||||
this._treebox.invalidateRow(row);
|
||||
madeChanges = true;
|
||||
}
|
||||
}
|
||||
else if(action == 'add')
|
||||
{
|
||||
var item = Scholar.Items.get(ids);
|
||||
|
||||
this._treebox.invalidateRow(row);
|
||||
madeChanges = true;
|
||||
}
|
||||
else if(action == 'add' && row == null)
|
||||
{
|
||||
var item = Scholar.Items.get(ids[i]);
|
||||
|
||||
if(this._itemGroup.isLibrary() || item.inCollection(this.getCollectionID()))
|
||||
{
|
||||
this._showItem(item,this.rowCount);
|
||||
this._treebox.rowCountChanged(this.rowCount-1,1);
|
||||
}
|
||||
|
||||
madeChanges = true;
|
||||
}
|
||||
|
||||
if(this._itemGroup.isLibrary() || item.inCollection(this.getCollectionID()))
|
||||
{
|
||||
this._showItem(item,this.rowCount);
|
||||
this._treebox.rowCountChanged(this.rowCount-1,1);
|
||||
|
||||
madeChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1234,7 +1234,7 @@ Scholar.Collection.prototype.removeItem = function(itemID){
|
|||
// If this was the last item, set collection to empty
|
||||
if (!this._childItems.length){
|
||||
this._hasChildItems = false;
|
||||
Scholar.Notifier.trigger('modify', 'collections', this.getID());
|
||||
Scholar.Notifier.trigger('modify', 'collection', this.getID());
|
||||
}
|
||||
|
||||
Scholar.Notifier.trigger('remove', 'item', itemID);
|
||||
|
|
Loading…
Reference in a new issue