[interface] You can now change an item's type via menu.

This commit is contained in:
David Norton 2006-06-19 15:45:32 +00:00
parent c345b90b9a
commit 8d50874d6b
4 changed files with 24 additions and 15 deletions

View file

@ -13,6 +13,7 @@ ScholarItemPane = new function()
this.onLoad = onLoad;
this.viewItem = viewItem;
this.changeTypeTo = changeTypeTo;
this.addCreatorRow = addCreatorRow;
this.removeCreator = removeCreator;
this.showEditor = showEditor;
@ -27,6 +28,7 @@ ScholarItemPane = new function()
function onLoad()
{
_dynamicFields = document.getElementById('editpane-dynamic-fields');
_itemTypeMenu = document.getElementById('editpane-type-menu');
_creatorTypeMenu = document.getElementById('creatorTypeMenu');
_notesMenu = document.getElementById('scholar-notes-menu');
_notesField = document.getElementById('scholar-notes-field');
@ -43,6 +45,10 @@ ScholarItemPane = new function()
_creatorTypeMenu.appendChild(menuitem);
}
var itemTypes = Scholar.ItemTypes.getTypes();
for(var i = 0; i<itemTypes.length; i++)
_itemTypeMenu.appendItem(Scholar.getString("itemTypes."+itemTypes[i]['name']),itemTypes[i]['id']);
return true;
}
@ -67,6 +73,10 @@ ScholarItemPane = new function()
while(_dynamicFields.hasChildNodes())
_dynamicFields.removeChild(_dynamicFields.firstChild);
for(var i = 0, len = _itemTypeMenu.firstChild.childNodes.length; i < len; i++)
if(_itemTypeMenu.firstChild.childNodes[i].value == _itemBeingEdited.getType())
_itemTypeMenu.selectedIndex = i;
var fieldNames = new Array("title","dateAdded","dateModified");
var fields = Scholar.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID"));
for(var i = 0; i<fields.length; i++)
@ -117,6 +127,16 @@ ScholarItemPane = new function()
onNoteSelected();
}
function changeTypeTo(id)
{
if(id != _itemBeingEdited.getType() && confirm('Are you sure you want to change the item type? Certain fields may be lost.'))
{
_itemBeingEdited.setType(id);
_itemBeingEdited.save();
reloadFields();
}
}
function addDynamicRow(label, value, beforeElement)
{
var row = document.createElement("row");

View file

@ -29,6 +29,9 @@
<popupset>
<popup id="creatorTypeMenu" position="after_start" oncommand="ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],'typeID',event.explicitOriginalTarget.getAttribute('typeid'));"/>
</popupset>
<menulist id="editpane-type-menu" oncommand="ScholarItemPane.changeTypeTo(this.value)">
<menupopup/>
</menulist>
<grid flex="1">
<columns>
<column/>

View file

@ -35,17 +35,6 @@ var ScholarPane = new function()
//select Library
collectionsView.selection.select(0);
//Create the add menu with each item type
var addMenu = document.getElementById('tb-add').firstChild;
var itemTypes = Scholar.ItemTypes.getTypes();
for(var i = 0; i<itemTypes.length; i++)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
addMenu.appendChild(menuitem);
}
}
/*

View file

@ -65,10 +65,7 @@
<splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<vbox persist="width" flex="1" style="min-width: 300px;">
<toolbar align="center">
<toolbarbutton id="tb-add" label="&toolbar.newItem.label;" type="menu">
<menupopup>
</menupopup>
</toolbarbutton>
<toolbarbutton id="tb-add" label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
<spacer flex="1"/>
<label value="&toolbar.search.label;" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="500" command="cmd_scholar_search"/>