Interface code for delete selected collection. (doesn't the function deleteCollectionSelection just sound great?)
Although I do not yet have interface code for it, collections do not have any sort of setName(), save() functions. Collections list now implements notify()
This commit is contained in:
parent
fdd8245eec
commit
2a117168a9
|
@ -4,6 +4,70 @@ Scholar.FolderTreeView = function()
|
||||||
this._dataItems = new Array();
|
this._dataItems = new Array();
|
||||||
this.rowCount = 0;
|
this.rowCount = 0;
|
||||||
this._showItem(new Scholar.ItemGroup('library',null),0,1);
|
this._showItem(new Scholar.ItemGroup('library',null),0,1);
|
||||||
|
this._unregisterID = Scholar.Notifier.registerColumnTree(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Scholar.FolderTreeView.prototype.unregister = function()
|
||||||
|
{
|
||||||
|
Scholar.Notifier.unregisterColumnTree(this._unregisterID);
|
||||||
|
}
|
||||||
|
|
||||||
|
//CALLED BY DATA LAYER ON CHANGE:
|
||||||
|
Scholar.FolderTreeView.prototype.notify = function(action, type, ids)
|
||||||
|
{
|
||||||
|
ids = Scholar.flattenArguments(ids);
|
||||||
|
var madeChanges = false;
|
||||||
|
|
||||||
|
if(action == 'remove')
|
||||||
|
{
|
||||||
|
//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._collectionRowMap[ids[i]] != null)
|
||||||
|
rows.push(this._collectionRowMap[ids[i]]);
|
||||||
|
|
||||||
|
if(rows.length > 0)
|
||||||
|
{
|
||||||
|
rows.sort(function(a,b) { return a-b });
|
||||||
|
|
||||||
|
for(var i=0, len=rows.length; i<len; i++)
|
||||||
|
{
|
||||||
|
var row = rows[i];
|
||||||
|
this._hideItem(row-i);
|
||||||
|
this._treebox.rowCountChanged(row-i,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
madeChanges = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var i=0, len=ids.length; i<len; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
var row = this._collectionRowMap[ids[i]];
|
||||||
|
if(action == 'modify' && row != null) //must check for null because it could legitimately be 0
|
||||||
|
{
|
||||||
|
this._treebox.invalidateRow(row)
|
||||||
|
}
|
||||||
|
else if(action == 'add' && row == null)
|
||||||
|
{
|
||||||
|
var item = Scholar.Items.get(ids[i]);
|
||||||
|
|
||||||
|
this._showItem(item,this.rowCount);
|
||||||
|
this._treebox.rowCountChanged(this.rowCount,1);
|
||||||
|
|
||||||
|
madeChanges = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(madeChanges)
|
||||||
|
this._refreshHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.FolderTreeView.prototype.setTree = function(treebox)
|
Scholar.FolderTreeView.prototype.setTree = function(treebox)
|
||||||
|
@ -121,7 +185,6 @@ Scholar.FolderTreeView.prototype.getProgressMode = function(row, col) { }
|
||||||
|
|
||||||
Scholar.FolderTreeView.prototype.deleteSelection = function()
|
Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if(this.selection.count == 0)
|
if(this.selection.count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -129,8 +192,9 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
for(var i=0; i<this.rowCount; i++)
|
for(var i=0; i<this.rowCount; i++)
|
||||||
if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i))
|
if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i))
|
||||||
this.toggleOpenState(i);
|
this.toggleOpenState(i);
|
||||||
|
this._refreshHashMap();
|
||||||
|
|
||||||
//create an array of selected items/collections
|
//create an array of collections
|
||||||
var rows = new Array();
|
var rows = new Array();
|
||||||
var start = new Object();
|
var start = new Object();
|
||||||
var end = new Object();
|
var end = new Object();
|
||||||
|
@ -138,6 +202,7 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
{
|
{
|
||||||
this.selection.getRangeAt(i,start,end);
|
this.selection.getRangeAt(i,start,end);
|
||||||
for (var j=start.value; j<=end.value; j++)
|
for (var j=start.value; j<=end.value; j++)
|
||||||
|
if(!this._getItemAtRow(j).isLibrary())
|
||||||
rows.push(j);
|
rows.push(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,16 +211,17 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
for (var i=0; i<rows.length; i++)
|
for (var i=0; i<rows.length; i++)
|
||||||
{
|
{
|
||||||
//erase item/collection from DB:
|
//erase item/collection from DB:
|
||||||
this._getItemAtRow(rows[i]-i).erase();
|
this._getItemAtRow(rows[i]-i).ref.erase();
|
||||||
|
|
||||||
|
/* Disabled for now because notifier handles it this:
|
||||||
//remove row from tree:
|
//remove row from tree:
|
||||||
this._hideItem(rows[i]-i);
|
this._hideItem(rows[i]-i);
|
||||||
this._treebox.rowCountChanged(rows[i]-i, -1);
|
this._treebox.rowCountChanged(rows[i]-i, -1);*/
|
||||||
}
|
}
|
||||||
this._treebox.endUpdateBatch();
|
this._treebox.endUpdateBatch();
|
||||||
|
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.FolderTreeView.prototype._refreshHashMap = function()
|
Scholar.FolderTreeView.prototype._refreshHashMap = function()
|
||||||
|
|
|
@ -119,7 +119,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function()
|
||||||
else if(this._itemGroup.isCollection())
|
else if(this._itemGroup.isCollection())
|
||||||
this._itemGroup.ref.removeItem(this._getItemAtRow(rows[i]-i).getID());
|
this._itemGroup.ref.removeItem(this._getItemAtRow(rows[i]-i).getID());
|
||||||
|
|
||||||
/* Don't do this, the notifier tells us?
|
/* Disabled for now (notifier)
|
||||||
//remove row from tree:
|
//remove row from tree:
|
||||||
this._hideItem(rows[i]-i);
|
this._hideItem(rows[i]-i);
|
||||||
this._treebox.rowCountChanged(rows[i]-i, -1); */
|
this._treebox.rowCountChanged(rows[i]-i, -1); */
|
||||||
|
@ -163,7 +163,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||||
|
|
||||||
if(action == 'remove')
|
if(action == 'remove')
|
||||||
{
|
{
|
||||||
//Since a remove involves
|
//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();
|
||||||
|
|
|
@ -11,7 +11,8 @@ var ScholarPane = new function()
|
||||||
this.newCollection = newCollection;
|
this.newCollection = newCollection;
|
||||||
this.folderSelected = folderSelected;
|
this.folderSelected = folderSelected;
|
||||||
this.itemSelected = itemSelected;
|
this.itemSelected = itemSelected;
|
||||||
this.deleteSelection = deleteSelection;
|
this.deleteItemSelection = deleteItemSelection;
|
||||||
|
this.deleteCollectionSelection = deleteCollectionSelection;
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.toggleView = toggleView;
|
this.toggleView = toggleView;
|
||||||
|
|
||||||
|
@ -51,7 +52,9 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
function newCollection()
|
function newCollection()
|
||||||
{
|
{
|
||||||
alert("new collection");
|
var c = new Scholar.Collection();
|
||||||
|
//c.setName('Untitled');
|
||||||
|
//c.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function folderSelected()
|
function folderSelected()
|
||||||
|
@ -99,12 +102,18 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSelection()
|
function deleteItemSelection()
|
||||||
{
|
{
|
||||||
if(itemsView && itemsView.selection.count > 0 && confirm("Are you sure you want to delete the selected items?"))
|
if(itemsView && itemsView.selection.count > 0 && confirm("Are you sure you want to delete the selected items?"))
|
||||||
itemsView.deleteSelection();
|
itemsView.deleteSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteCollectionSelection()
|
||||||
|
{
|
||||||
|
if(itemsView && foldersView.selection.count > 0 && confirm("Are you sure you want to delete the selected collections?"))
|
||||||
|
foldersView.deleteSelection();
|
||||||
|
}
|
||||||
|
|
||||||
function search()
|
function search()
|
||||||
{
|
{
|
||||||
if(itemsView)
|
if(itemsView)
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<tree id="folders-tree" hidecolumnpicker="true"
|
<tree id="folders-tree" hidecolumnpicker="true"
|
||||||
onselect="ScholarPane.folderSelected();" seltype="single"
|
onselect="ScholarPane.folderSelected();" seltype="single"
|
||||||
ondragover="nsDragAndDrop.dragOver(event,ScholarCollectionsDragObserver)" ondragdrop="nsDragAndDrop.drop(event,ScholarCollectionsDragObserver)"
|
ondragover="nsDragAndDrop.dragOver(event,ScholarCollectionsDragObserver)" ondragdrop="nsDragAndDrop.drop(event,ScholarCollectionsDragObserver)"
|
||||||
|
onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteCollectionSelection(); return false; }"
|
||||||
persist="width" flex="1">
|
persist="width" flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
|
@ -47,7 +48,7 @@
|
||||||
<splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
|
<splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
|
||||||
<tree
|
<tree
|
||||||
id="items-tree"
|
id="items-tree"
|
||||||
enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelection(); return false; }"
|
enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteItemSelection(); return false; }"
|
||||||
onselect="ScholarPane.itemSelected();"
|
onselect="ScholarPane.itemSelected();"
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarItemsDragObserver);"
|
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarItemsDragObserver);"
|
||||||
persist="width" flex="5">
|
persist="width" flex="5">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user