From ae11d5c1067f72e6137496ddec5ffacffeb31b29 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Wed, 3 Oct 2012 11:57:16 -0400 Subject: [PATCH] BUG 9508 I add the option the show scroll I add propety in form to the grids with scroll --- gulliver/system/class.form.php | 1 + gulliver/system/class.xmlform.php | 30 +++++++++++++++++-- .../engine/classes/class.dynaformEditor.php | 4 +++ workflow/engine/templates/grid.html | 6 ++-- .../dynaforms/dynaforms_Properties.xml | 8 ++++- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/gulliver/system/class.form.php b/gulliver/system/class.form.php index 1d27ed675..599404250 100755 --- a/gulliver/system/class.form.php +++ b/gulliver/system/class.form.php @@ -47,6 +47,7 @@ class Form extends XmlForm var $objectRequiredFields = null; var $nextstepsave = ''; var $printdynaform = ''; + var $adjustgridswith = '0'; public $visual_frontend; diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 703f5fb88..f173bbdf1 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3295,8 +3295,34 @@ class XmlForm_Field_Grid extends XmlForm_Field $fieldsSize += $size; $emptyRow [$key] = array ($emptyValue); } - if($fieldsSize>100) - $owner->width = '100%'; + + if (isset($owner->adjustgridswith) && $owner->adjustgridswith == '1') { + // 400w -> 34s to Firefox + // 400w -> 43s to Chrome + + $baseWidth = 400; + $minusWidth = 30; + if (eregi('chrome', $_SERVER['HTTP_USER_AGENT'])) { + $baseSize = 43; + } else { + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { + $minusWidth = 20; + } + $baseSize = 34; + } + + $baseWidth = 400; + $formWidth = (int)$owner->width; + $maxSize = (($formWidth*$baseSize) / $baseWidth); + + if ($fieldsSize > $maxSize) { + $this->scrollStyle = 'height:100%; overflow-x: scroll; width:'; + $this->scrollStyle .= $formWidth - $minusWidth . ';'; + } + } else { + if($fieldsSize>100) + $owner->width = '100%'; + } // else // $owner->width = $fieldsSize . 'em'; return $this->renderGrid ( $emptyRow, $owner ); diff --git a/workflow/engine/classes/class.dynaformEditor.php b/workflow/engine/classes/class.dynaformEditor.php index 6040d03f5..fd8017a5b 100755 --- a/workflow/engine/classes/class.dynaformEditor.php +++ b/workflow/engine/classes/class.dynaformEditor.php @@ -716,6 +716,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax //'ENABLETEMPLATE'=> $form->enableTemplate, 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, + 'ADJUSTGRIDSWITH'=> $form->adjustgridswith, 'NEXTSTEPSAVE' => $form->nextstepsave ); $tmp['Properties']=$Properties; @@ -776,6 +777,9 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax if (isset($Fields['PRINTDYNAFORM'])) { $ses2->execute(G::replaceDataField("UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields)); } + if (isset($Fields['ADJUSTGRIDSWITH'])) { + $ses2->execute(G::replaceDataField("UPDATE . SET ADJUSTGRIDSWITH = @@ADJUSTGRIDSWITH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields)); + } return 0; } catch(Exception $e) { diff --git a/workflow/engine/templates/grid.html b/workflow/engine/templates/grid.html index 758a4f215..d0656c506 100755 --- a/workflow/engine/templates/grid.html +++ b/workflow/engine/templates/grid.html @@ -2,18 +2,19 @@ {* this is the grid template *}
-
+
{$form->label}
+
{if ($form->addRow) } - +
 {$form->NewLabel}  {$form->NewLabel}
{/if} @@ -66,6 +67,7 @@
+
diff --git a/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml b/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml index 5001bab07..955c200c2 100755 --- a/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml +++ b/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml @@ -53,11 +53,15 @@ - + Show print dynaform button + + Adjust the grid width to the width of the main form + + @@ -83,6 +87,7 @@ if(document.getElementById("form[DYN_TYPE]").value=="grid"){ hideRowById('WIDTH'); hideRowById('NEXTSTEPSAVE'); hideRowById('PRINTDYNAFORM'); + hideRowById('ADJUSTGRIDSWITH'); } function getElementsByClassNameCrossBrowser(searchClass,node,tag) { @@ -145,6 +150,7 @@ function validateGridConversion(proUid,dynUid){ hideRowById('WIDTH'); hideRowById('NEXTSTEPSAVE'); hideRowById('PRINTDYNAFORM'); + hideRowById('ADJUSTGRIDSWITH'); } else { setDropdownSelection("form[DYN_TYPE]" , "xmlform"); msgBox("Grid forms can not contain the following fields:
" + response,"alert");