mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Fix command palette form submit (#5893)
This commit is contained in:
parent
2fc5faa824
commit
ed5dbcdfc4
|
@ -103,9 +103,9 @@ function debugOutput(text, dstID) {
|
||||||
stdout.innerHTML = stdout.innerHTML + wrapped;
|
stdout.innerHTML = stdout.innerHTML + wrapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a pre-created form or create a hidden form
|
// Use a supplied form, a pre-created form or create a hidden form
|
||||||
// and submit with sapevent
|
// and submit with sapevent
|
||||||
function submitSapeventForm(params, action, method) {
|
function submitSapeventForm(params, action, method, form) {
|
||||||
|
|
||||||
function getSapeventPrefix() {
|
function getSapeventPrefix() {
|
||||||
if (document.querySelector('a[href*="file:///SAPEVENT:"]')) {
|
if (document.querySelector('a[href*="file:///SAPEVENT:"]')) {
|
||||||
|
@ -116,17 +116,17 @@ function submitSapeventForm(params, action, method) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var stub_form_id = "form_" + action;
|
var stub_form_id = "form_" + action;
|
||||||
var form = document.getElementById(stub_form_id);
|
|
||||||
|
|
||||||
if (form === null) {
|
form = form
|
||||||
form = document.createElement("form");
|
|| document.getElementById(stub_form_id)
|
||||||
|
|| document.createElement("form");
|
||||||
|
|
||||||
form.setAttribute("method", method || "post");
|
form.setAttribute("method", method || "post");
|
||||||
if (/sapevent/i.test(action)){
|
if (/sapevent/i.test(action)){
|
||||||
form.setAttribute("action", action);
|
form.setAttribute("action", action);
|
||||||
} else {
|
} else {
|
||||||
form.setAttribute("action", getSapeventPrefix() + "SAPEVENT:" + action);
|
form.setAttribute("action", getSapeventPrefix() + "SAPEVENT:" + action);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for(var key in params) {
|
for(var key in params) {
|
||||||
var hiddenField = document.createElement("input");
|
var hiddenField = document.createElement("input");
|
||||||
|
@ -136,7 +136,9 @@ function submitSapeventForm(params, action, method) {
|
||||||
form.appendChild(hiddenField);
|
form.appendChild(hiddenField);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form.id !== stub_form_id) {
|
var formExistsInDOM = form.id && Boolean(document.querySelector("#" + form.id));
|
||||||
|
|
||||||
|
if (form.id !== stub_form_id && !formExistsInDOM) {
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2431,13 +2433,10 @@ function enumerateUiActions() {
|
||||||
.forEach(function(input){
|
.forEach(function(input){
|
||||||
items.push({
|
items.push({
|
||||||
action: function(){
|
action: function(){
|
||||||
if ([].slice.call(input.classList).indexOf("main") !== -1){
|
if (input.form.action.includes(input.formAction)){
|
||||||
var parentForm = input.parentNode.parentNode.parentNode;
|
input.form.submit();
|
||||||
if (parentForm.nodeName === "FORM"){
|
|
||||||
parentForm.submit();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
submitSapeventForm({}, input.formAction, "post");
|
submitSapeventForm({}, input.formAction, "post", input.form);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: input.value + " " + input.title.replace(/\[.*\]/,"")
|
title: input.value + " " + input.title.replace(/\[.*\]/,"")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user