Updated trees to work with new setup. Some New Item functionality. etc.
This commit is contained in:
parent
03637a6c63
commit
2be758e488
|
@ -12,9 +12,9 @@ Scholar.FolderTreeView.prototype.setTree = function(treebox)
|
|||
return;
|
||||
this._treebox = treebox;
|
||||
|
||||
var newRows = Scholar.Items.getTreeRows(0,'folders');
|
||||
var newRows = Scholar.getCollections();
|
||||
for(var i = 0; i < newRows.length; i++)
|
||||
this._showItem(new Scholar.ItemGroup('folder',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow
|
||||
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow
|
||||
|
||||
this._refreshHashMap();
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ Scholar.FolderTreeView.prototype.getCellText = function(row, column)
|
|||
return "";
|
||||
}
|
||||
|
||||
Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); }
|
||||
Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isCollection(); }
|
||||
Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; }
|
||||
Scholar.FolderTreeView.prototype.isContainerEmpty = function(row)
|
||||
{
|
||||
var itemGroup = this._getItemAtRow(row);
|
||||
if(itemGroup.isFolder())
|
||||
return !itemGroup.ref.hasChildFolders();
|
||||
if(itemGroup.isCollection())
|
||||
return !itemGroup.ref.hasChildCollections();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
@ -79,12 +79,12 @@ Scholar.FolderTreeView.prototype.toggleOpenState = function(row)
|
|||
}
|
||||
else
|
||||
{
|
||||
var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).ref.getID(),'folders'); //Get children
|
||||
var newRows = Scholar.getCollections(this._getItemAtRow(row).ref.getID()); //Get children
|
||||
|
||||
for(var i = 0; i < newRows.length; i++)
|
||||
{
|
||||
count++;
|
||||
this._showItem(new Scholar.ItemGroup('folder',newRows[i]), thisLevel+1, row+i+1); //insert new row
|
||||
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), thisLevel+1, row+i+1); //insert new row
|
||||
}
|
||||
}
|
||||
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
|
||||
|
@ -117,12 +117,12 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
|||
if(this.selection.count == 0)
|
||||
return;
|
||||
|
||||
//collapse open folders
|
||||
//collapse open collections
|
||||
for(var i=0; i<this.rowCount; i++)
|
||||
if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i))
|
||||
this.toggleOpenState(i);
|
||||
|
||||
//create an array of selected items/folders
|
||||
//create an array of selected items/collections
|
||||
var rows = new Array();
|
||||
var start = new Object();
|
||||
var end = new Object();
|
||||
|
@ -137,7 +137,7 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
|||
this._treebox.beginUpdateBatch();
|
||||
for (var i=0; i<rows.length; i++)
|
||||
{
|
||||
//erase item/folder from DB:
|
||||
//erase item/collection from DB:
|
||||
this._getItemAtRow(rows[i]-i).erase();
|
||||
|
||||
//remove row from tree:
|
||||
|
@ -152,15 +152,15 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
|||
|
||||
Scholar.FolderTreeView.prototype._refreshHashMap = function()
|
||||
{
|
||||
// Create hash map of folder and object ids to row indexes
|
||||
// Create hash map of collection and object ids to row indexes
|
||||
|
||||
this._folderRowMap = new Array();
|
||||
this._collectionRowMap = new Array();
|
||||
for(var i=0; i < this.rowCount; i++){
|
||||
if (this.isContainer(i)){
|
||||
this._folderRowMap[this._getItemAtRow(i).ref.getID()] = i;
|
||||
this._collectionRowMap[this._getItemAtRow(i).ref.getID()] = i;
|
||||
}
|
||||
}
|
||||
//Scholar.debug(Scholar.varDump(this.folderRowMap));
|
||||
//Scholar.debug(Scholar.varDump(this.collectionRowMap));
|
||||
//Scholar.debug(Scholar.varDump(this.objectRowMap));
|
||||
}
|
||||
|
||||
|
@ -175,14 +175,14 @@ Scholar.ItemGroup.prototype.isLibrary = function()
|
|||
return this.type == 'library';
|
||||
}
|
||||
|
||||
Scholar.ItemGroup.prototype.isFolder = function()
|
||||
Scholar.ItemGroup.prototype.isCollection = function()
|
||||
{
|
||||
return this.type == 'folder';
|
||||
return this.type == 'collection';
|
||||
}
|
||||
|
||||
Scholar.ItemGroup.prototype.getName = function()
|
||||
{
|
||||
if(this.isFolder())
|
||||
if(this.isCollection())
|
||||
return this.ref.getName();
|
||||
else if(this.isLibrary())
|
||||
return "Library";
|
||||
|
@ -192,10 +192,10 @@ Scholar.ItemGroup.prototype.getName = function()
|
|||
|
||||
Scholar.ItemGroup.prototype.getChildItems = function()
|
||||
{
|
||||
if(this.isFolder())
|
||||
return Scholar.Items.getTreeRows(this.ref.getID(),'items');
|
||||
if(this.isCollection())
|
||||
return Scholar.getItems(this.ref.getID());
|
||||
else if(this.isLibrary())
|
||||
return Scholar.Items.getAll();
|
||||
return Scholar.getItems();
|
||||
else
|
||||
return null;
|
||||
}
|
|
@ -127,7 +127,7 @@ MetadataPane = new function()
|
|||
function getFullFieldList(item)
|
||||
{
|
||||
var fields = Scholar.ItemFields.getItemTypeFields(item.getField("itemTypeID"));
|
||||
var fieldNames = new Array("title","dateAdded","dateModified","source","rights");
|
||||
var fieldNames = new Array("title","dateAdded","dateModified");
|
||||
for(var i = 0; i<fields.length; i++)
|
||||
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
|
||||
return fieldNames;
|
||||
|
|
|
@ -8,7 +8,7 @@ var ScholarPane = new function()
|
|||
this.init = init;
|
||||
this.toggleScholar = toggleScholar;
|
||||
this.newItem = newItem;
|
||||
this.newFolder = newFolder;
|
||||
this.newCollection = newCollection;
|
||||
this.folderSelected = folderSelected;
|
||||
this.itemSelected = itemSelected;
|
||||
this.deleteSelection = deleteSelection;
|
||||
|
@ -18,7 +18,7 @@ var ScholarPane = new function()
|
|||
{
|
||||
foldersView = new Scholar.FolderTreeView(); //pass params here?
|
||||
document.getElementById('folders-tree').view = foldersView;
|
||||
document.getElementById('items-tree').view = null;
|
||||
foldersView.selection.select(0);
|
||||
|
||||
var addMenu = document.getElementById('tb-add').firstChild;
|
||||
var itemTypes = Scholar.ItemTypes.getTypes();
|
||||
|
@ -41,12 +41,12 @@ var ScholarPane = new function()
|
|||
|
||||
function newItem(typeID)
|
||||
{
|
||||
alert("new item of type: "+typeID);
|
||||
document.getElementById('content').loadURI('chrome://scholar/content/view.xul?new='+typeID);
|
||||
}
|
||||
|
||||
function newFolder()
|
||||
function newCollection()
|
||||
{
|
||||
alert("new folder");
|
||||
alert("new collection");
|
||||
}
|
||||
|
||||
function folderSelected()
|
||||
|
|
|
@ -13,21 +13,22 @@
|
|||
<script src="itemTreeView.js"/>
|
||||
<script src="folderTreeView.js"/>
|
||||
|
||||
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/>
|
||||
<command id="cmd_scholar_newFolder" oncommand="ScholarPane.newFolder();"/>
|
||||
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
|
||||
|
||||
<commandset id="mainCommandSet">
|
||||
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/>
|
||||
<command id="cmd_scholar_newCollection" oncommand="ScholarPane.newCollection();"/>
|
||||
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
|
||||
</commandset>
|
||||
|
||||
<vbox id="appcontent">
|
||||
<vbox id="scholar-pane" position="1" persist="height collapsed">
|
||||
<hbox flex="1">
|
||||
<tree id="folders-tree"
|
||||
style="-moz-user-focus: ignore;" hidecolumnpicker="true"
|
||||
onselect="ScholarPane.folderSelected();"
|
||||
<tree id="folders-tree" hidecolumnpicker="true"
|
||||
onselect="ScholarPane.folderSelected();" seltype="single"
|
||||
persist="width" flex="1">
|
||||
<treecols>
|
||||
<treecol
|
||||
id="name_column"
|
||||
label="&folders.name_column;"
|
||||
label="&collections.name_column;"
|
||||
flex="1"
|
||||
primary="true"/>
|
||||
</treecols>
|
||||
|
@ -75,7 +76,7 @@
|
|||
</tree>
|
||||
</hbox>
|
||||
<toolbar id="scholar-toolbar" align="center">
|
||||
<toolbarbutton label="&menuitem.newFolder.label;" command="cmd_scholar_newFolder"/>
|
||||
<toolbarbutton label="&menuitem.newCollection.label;" command="cmd_scholar_newCollection"/>
|
||||
<toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu">
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
|
|
|
@ -2,10 +2,22 @@ var thisItem;
|
|||
|
||||
function init()
|
||||
{
|
||||
thisItem = Scholar.Items.get(getArgument("id"));
|
||||
|
||||
document.getElementById('view').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+thisItem.getField("title")+'"')+'&btnI');
|
||||
MetadataPane.viewItem(thisItem);
|
||||
if(thisItem)
|
||||
return;
|
||||
|
||||
var id = getArgument("id");
|
||||
if(id)
|
||||
{
|
||||
thisItem = Scholar.Items.get(id);
|
||||
document.getElementById('view').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+thisItem.getField("title")+'"')+'&btnI');
|
||||
MetadataPane.viewItem(thisItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
thisItem = new Scholar.Item(getArgument('new'));
|
||||
MetadataPane.viewItem(thisItem);
|
||||
MetadataPane.toggleEdit();
|
||||
}
|
||||
}
|
||||
|
||||
function toggle(id)
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
<script src="include.js"/>
|
||||
<?xul-overlay href="metadataPane.xul" ?>
|
||||
|
||||
<toolbar id="view-toolbar">
|
||||
<toolbarbutton class="toggler" id="tb-view" label="View" checked="true" oncommand="toggle('view')"/>
|
||||
<toolbarbutton class="toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="toggle('metadata')"/>
|
||||
<toolbarbutton class="toggler" id="tb-notes" label="Notes" checked="true" oncommand="toggle('notes')"/>
|
||||
</toolbar>
|
||||
<stack flex="1">
|
||||
<browser id="view" flex="1"/>
|
||||
<vbox align="end">
|
||||
|
@ -23,4 +18,9 @@
|
|||
</vbox>
|
||||
</vbox>
|
||||
</stack>
|
||||
<toolbar id="view-toolbar">
|
||||
<toolbarbutton class="toggler" id="tb-view" label="View" checked="true" oncommand="toggle('view')"/>
|
||||
<toolbarbutton class="toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="toggle('metadata')"/>
|
||||
<toolbarbutton class="toggler" id="tb-notes" label="Notes" checked="true" oncommand="toggle('notes')"/>
|
||||
</toolbar>
|
||||
</page>
|
|
@ -5,7 +5,7 @@
|
|||
<!ENTITY items.dateAdded_column "Date Added">
|
||||
<!ENTITY items.dateModified_column "Date Modified">
|
||||
|
||||
<!ENTITY folders.name_column "Name">
|
||||
<!ENTITY collections.name_column "Name">
|
||||
|
||||
<!ENTITY creators.firstname "First name">
|
||||
<!ENTITY creators.lastname "Last name">
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
<!ENTITY menuitem.newItem.label "New Item...">
|
||||
<!ENTITY menuitem.newItem.accesskey "n">
|
||||
<!ENTITY menuitem.newFolder.label "New Folder...">
|
||||
<!ENTITY menuitem.newCollection.label "New Collection...">
|
||||
<!ENTITY menuitem.newFolder.accesskey "o">
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ tree #folders-tree
|
|||
|
||||
#scholar-tree-splitter
|
||||
{
|
||||
background: #f5f5f5;
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,6 +25,7 @@ tree #items-tree
|
|||
#scholar-toolbar
|
||||
{
|
||||
border-bottom: none;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
#scholar-toolbar toolbarbutton
|
||||
|
|
Loading…
Reference in New Issue
Block a user