diff --git a/pages/run_query.php b/pages/run_query.php index f355888e0..ce70e9efd 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -23,7 +23,9 @@ use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSec use Combodo\iTop\Application\UI\Base\Component\FieldSet\FieldSet; use Combodo\iTop\Application\UI\Base\Component\Form\Form; use Combodo\iTop\Application\UI\Base\Component\Html\Html; +use Combodo\iTop\Application\UI\Base\Component\Input\InputFactory; use Combodo\iTop\Application\UI\Base\Component\Input\TextArea; +use Combodo\iTop\Application\UI\Base\Component\Panel\PanelFactory; require_once('../approot.inc.php'); require_once(APPROOT.'/application/application.inc.php'); @@ -172,20 +174,13 @@ try $oHiddenParams = new Html($oAppContext->GetForForm()); $oQueryForm->AddSubBlock($oHiddenParams); + //--- Query textarea $oQueryTitle = new Html('

'.Dict::S('UI:RunQuery:ExpressionToEvaluate').'

'); $oQueryForm->AddSubBlock($oQueryTitle); $oQueryTextArea = new TextArea(utils::EscapeHtml($sExpression), 'expression', 120, 8); $oQueryTextArea->SetName('expression'); $oQueryForm->AddSubBlock($oQueryTextArea); - $oQuerySubmit = ButtonFactory::MakeForPrimaryAction( - Dict::S('UI:Button:Evaluate'), - null, - null, - true - ); - $oQueryForm->AddSubBlock($oQuerySubmit); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot()."/js/jquery.hotkeys.js"); $oP->add_ready_script(<< 0) { - $oP->add("
\n"); - $oP->add("

Query arguments

\n"); + //--- Query arguments + $oQueryArgsContainer = PanelFactory::MakeForInformation('Query arguments') + ->SetCSSClasses('wizContainer'); + $oQueryForm->AddSubBlock($oQueryArgsContainer); foreach ($aArgs as $sParam => $sValue) { - $oP->p("$sParam: \n"); + $oArgInput = InputFactory::MakeForInputWithLabel( + $sParam, + 'arg_'.$sParam, + $sValue + ); + $oQueryArgsContainer->AddSubBlock($oArgInput); } - $oP->add("
\n"); } + $oQuerySubmit = ButtonFactory::MakeForPrimaryAction( + Dict::S('UI:Button:Evaluate'), + null, + null, + true + ); + $oQueryForm->AddSubBlock($oQuerySubmit); + + if ($oFilter) { + //--- Query filter $oP->add("

Query results

\n"); $oResultBlock = new DisplayBlock($oFilter, 'list', false); @@ -230,6 +241,7 @@ EOF iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES); + //--- More info $aMoreInfoBlocks = []; $oDevelopedQuerySet = new FieldSet(Dict::S('UI:RunQuery:DevelopedQuery')); diff --git a/sources/application/UI/Base/Component/Input/InputFactory.php b/sources/application/UI/Base/Component/Input/InputFactory.php index 8409aa1a0..96f92f1e7 100644 --- a/sources/application/UI/Base/Component/Input/InputFactory.php +++ b/sources/application/UI/Base/Component/Input/InputFactory.php @@ -26,6 +26,29 @@ class InputFactory return $oInput; } + /** + * @see Field component that is better adapter when dealing with a standard iTop form + * + * @param string $sLabel + * @param string $sInputName + * @param string|null $sInputValue + * @param string|null $sInputId + * @param string $sInputType + * + * @return \Combodo\iTop\Application\UI\Base\Component\Input\InputWithLabel + */ + public static function MakeForInputWithLabel( + string $sLabel, string $sInputName, ?string $sInputValue = null, + ?string $sInputId = null, string $sInputType = 'type' + ): InputWithLabel + { + $oInput = new Input($sInputId); + $oInput->SetType($sInputType); + $oInput->SetValue($sInputValue); + + return static::MakeInputWithLabel($sInputName, $sLabel, $oInput, $sInputId); + } + /** * If you need to have a real field with a label, you might use a {@link Field} component instead * @@ -38,14 +61,19 @@ class InputFactory public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel { $oInput = new Select($sId); + + return static::MakeInputWithLabel($sName, $sLabel, $oInput, $sId); + } + + private static function MakeInputWithLabel(string $sName, string $sLabel, Input $oInput, ?string $sId = null) + { $oInput->SetName($sName); if (is_null($sId)) { $sId = $oInput->GetId(); } - $oInputWithLabel = new InputWithLabel($sLabel, $oInput, $sId); - return $oInputWithLabel; + return new InputWithLabel($sLabel, $oInput, $sId); } public static function MakeForSelect(string $sName, ?string $sId = null): Select