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>
This commit is contained in:
Christian Günter 2021-11-18 20:17:52 +01:00 committed by GitHub
parent 543969e870
commit 2dc5626e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 6 deletions

View File

@ -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;
}

View File

@ -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( '});' ).

View File

@ -758,7 +758,8 @@ CLASS zcl_abapgit_html_form IMPLEMENTATION.
IF is_field-side_action IS NOT INITIAL.
ii_html->add( '</div>' ).
ii_html->add( '<div class="command-container">' ).
ii_html->add( |<input type="submit" value="&#x2026;" formaction="sapevent:{ is_field-side_action }">| ).
ii_html->add( |<input type="submit" value="&#x2026;" formaction="sapevent:{ is_field-side_action }"|
&& | title="{ is_field-label }">| ).
ii_html->add( '</div>' ).
ENDIF.