create custom dialog form element
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
d6a37ef59c
commit
cc72688bf8
@ -10,7 +10,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="center-div">
|
<div class="center-div">
|
||||||
<form>
|
<form style="margin-top: 20px;">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Proxmox VE Login</legend>
|
<legend>Proxmox VE Login</legend>
|
||||||
<div class="input-grid" style="grid-template-columns: repeat(2, auto);">
|
<div class="input-grid" style="grid-template-columns: repeat(2, auto);">
|
||||||
|
@ -131,4 +131,43 @@ class Instance extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Dialog extends HTMLElement {
|
||||||
|
constructor () {
|
||||||
|
super();
|
||||||
|
let shadowRoot = this.attachShadow({mode: "open"});
|
||||||
|
|
||||||
|
shadowRoot.innerHTML = `
|
||||||
|
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||||
|
<link rel="stylesheet" href="css/dialog.css" type="text/css">
|
||||||
|
<dialog>
|
||||||
|
<form method="dialog"></form>
|
||||||
|
</dialog>
|
||||||
|
`;
|
||||||
|
|
||||||
|
this.shadowElement = shadowRoot;
|
||||||
|
this.dialog = shadowRoot.querySelector("dialog");
|
||||||
|
this.form = shadowRoot.querySelector("form");
|
||||||
|
}
|
||||||
|
|
||||||
|
set body (body) {
|
||||||
|
this.form.innerHTML = body + `
|
||||||
|
<div class="btn-group">
|
||||||
|
<button value="cancel">Cancel</button>
|
||||||
|
<button value="confirm">Confirm</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
set callback (callback) {
|
||||||
|
this.dialog.addEventListener("close", () => {
|
||||||
|
callback(this.dialog.returnValue, new FormData(this.form));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
show () {
|
||||||
|
this.dialog.showModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
customElements.define("instance-article", Instance);
|
customElements.define("instance-article", Instance);
|
||||||
|
customElements.define("dialog-form", Dialog);
|
Loading…
Reference in New Issue
Block a user