2022-03-16 20:53:50 +01:00
|
|
|
import {css, CSSResultArray, html, LitElement} from "@lion/core";
|
2022-03-15 00:06:42 +01:00
|
|
|
import {Et2Widget} from "../Et2Widget/Et2Widget";
|
2022-08-18 22:46:44 +02:00
|
|
|
import shoelace from "../Styles/shoelace";
|
2022-03-15 00:06:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget for the actual content of a dialog, used when we're not doing a template
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export class Et2DialogContent extends Et2Widget(LitElement)
|
|
|
|
{
|
2022-03-16 20:53:50 +01:00
|
|
|
static styles : CSSResultArray = [
|
2022-08-18 22:46:44 +02:00
|
|
|
shoelace,
|
2022-03-16 20:53:50 +01:00
|
|
|
css`
|
2022-03-15 00:06:42 +01:00
|
|
|
:host {
|
|
|
|
display: block;
|
2022-03-24 18:41:29 +01:00
|
|
|
min-width: 300px;
|
2022-03-24 18:21:32 +01:00
|
|
|
min-height: 32px;
|
2022-03-15 00:06:42 +01:00
|
|
|
}
|
2022-03-15 21:10:53 +01:00
|
|
|
.dialog {
|
|
|
|
}
|
|
|
|
.dialog_icon {
|
|
|
|
margin-right: 2ex;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
`
|
2022-03-16 20:53:50 +01:00
|
|
|
];
|
|
|
|
|
2022-03-15 00:06:42 +01:00
|
|
|
|
|
|
|
get properties()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
...super.properties(),
|
|
|
|
|
|
|
|
message: String,
|
2022-07-21 17:57:50 +02:00
|
|
|
dialogType: Number,
|
2022-03-15 00:06:42 +01:00
|
|
|
icon: String,
|
|
|
|
value: Object
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Details for dialog type options
|
|
|
|
*/
|
2022-07-21 17:57:50 +02:00
|
|
|
private readonly _dialogTypes : any = [
|
2022-03-15 00:06:42 +01:00
|
|
|
//PLAIN_MESSAGE: 0
|
|
|
|
"",
|
|
|
|
//INFORMATION_MESSAGE: 1,
|
|
|
|
"dialog_info",
|
|
|
|
//QUESTION_MESSAGE: 2,
|
|
|
|
"dialog_help",
|
|
|
|
//WARNING_MESSAGE: 3,
|
|
|
|
"dialog_warning",
|
|
|
|
//ERROR_MESSAGE: 4,
|
|
|
|
"dialog_error"
|
|
|
|
];
|
|
|
|
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.icon = "";
|
2022-07-21 17:57:50 +02:00
|
|
|
this.dialogType = 0;
|
2022-03-15 00:06:42 +01:00
|
|
|
}
|
|
|
|
|
2022-03-15 21:10:53 +01:00
|
|
|
/**
|
|
|
|
* Block until after the paint - This is needed to deal with children not fully "done" before the OverlayController
|
|
|
|
* tries to do things with them
|
|
|
|
*
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
async performUpdate()
|
|
|
|
{
|
|
|
|
await new Promise((resolve) => setTimeout(() => resolve()));
|
|
|
|
return super.performUpdate();
|
|
|
|
}
|
2022-03-15 00:06:42 +01:00
|
|
|
|
|
|
|
render()
|
|
|
|
{
|
2022-07-21 17:57:50 +02:00
|
|
|
let icon = this.icon || this.parentNode.egw().image(this._dialogTypes[this.dialogType]) || "";
|
2022-03-15 00:06:42 +01:00
|
|
|
return html`
|
2022-07-21 17:57:50 +02:00
|
|
|
<div class="dialog ${this._dialogTypes[this.dialogType]}">
|
2022-03-15 21:10:53 +01:00
|
|
|
<img class="dialog_icon" src=${icon}/>
|
2022-03-15 00:06:42 +01:00
|
|
|
<slot>Empty dialog - add some content</slot>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("et2-dialog-content", Et2DialogContent);
|