mirror of https://github.com/jenkinsci/jenkins.git
improve dialog form handling (#8701)
This commit is contained in:
parent
f4fe5710a5
commit
a9c34d7393
|
@ -139,7 +139,11 @@ Dialog.prototype.appendButtons = function () {
|
||||||
}</button>
|
}</button>
|
||||||
</div>`);
|
</div>`);
|
||||||
|
|
||||||
this.dialog.appendChild(buttons);
|
if (this.dialogType === "form") {
|
||||||
|
this.form.appendChild(buttons);
|
||||||
|
} else {
|
||||||
|
this.dialog.appendChild(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
this.ok = buttons.querySelector("[data-id=ok]");
|
this.ok = buttons.querySelector("[data-id=ok]");
|
||||||
this.cancel = buttons.querySelector("[data-id=cancel]");
|
this.cancel = buttons.querySelector("[data-id=cancel]");
|
||||||
|
@ -172,25 +176,24 @@ Dialog.prototype.show = function () {
|
||||||
if (this.input != null) {
|
if (this.input != null) {
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
if (this.ok != null) {
|
if (
|
||||||
|
this.ok != null &&
|
||||||
|
(this.dialogType != "form" || !this.options.submitButton)
|
||||||
|
) {
|
||||||
this.ok.addEventListener(
|
this.ok.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
(e) => {
|
(e) => {
|
||||||
if (this.dialogType === "form" && this.options.submitButton) {
|
e.preventDefault();
|
||||||
this.form.submit();
|
|
||||||
} else {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
let value = true;
|
let value = true;
|
||||||
if (this.dialogType === "prompt") {
|
if (this.dialogType === "prompt") {
|
||||||
value = this.input.value;
|
value = this.input.value;
|
||||||
}
|
|
||||||
if (this.dialogType === "form") {
|
|
||||||
value = new FormData(this.form);
|
|
||||||
}
|
|
||||||
this.dialog.remove();
|
|
||||||
resolve(value);
|
|
||||||
}
|
}
|
||||||
|
if (this.dialogType === "form") {
|
||||||
|
value = new FormData(this.form);
|
||||||
|
}
|
||||||
|
this.dialog.remove();
|
||||||
|
resolve(value);
|
||||||
},
|
},
|
||||||
{ once: true },
|
{ once: true },
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue