Lots of little things:

- Fix item modify notify() on 1st row.
 - Ensure that new items are visible when added.
 - New functionality for creating new items (prevents a lot of problems).
 - Number-based fields display properly.
 - Fixed bug when creating and saving the first notes on an item.
 - New notes won't save empty.
This commit is contained in:
David Norton 2006-06-17 00:57:50 +00:00
parent 32ce0da44a
commit 953b1f9d20
3 changed files with 20 additions and 11 deletions

View file

@ -174,8 +174,11 @@ ScholarItemPane = new function()
valueElement.setAttribute('onclick', 'ScholarItemPane.showEditor(this);'); valueElement.setAttribute('onclick', 'ScholarItemPane.showEditor(this);');
valueElement.className = 'clicky'; valueElement.className = 'clicky';
} }
var firstSpace = valueText.indexOf(" "); var firstSpace;
if(typeof valueText == 'string')
firstSpace = valueText.indexOf(" ");
if((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29) if((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29)
{ {
valueElement.setAttribute('crop', 'end'); valueElement.setAttribute('crop', 'end');
@ -284,15 +287,15 @@ ScholarItemPane = new function()
{ {
_itemBeingEdited.updateNote(id,_notesField.value); _itemBeingEdited.updateNote(id,_notesField.value);
} }
else //new note else if(_notesField.value)//new note
{ {
id = _itemBeingEdited.addNote(_notesField.value); id = _itemBeingEdited.addNote(_notesField.value);
_notesMenu.selectedItem.value = id; _notesMenu.selectedItem.setAttribute('value',id);
} }
var label = _noteToTitle(_notesField.value); var label = _noteToTitle(_notesField.value);
_notesMenu.selectedItem.label = label; _notesMenu.selectedItem.label = label; //sets the individual item label
_notesMenu.setAttribute('label', label); _notesMenu.setAttribute('label', label); //sets the 'overall' label of the menu... not usually updated unless the item is reselected
} }
function removeSelectedNote() function removeSelectedNote()

View file

@ -94,7 +94,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
} }
else if(action == 'modify') //must check for null because it could legitimately be 0 else if(action == 'modify') //must check for null because it could legitimately be 0
{ {
if(this._itemRowMap[ids]) if(this._itemRowMap[ids] != null)
{ {
this._treebox.invalidateRow(row); this._treebox.invalidateRow(row);
madeChanges = true; madeChanges = true;
@ -126,9 +126,14 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
} }
if(action == 'add') if(action == 'add')
{
this.selection.select(this._itemRowMap[item.getID()]); this.selection.select(this._itemRowMap[item.getID()]);
this._treebox.ensureRowIsVisible(this._itemRowMap[item.getID()]);
}
else else
{
this.rememberSelection(); this.rememberSelection();
}
} }
this.selection.selectEventsSuppressed = false; this.selection.selectEventsSuppressed = false;
} }

View file

@ -68,13 +68,14 @@ var ScholarPane = new function()
} }
/* /*
* Called when the window closes * Create a new item
*/ */
function newItem(typeID) function newItem(typeID)
{ {
ScholarItemPane.viewItem(new Scholar.Item(typeID)); var item = new Scholar.Item(typeID);
document.getElementById('scholar-view-item').hidden = false; item.save();
document.getElementById('scholar-view-selected-label').hidden = true; if(itemsView && itemsView._itemGroup.isCollection())
itemsView._itemGroup.ref.addItem(item.getID());
} }
function newCollection() function newCollection()