From 5ae5221f6fde43e48249971d0f0dea12c3d52b07 Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Wed, 28 May 2025 10:59:50 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06925=20-=20Enable=20on=20any=20search=20?= =?UTF-8?q?result=20edition=20of=20OQL=20(#711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 5 +++++ js/utils.js | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/application/utils.inc.php b/application/utils.inc.php index 9233ca932..5803a3bc8 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1555,6 +1555,11 @@ class utils } $aResult[] = new JSPopupMenuItem('UI:Menu:AddToDashboard', Dict::S('UI:Menu:AddToDashboard'), "DashletCreationDlg('$sOQL', '$sContext')"); $aResult[] = new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('$sOQL', '$sDataTableId', '$sContext')"); + if (ApplicationMenu::IsMenuIdEnabled('RunQueriesMenu')) { + $oMenuItemPlay = new JSPopupMenuItem('UI:Menu:OpenOQL', Dict::S('UI:Edit:TestQuery'), "OpenOql('$sOQL')"); + $oMenuItemPlay->SetIconClass('fas fa-play'); + $aResult[] = $oMenuItemPlay; + } break; diff --git a/js/utils.js b/js/utils.js index 987358fdb..8bbda0ccf 100644 --- a/js/utils.js +++ b/js/utils.js @@ -369,6 +369,24 @@ function DashletCreationDlg(sOQL, sContext) { return false; } +function OpenOql(sOQL) { + sBaseUrl = GetAbsoluteUrlAppRoot() + 'pages/run_query.php'; + var form = document.createElement("form"); + form.setAttribute("method", "post"); + form.setAttribute("action", sBaseUrl); + form.setAttribute("target", '_blank'); + form.setAttribute("id", 'run_query_form'); + var input = document.createElement('input'); + input.type = 'hidden'; + input.name = 'expression'; + input.value = sOQL; + form.appendChild(input); + document.body.appendChild(form); + // form.submit() is blocked by the browser + $('#run_query_form').submit(); + document.body.removeChild(form); +} + function ShortcutListDlg(sOQL, sDataTableId, sContext) { var sDataTableName = 'datatable_'+sDataTableId; var oTableSettings = {