This commit is contained in:
parent
19d268e198
commit
44d4c5dee8
4 changed files with 110 additions and 4 deletions
69
chrome/chromeFiles/content/scholar/editDialog.js
Normal file
69
chrome/chromeFiles/content/scholar/editDialog.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
var ScholarLocalizedStrings;
|
||||
var thisRow;
|
||||
var dynamicBox;
|
||||
|
||||
function init()
|
||||
{
|
||||
thisRow = window.arguments[0];
|
||||
dynamicBox = document.getElementById('dynamic-fields');
|
||||
ScholarLocalizedStrings = document.getElementById('scholar-strings');
|
||||
|
||||
//universal fields
|
||||
var fieldNames = new Array("title","dateAdded","dateModified","source","rights");
|
||||
|
||||
//add specific fields for this object type
|
||||
var fields = Scholar.ObjectFields.getObjectTypeFields(thisRow.getField("objectTypeID"));
|
||||
for(var i = 0; i<fields.length; i++)
|
||||
fieldNames.push(Scholar.ObjectFields.getName(fields[i]));
|
||||
|
||||
//Add each
|
||||
for(var i = 0; i<fieldNames.length; i++)
|
||||
{
|
||||
var label = document.createElement("label");
|
||||
label.setAttribute("value",ScholarLocalizedStrings.getString("objectFields."+fieldNames[i])+":");
|
||||
label.setAttribute("control","dynamic-field-"+i);
|
||||
|
||||
var valueElement = document.createElement("textbox");
|
||||
valueElement.setAttribute("value",thisRow.getField(fieldNames[i]));
|
||||
valueElement.setAttribute("id","dynamic-field-"+i);
|
||||
//valueElement.setAttribute("fieldName",fieldNames[i])
|
||||
|
||||
var row = document.createElement("row");
|
||||
row.appendChild(label);
|
||||
row.appendChild(valueElement);
|
||||
dynamicBox.appendChild(row);
|
||||
|
||||
}
|
||||
|
||||
var beforeField = dynamicBox.firstChild;
|
||||
beforeField = beforeField.nextSibling;
|
||||
|
||||
for (var i=0,len=thisRow.numCreators(); i<len; i++)
|
||||
{
|
||||
var creator = thisRow.getCreator(i);
|
||||
|
||||
var label = document.createElement("label");
|
||||
label.setAttribute("value","Creator:");
|
||||
label.setAttribute("control","dynamic-creator-"+i);
|
||||
|
||||
var valueElement = document.createElement("textbox");
|
||||
valueElement.setAttribute("value",creator.lastName+", "+creator.firstName);
|
||||
valueElement.setAttribute("id","dynamic-field-"+i);
|
||||
|
||||
var row = document.createElement("row");
|
||||
row.appendChild(label);
|
||||
row.appendChild(valueElement);
|
||||
|
||||
dynamicBox.insertBefore(row, beforeField);
|
||||
}
|
||||
}
|
||||
|
||||
function doOK()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function doCancel()
|
||||
{
|
||||
return true;
|
||||
}
|
27
chrome/chromeFiles/content/scholar/editDialog.xul
Normal file
27
chrome/chromeFiles/content/scholar/editDialog.xul
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<dialog id="editDialog" title="Edit Object"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
buttons="accept,cancel"
|
||||
onload="init();"
|
||||
ondialogaccept="return doOK();"
|
||||
ondialogcancel="return doCancel();">
|
||||
<stringbundle id="scholar-strings" src="chrome://scholar/locale/scholar.properties"/>
|
||||
|
||||
|
||||
<script src="include.js"/>
|
||||
<script src="editDialog.js"/>
|
||||
<grid width="400">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
|
||||
<rows id="dynamic-fields">
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
|
||||
</dialog>
|
|
@ -201,11 +201,15 @@ function populateObjectPane(objectRow)
|
|||
|
||||
}
|
||||
|
||||
function selectionChanged()
|
||||
function editSelectedRow()
|
||||
{
|
||||
myTreeView.selectionChanged();
|
||||
var thisRow = myTreeView._getObjectAtRow(myTreeView.selection.currentIndex);
|
||||
window.openDialog('chrome://scholar/content/editDialog.xul','editDialog','modal,dialog,chrome',thisRow);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setView()
|
||||
{
|
||||
myTreeView = new Scholar.TreeView();
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<tree
|
||||
id="scholar-sidebar-items"
|
||||
onselect="selectionChanged()"
|
||||
onselect="this.view.selectionChanged()"
|
||||
enableColumnDrag="true"
|
||||
seltype="multiple"
|
||||
flex="1">
|
||||
|
@ -35,7 +35,12 @@
|
|||
<treechildren/>
|
||||
</tree>
|
||||
|
||||
<grid id="scholar-sidebar-object-pane" hidden="true">
|
||||
<vbox id="scholar-sidebar-object-pane" hidden="true">
|
||||
<sidebarheader>
|
||||
<spacer flex="1" />
|
||||
<toolbarbutton label="Edit" oncommand="editSelectedRow();" />
|
||||
</sidebarheader>
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
|
@ -44,6 +49,7 @@
|
|||
<rows id="scholar-sidebar-object-pane-dynamic-fields">
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
<!--
|
||||
<textbox id="test1"/>
|
||||
<label control="test2" value="Test2:"/>
|
||||
|
|
Loading…
Reference in a new issue