finish Graph migration to FormBuilder

This commit is contained in:
Doug Bell 2011-02-15 16:16:09 -06:00
parent 24c2d6bb27
commit 88a94d65e2

View file

@ -234,8 +234,6 @@ sub getGraphingTab {
my $i18n = WebGUI::International->new($session, 'Image_Graph'); my $i18n = WebGUI::International->new($session, 'Image_Graph');
my $f = WebGUI::HTMLForm->new($session);
unless ($session->config->get("graphingPlugins")) { unless ($session->config->get("graphingPlugins")) {
$tab->addField('readOnly', { value => $i18n->get('no graphing plugins in config'), }); $tab->addField('readOnly', { value => $i18n->get('no graphing plugins in config'), });
} }
@ -252,75 +250,70 @@ sub getGraphingTab {
} }
my $ns = $config->{graph_formNamespace}; my $ns = $config->{graph_formNamespace};
my %configForms; if (%graphingPlugins) {
if (%graphingPlugins) { $session->style->setRawHeadTags(<<EOS
$session->style->setRawHeadTags(<<EOS <script type="text/javascript">
<script type="text/javascript"> function inNamespace (clas, namespace) {
function inNamespace (clas, namespace) { var namespaceParts = namespace.split('_');
var namespaceParts = namespace.split('_'); var s = '';
var s = '';
for (var i = 0; i < namespaceParts.length; i++) { for (var i = 0; i < namespaceParts.length; i++) {
if (i > 0) { if (i > 0) {
s = s + '_'; s = s + '_';
} }
s = s + namespaceParts[i]; s = s + namespaceParts[i];
if (s == clas) { if (s == clas) {
return true; return true;
} }
} }
return false; return false;
} }
function getContainerTag (elem, tagname) { function getContainerTag (elem, tagname) {
var parent = elem.parentNode; var parent = elem.parentNode;
while (parent.tagName != tagname) { while (parent.tagName != tagname) {
parent = parent.parentNode; parent = parent.parentNode;
} }
return parent; return parent;
} }
function switchGraphingFormElements (elem, namespace) { function switchGraphingFormElements (elem, namespace) {
var rowElements = getContainerTag(elem, 'TABLE').getElementsByTagName('TR'); var rowElements = getContainerTag(elem, 'TABLE').getElementsByTagName('TR');
for (var ix = 0; ix < rowElements.length; ix++) { for (var ix = 0; ix < rowElements.length; ix++) {
if (inNamespace(rowElements[ix].className, namespace)) { if (inNamespace(rowElements[ix].className, namespace)) {
rowElements[ix].style.display = ''; rowElements[ix].style.display = '';
} else { } else {
if (rowElements[ix].className.match(/^Graph_/)) { if (rowElements[ix].className.match(/^Graph_/)) {
rowElements[ix].style.display = 'none'; rowElements[ix].style.display = 'none';
} }
} }
} }
} }
</script> </script>
EOS EOS
); );
$tab->addField('selectBox', $tab->addField('selectBox',
name => 'graphingPlugin', name => 'graphingPlugin',
options => \%graphingPlugins, options => \%graphingPlugins,
label => $i18n->get('graph type'), label => $i18n->get('graph type'),
hoverHelp => $i18n->get('graph type description'), hoverHelp => $i18n->get('graph type description'),
id => 'graphTypeSelector', id => 'graphTypeSelector',
value => [ $config->{graph_formNamespace} ], value => [ $config->{graph_formNamespace} ],
extras => 'onchange="switchGraphingFormElements(this, this.value)"', extras => 'onchange="switchGraphingFormElements(this, this.value)"',
); );
foreach my $currentPlugin (@graphingPlugins) { foreach my $currentPlugin (@graphingPlugins) {
$currentPlugin->configurationForm($tab); $currentPlugin->configurationForm($tab);
} }
} else { } else {
$tab->addField('readOnly', value => $i18n->get('no graphing plugins'), ); $tab->addField('readOnly', value => $i18n->get('no graphing plugins'), );
} }
foreach (sort keys %configForms) {
$f->raw($configForms{$_});
}
$tab->addField('readOnly', value => <<EOJS ); $tab->addField('readOnly', value => <<EOJS );
<script type="text/javascript"> <script type="text/javascript">