From 56b1e37c139b1f3056de9cf62096d6318d009551 Mon Sep 17 00:00:00 2001 From: David Norton Date: Mon, 5 Jun 2006 13:56:59 +0000 Subject: [PATCH] New items are properly displayed on a notify() New items are automatically selected. When adding a new item, or editing an item without a creator, display an empty creator box. Edit button changed from toggling to Save/Cancel buttons. Simple "Do you want to save changes?" dialog if you select a different item while in edit mode. --- .../content/scholar/itemTreeView.js | 6 +- .../content/scholar/metadataPane.js | 73 +++++++++++++------ .../content/scholar/metadataPane.xul | 4 +- .../chromeFiles/content/scholar/overlay.xul | 2 +- .../skin/default/scholar/overlay.css | 17 +++++ 5 files changed, 77 insertions(+), 25 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index 6e4aabd2b..65740662e 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -196,7 +196,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) if(this._itemGroup.isLibrary() || item.inCollection(this.getCollectionID())) { this._showItem(item,this.rowCount); - this._treebox.rowCountChanged(this.rowCount,1); + this._treebox.rowCountChanged(this.rowCount-1,1); } madeChanges = true; @@ -209,6 +209,10 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) if(madeChanges) this._refreshHashMap(); + + //Select last add + if(action == 'add' && item) + this.selection.select(this._itemRowMap[item.getID()]); } Scholar.ItemTreeView.prototype.canDrop = function(index, orient) diff --git a/chrome/chromeFiles/content/scholar/metadataPane.js b/chrome/chromeFiles/content/scholar/metadataPane.js index 2b68bb4e1..3c2ec364f 100644 --- a/chrome/chromeFiles/content/scholar/metadataPane.js +++ b/chrome/chromeFiles/content/scholar/metadataPane.js @@ -3,6 +3,9 @@ MetadataPane = new function() var _dynamicFields; var _dynamicCreators; var _editButton; + var _cancelButton; + var _saveButton; + var _creatorsToolbar; var _itemBeingEdited; var _creatorTypes = Scholar.CreatorTypes.getTypes(); @@ -20,20 +23,35 @@ MetadataPane = new function() _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'); return true; } /* - * Dynamically loads an item + * Loads an item */ function viewItem(thisItem) - { + { + if(_editButton.hidden) + toggleEdit(confirm("Save changes to '"+_itemBeingEdited.getField('title')+"'?")); + + _itemBeingEdited = thisItem; + + reloadFields(); + + } + + function reloadFields() + { removeDynamicRows(_dynamicFields); removeDynamicRows(_dynamicCreators); + thisItem = _itemBeingEdited; var fieldNames = getFullFieldList(thisItem); - var editingMode = _editButton.checked; + var editingMode = _editButton.hidden; for(var i = 0; i 0) { - var creator = thisItem.getCreator(i); - if(_editButton.checked) + for(var i = 0, len=thisItem.numCreators(); i