diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index 20bdbf7f3b..8aedbbef26 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -194,6 +194,9 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) ids = Scholar.flattenArguments(ids); var madeChanges = false; + this.selection.selectEventsSuppressed = true; + this.saveSelection(); + if(action == 'remove') { //Since a remove involves shifting of rows, we have to do it in order @@ -254,11 +257,18 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) this.selection.select(this._itemRowMap[item.getID()]); if(this.isSorted()) + { this.sort(); //this also refreshes the hash map + this._treebox.invalidate(); + } else if(action != 'modify') //no need to update this if we just modified + { this._refreshHashMap(); - - } + } + + this.rememberSelection(); + } + this.selection.selectEventsSuppressed = false; } Scholar.ItemTreeView.prototype.saveSelection = function() diff --git a/chrome/chromeFiles/content/scholar/metadataPane.js b/chrome/chromeFiles/content/scholar/metadataPane.js index 30af17dae6..e0c9a5a43a 100644 --- a/chrome/chromeFiles/content/scholar/metadataPane.js +++ b/chrome/chromeFiles/content/scholar/metadataPane.js @@ -1,27 +1,36 @@ MetadataPane = new function() { var _dynamicFields; + var _creatorTypeMenu; + var _beforeRow; + + var _creatorCount; var _itemBeingEdited; - var _creatorTypes = Scholar.CreatorTypes.getTypes(); this.onLoad = onLoad; this.viewItem = viewItem; -/* this.saveItem = saveItem; - this.addCreator = addCreator; - this.removeCreator = removeCreator; */ + this.addCreatorRow = addCreatorRow; + this.modifyCreator = modifyCreator; + this.removeCreator = removeCreator; this.showEditor = showEditor; this.hideEditor = hideEditor; function onLoad() { - _metadataPane = document.getElementById('scholar-metadata'); _dynamicFields = document.getElementById('editpane-dynamic-fields'); - _dynamicCreators = document.getElementById('editpane-dynamic-creators'); - _editButton = document.getElementById('metadata-pane-edit-button'); - _cancelButton = document.getElementById('metadata-pane-cancel-button'); - _saveButton = document.getElementById('metadata-pane-save-button'); - _creatorsToolbar = document.getElementById('metadata-creators-toolbar'); + _creatorTypeMenu = document.getElementById('creatorTypeMenu'); + + var creatorTypes = Scholar.CreatorTypes.getTypes(); + for(var i = 0; i < creatorTypes.length; i++) + { + var menuitem = document.createElement("menuitem"); + menuitem.setAttribute("label",Scholar.getString('creatorTypes.'+creatorTypes[i]['name'])); + menuitem.setAttribute("typeid",creatorTypes[i]['id']); + if(creatorTypes[i]['id'] == 0) + menuitem.setAttribute("selected",true); + _creatorTypeMenu.appendChild(menuitem); + } return true; } @@ -38,74 +47,38 @@ MetadataPane = new function() function reloadFields() { - removeDynamicRows(_dynamicFields); - thisItem = _itemBeingEdited; + while(_dynamicFields.hasChildNodes()) + _dynamicFields.removeChild(_dynamicFields.firstChild); - var fieldNames = getFullFieldList(thisItem); + var fieldNames = new Array("title","dateAdded","dateModified"); + var fields = Scholar.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID")); + for(var i = 0; i 0) + _beforeRow = _dynamicFields.firstChild.nextSibling; + _creatorCount = 0; + if(_itemBeingEdited.numCreators() > 0) { - for(var i = 0, len=thisItem.numCreators(); i -