From 2dc5626e7066306032497a8834fe806c3cd351d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=BCnter?= Date: Thu, 18 Nov 2021 20:17:52 +0100 Subject: [PATCH] add form actions to command palette (#5141) * add form actions to command palette * fix attribute Co-authored-by: Marc Bernard <59966492+mbtools@users.noreply.github.com> --- src/ui/zabapgit_js_common.w3mi.data.js | 25 +++++++++++++++++++++---- src/ui/zcl_abapgit_gui_page.clas.abap | 2 +- src/ui/zcl_abapgit_html_form.clas.abap | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/ui/zabapgit_js_common.w3mi.data.js b/src/ui/zabapgit_js_common.w3mi.data.js index 5e61f5c67..fdc8a0fe3 100644 --- a/src/ui/zabapgit_js_common.w3mi.data.js +++ b/src/ui/zabapgit_js_common.w3mi.data.js @@ -24,7 +24,7 @@ /* exported addMarginBottom */ /* exported enumerateJumpAllFiles */ /* exported createRepoCatalogEnumerator */ -/* exported enumerateToolbarActions */ +/* exported enumerateUiActions */ /* exported onDiffCollapse */ /* exported restoreScrollPosition */ @@ -2304,7 +2304,7 @@ function createRepoCatalogEnumerator(catalog, action) { }; } -function enumerateToolbarActions() { +function enumerateUiActions() { var items = []; function processUL(ulNode, prefix) { @@ -2326,6 +2326,7 @@ function enumerateToolbarActions() { } } + // toolbars [].slice.call(document.querySelectorAll("[id*=toolbar]")) .filter(function(toolbar){ return (toolbar && toolbar.nodeName === "UL"); @@ -2333,8 +2334,6 @@ function enumerateToolbarActions() { processUL(toolbar); }); - if (items.length === 0) return; - items = items.map(function(item) { var action = ""; var anchor = item[0]; @@ -2352,6 +2351,24 @@ function enumerateToolbarActions() { }; }); + // forms + [].slice.call(document.querySelectorAll("input[type='submit']")) + .forEach(function(input){ + items.push({ + action: function(){ + if ([].slice.call(input.classList).indexOf("main") !== -1){ + var parentForm = input.parentNode.parentNode.parentNode; + if (parentForm.nodeName === "FORM"){ + parentForm.submit(); + } + } else { + submitSapeventForm({}, input.formAction, "post"); + } + }, + title: input.value + " " + input.title.replace(/\[.*\]/,"") + }); + }); + return items; } diff --git a/src/ui/zcl_abapgit_gui_page.clas.abap b/src/ui/zcl_abapgit_gui_page.clas.abap index 4ce1cb5e4..73782f5a0 100644 --- a/src/ui/zcl_abapgit_gui_page.clas.abap +++ b/src/ui/zcl_abapgit_gui_page.clas.abap @@ -164,7 +164,7 @@ CLASS zcl_abapgit_gui_page IMPLEMENTATION. METHOD render_command_palettes. - ii_html->add( 'var gCommandPalette = new CommandPalette(enumerateToolbarActions, {' ). + ii_html->add( 'var gCommandPalette = new CommandPalette(enumerateUiActions, {' ). ii_html->add( ' toggleKey: "F1",' ). ii_html->add( ' hotkeyDescription: "Command ..."' ). ii_html->add( '});' ). diff --git a/src/ui/zcl_abapgit_html_form.clas.abap b/src/ui/zcl_abapgit_html_form.clas.abap index 99a9b5083..1a912a5d9 100644 --- a/src/ui/zcl_abapgit_html_form.clas.abap +++ b/src/ui/zcl_abapgit_html_form.clas.abap @@ -758,7 +758,8 @@ CLASS zcl_abapgit_html_form IMPLEMENTATION. IF is_field-side_action IS NOT INITIAL. ii_html->add( '' ). ii_html->add( '
' ). - ii_html->add( || ). + ii_html->add( || ). ii_html->add( '
' ). ENDIF.