web: rudimentary lazy loading for modals
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
76e571ea0a
commit
12bfa404c8
|
@ -136,6 +136,11 @@ export class ModalButton extends LitElement {
|
||||||
if (!this.href) {
|
if (!this.href) {
|
||||||
this.updateHandlers();
|
this.updateHandlers();
|
||||||
this.open = true;
|
this.open = true;
|
||||||
|
this.querySelectorAll("*").forEach(child => {
|
||||||
|
if ("requestUpdate" in child) {
|
||||||
|
(child as LitElement).requestUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const request = new Request(this.href);
|
const request = new Request(this.href);
|
||||||
fetch(request, {
|
fetch(request, {
|
||||||
|
|
|
@ -100,6 +100,10 @@ export class Form<T> extends LitElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): TemplateResult {
|
render(): TemplateResult {
|
||||||
|
const rect = this.getBoundingClientRect();
|
||||||
|
if (rect.x + rect.y + rect.width + rect.height === 0) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
return html`<iron-form
|
return html`<iron-form
|
||||||
@iron-form-presubmit=${(ev: Event) => { this.submit(ev); }}>
|
@iron-form-presubmit=${(ev: Event) => { this.submit(ev); }}>
|
||||||
${this.renderForm()}
|
${this.renderForm()}
|
||||||
|
|
|
@ -8,12 +8,6 @@ export class HorizontalFormElement extends LitElement {
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [PFForm, PFFormControl, css`
|
return [PFForm, PFFormControl, css`
|
||||||
slot {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-around;
|
|
||||||
}
|
|
||||||
.pf-c-form__group {
|
.pf-c-form__group {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: var(--pf-c-form--m-horizontal__group-label--md--GridColumnWidth) var(--pf-c-form--m-horizontal__group-control--md--GridColumnWidth);
|
grid-template-columns: var(--pf-c-form--m-horizontal__group-label--md--GridColumnWidth) var(--pf-c-form--m-horizontal__group-control--md--GridColumnWidth);
|
||||||
|
@ -51,8 +45,8 @@ export class HorizontalFormElement extends LitElement {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="pf-c-form__group-control">
|
<div class="pf-c-form__group-control">
|
||||||
|
<slot class="pf-c-form__horizontal-group"></slot>
|
||||||
<div class="pf-c-form__horizontal-group">
|
<div class="pf-c-form__horizontal-group">
|
||||||
<slot></slot>
|
|
||||||
${this.invalid ? html`<p class="pf-c-form__helper-text pf-m-error" aria-live="polite">${this.errorMessage}</p>` : html``}
|
${this.invalid ? html`<p class="pf-c-form__helper-text pf-m-error" aria-live="polite">${this.errorMessage}</p>` : html``}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,7 +34,7 @@ export class GroupForm extends Form<Group> {
|
||||||
<ak-form-element-horizontal label=${gettext("Name")} ?required=${true}>
|
<ak-form-element-horizontal label=${gettext("Name")} ?required=${true}>
|
||||||
<input type="text" name="name" value="${ifDefined(this.group?.name)}" class="pf-c-form-control" required="">
|
<input type="text" name="name" value="${ifDefined(this.group?.name)}" class="pf-c-form-control" required="">
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal ?required=${true}>
|
<ak-form-element-horizontal>
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" name="is_superuser" class="pf-c-check__input" ?checked=${this.group?.isSuperuser || false}>
|
<input type="checkbox" name="is_superuser" class="pf-c-check__input" ?checked=${this.group?.isSuperuser || false}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
|
|
Reference in New Issue