web: use custom-element as wrapper
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
48ee582f37
commit
76e571ea0a
|
@ -133,6 +133,27 @@
|
||||||
"resolved": "https://registry.npmjs.org/@patternfly/patternfly/-/patternfly-4.90.5.tgz",
|
"resolved": "https://registry.npmjs.org/@patternfly/patternfly/-/patternfly-4.90.5.tgz",
|
||||||
"integrity": "sha512-Fe0C8UkzSjtacQ+fHXlFB/LHzrv/c2K4z479C6dboOgkGQE1FyB0wt1NBfxij0D++rhOy04OOYdE+Tr0JSlZKw=="
|
"integrity": "sha512-Fe0C8UkzSjtacQ+fHXlFB/LHzrv/c2K4z479C6dboOgkGQE1FyB0wt1NBfxij0D++rhOy04OOYdE+Tr0JSlZKw=="
|
||||||
},
|
},
|
||||||
|
"@polymer/font-roboto": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/font-roboto/-/font-roboto-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-tx5TauYSmzsIvmSqepUPDYbs4/Ejz2XbZ1IkD7JEGqkdNUJlh+9KU85G56Tfdk/xjEZ8zorFfN09OSwiMrIQWA=="
|
||||||
|
},
|
||||||
|
"@polymer/iron-a11y-announcer": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-a11y-announcer/-/iron-a11y-announcer-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-lc5i4NKB8kSQHH0Hwu8WS3ym93m+J69OHJWSSBxwd17FI+h2wmgxDzeG9LI4ojMMck17/uc2pLe7g/UHt5/K/A==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-a11y-keys-behavior": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-a11y-keys-behavior/-/iron-a11y-keys-behavior-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-lnrjKq3ysbBPT/74l0Fj0U9H9C35Tpw2C/tpJ8a+5g8Y3YJs1WSZYnEl1yOkw6sEyaxOq/1DkzH0+60gGu5/PQ==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@polymer/iron-ajax": {
|
"@polymer/iron-ajax": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@polymer/iron-ajax/-/iron-ajax-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@polymer/iron-ajax/-/iron-ajax-3.0.1.tgz",
|
||||||
|
@ -141,6 +162,34 @@
|
||||||
"@polymer/polymer": "^3.0.0"
|
"@polymer/polymer": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@polymer/iron-autogrow-textarea": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-autogrow-textarea/-/iron-autogrow-textarea-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-5r0VkWrIlm0JIp5E5wlnvkw7slK72lFRZXncmrsLZF+6n1dg2rI8jt7xpFzSmUWrqpcyXwyKaGaDvUjl3j4JLA==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/iron-behaviors": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-flex-layout": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-validatable-behavior": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-behaviors": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-behaviors/-/iron-behaviors-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-IMEwcv1lhf1HSQxuyWOUIL0lOBwmeaoSTpgCJeP9IBYnuB1SPQngmfRuHKgK6/m9LQ9F9miC7p3HeQQUdKAE0w==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/iron-a11y-keys-behavior": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-flex-layout": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-flex-layout/-/iron-flex-layout-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-7gB869czArF+HZcPTVSgvA7tXYFze9EKckvM95NB7SqYF+NnsQyhoXgKnpFwGyo95lUjUW9TFDLUwDXnCYFtkw==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@polymer/iron-form": {
|
"@polymer/iron-form": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@polymer/iron-form/-/iron-form-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@polymer/iron-form/-/iron-form-3.0.1.tgz",
|
||||||
|
@ -150,6 +199,65 @@
|
||||||
"@polymer/polymer": "^3.0.0"
|
"@polymer/polymer": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@polymer/iron-form-element-behavior": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-form-element-behavior/-/iron-form-element-behavior-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-G/e2KXyL5AY7mMjmomHkGpgS0uAf4ovNpKhkuUTRnMuMJuf589bKqE85KN4ovE1Tzhv2hJoh/igyD6ekHiYU1A==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-input": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-input/-/iron-input-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-WLx13kEcbH9GKbj9+pWR6pbJkA5kxn3796ynx6eQd2rueMyUfVTR3GzOvadBKsciUuIuzrxpBWZ2+3UcueVUQQ==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/iron-a11y-announcer": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-validatable-behavior": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-meta": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-meta/-/iron-meta-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-pWguPugiLYmWFV9UWxLWzZ6gm4wBwQdDy4VULKwdHCqR7OP7u98h+XDdGZsSlDPv6qoryV/e3tGHlTIT0mbzJA==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/iron-validatable-behavior": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/iron-validatable-behavior/-/iron-validatable-behavior-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-wwpYh6wOa4fNI+jH5EYKC7TVPYQ2OfgQqocWat7GsNWcsblKYhLYbwsvEY5nO0n2xKqNfZzDLrUom5INJN7msQ==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/iron-meta": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/paper-input": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/paper-input/-/paper-input-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-6ghgwQKM6mS0hAQxQqj+tkeEY1VUBqAsrasAm8V5RpNcfSWQC/hhRFxU0beGuKTAhndzezDzWYP6Zz4b8fExGg==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/iron-a11y-keys-behavior": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-autogrow-textarea": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-behaviors": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-form-element-behavior": "^3.0.0-pre.26",
|
||||||
|
"@polymer/iron-input": "^3.0.0-pre.26",
|
||||||
|
"@polymer/paper-styles": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@polymer/paper-styles": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@polymer/paper-styles/-/paper-styles-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-y6hmObLqlCx602TQiSBKHqjwkE7xmDiFkoxdYGaNjtv4xcysOTdVJsDR/R9UHwIaxJ7gHlthMSykir1nv78++g==",
|
||||||
|
"requires": {
|
||||||
|
"@polymer/font-roboto": "^3.0.1",
|
||||||
|
"@polymer/iron-flex-layout": "^3.0.0-pre.26",
|
||||||
|
"@polymer/polymer": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@polymer/polymer": {
|
"@polymer/polymer": {
|
||||||
"version": "3.4.1",
|
"version": "3.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@polymer/polymer/-/polymer-3.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/@polymer/polymer/-/polymer-3.4.1.tgz",
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"@fortawesome/fontawesome-free": "^5.15.3",
|
"@fortawesome/fontawesome-free": "^5.15.3",
|
||||||
"@patternfly/patternfly": "^4.90.5",
|
"@patternfly/patternfly": "^4.90.5",
|
||||||
"@polymer/iron-form": "^3.0.1",
|
"@polymer/iron-form": "^3.0.1",
|
||||||
|
"@polymer/paper-input": "^3.2.1",
|
||||||
"@sentry/browser": "^6.2.3",
|
"@sentry/browser": "^6.2.3",
|
||||||
"@sentry/tracing": "^6.2.3",
|
"@sentry/tracing": "^6.2.3",
|
||||||
"@types/chart.js": "^2.9.31",
|
"@types/chart.js": "^2.9.31",
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { customElement, LitElement, CSSResult, property, css } from "lit-element";
|
||||||
|
import { TemplateResult, html } from "lit-html";
|
||||||
|
import PFForm from "@patternfly/patternfly/components/Form/form.css";
|
||||||
|
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
|
||||||
|
|
||||||
|
@customElement("ak-form-element-horizontal")
|
||||||
|
export class HorizontalFormElement extends LitElement {
|
||||||
|
|
||||||
|
static get styles(): CSSResult[] {
|
||||||
|
return [PFForm, PFFormControl, css`
|
||||||
|
slot {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
.pf-c-form__group {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
.pf-c-form__group-label {
|
||||||
|
padding-top: var(--pf-c-form--m-horizontal__group-label--md--PaddingTop);
|
||||||
|
}
|
||||||
|
`];
|
||||||
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
label: string = "";
|
||||||
|
|
||||||
|
@property({ type: Boolean })
|
||||||
|
required = false;
|
||||||
|
|
||||||
|
@property()
|
||||||
|
errorMessage: string = "";
|
||||||
|
|
||||||
|
@property()
|
||||||
|
invalid: boolean = false;
|
||||||
|
|
||||||
|
updated(): void {
|
||||||
|
this.querySelectorAll<HTMLInputElement>("input[autofocus]").forEach(input => {
|
||||||
|
input.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): TemplateResult {
|
||||||
|
return html`<div class="pf-c-form__group">
|
||||||
|
<div class="pf-c-form__group-label">
|
||||||
|
<label class="pf-c-form__label">
|
||||||
|
<span class="pf-c-form__label-text">${this.label}</span>
|
||||||
|
${this.required ? html`<span class="pf-c-form__label-required" aria-hidden="true">*</span>` : html``}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="pf-c-form__group-control">
|
||||||
|
<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``}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
import { TemplateResult, html } from "lit-html";
|
|
||||||
|
|
||||||
export function formGroup(label: string, body: TemplateResult): TemplateResult {
|
|
||||||
return html`<div class="pf-c-form__group">
|
|
||||||
<div class="pf-c-form__group-label">
|
|
||||||
<label class="pf-c-form__label">
|
|
||||||
<span class="pf-c-form__label-text">${label}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="pf-c-form__group-control">
|
|
||||||
<div class="pf-c-form__horizontal-group">
|
|
||||||
${body}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
|
@ -5,8 +5,8 @@ import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||||
import { Form } from "../../elements/forms/Form";
|
import { Form } from "../../elements/forms/Form";
|
||||||
import { until } from "lit-html/directives/until";
|
import { until } from "lit-html/directives/until";
|
||||||
import { formGroup } from "../../elements/forms/utils";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
|
import "../../elements/forms/HorizontalFormElement";
|
||||||
|
|
||||||
@customElement("ak-group-form")
|
@customElement("ak-group-form")
|
||||||
export class GroupForm extends Form<Group> {
|
export class GroupForm extends Form<Group> {
|
||||||
|
@ -31,42 +31,42 @@ export class GroupForm extends Form<Group> {
|
||||||
|
|
||||||
renderForm(): TemplateResult {
|
renderForm(): TemplateResult {
|
||||||
return html`<form class="pf-c-form pf-m-horizontal">
|
return html`<form class="pf-c-form pf-m-horizontal">
|
||||||
${formGroup(gettext("Name"), html`
|
<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>
|
||||||
${formGroup("", html`
|
<ak-form-element-horizontal ?required=${true}>
|
||||||
<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">
|
||||||
${gettext("Is superuser")}
|
${gettext("Is superuser")}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<p class="pf-c-form__helper-text">${gettext("Users added to this group will be superusers.")}</p>
|
<p class="pf-c-form__helper-text">${gettext("Users added to this group will be superusers.")}</p>
|
||||||
`)}
|
</ak-form-element-horizontal>
|
||||||
${formGroup(gettext("Parent"), html`
|
<ak-form-element-horizontal label=${gettext("Parent")} ?required=${true}>
|
||||||
<select name="parent" class="pf-c-form-control">
|
<select name="parent" class="pf-c-form-control">
|
||||||
<option value="" ?selected=${this.group?.parent === undefined}>---------</option>
|
<option value="" ?selected=${this.group?.parent === undefined}>---------</option>
|
||||||
${until(new CoreApi(DEFAULT_CONFIG).coreGroupsList({}).then(groups => {
|
${until(new CoreApi(DEFAULT_CONFIG).coreGroupsList({}).then(groups => {
|
||||||
return groups.results.map(group => {
|
return groups.results.map(group => {
|
||||||
return html`<option value=${ifDefined(group.pk)} ?selected=${this.group?.parent === group.pk}>${group.name}</option>`;
|
return html`<option value=${ifDefined(group.pk)} ?selected=${this.group?.parent === group.pk}>${group.name}</option>`;
|
||||||
|
});
|
||||||
|
}), html``)}
|
||||||
|
</select>
|
||||||
|
</ak-form-element-horizontal>
|
||||||
|
<ak-form-element-horizontal label=${gettext("Members")} ?required=${true}>
|
||||||
|
<select name="users" class="pf-c-form-control" multiple="">
|
||||||
|
${until(new CoreApi(DEFAULT_CONFIG).coreUsersList({}).then(users => {
|
||||||
|
return users.results.map(user => {
|
||||||
|
const selected = Array.from(this.group?.users || []).some(su => {
|
||||||
|
return su == user.pk;
|
||||||
});
|
});
|
||||||
}), html``)}
|
return html`<option value=${ifDefined(user.pk)} ?selected=${selected}>${user.username}</option>`;
|
||||||
</select>
|
});
|
||||||
`)}
|
}))}
|
||||||
${formGroup(gettext("Members"), html`
|
</select>
|
||||||
<select name="users" class="pf-c-form-control" multiple="">
|
<p class="pf-c-form__helper-text">${gettext("Hold control/command to select multiple items.")}</p>
|
||||||
${until(new CoreApi(DEFAULT_CONFIG).coreUsersList({}).then(users => {
|
</ak-form-element-horizontal>
|
||||||
return users.results.map(user => {
|
</form>`;
|
||||||
const selected = Array.from(this.group?.users || []).some(su => {
|
|
||||||
return su == user.pk;
|
|
||||||
});
|
|
||||||
return html`<option value=${ifDefined(user.pk)} ?selected=${selected}>${user.username}</option>`;
|
|
||||||
});
|
|
||||||
}))}
|
|
||||||
</select>
|
|
||||||
<p class="pf-c-form__helper-text">${gettext("Hold control/command to select multiple items.")}</p>
|
|
||||||
`)}
|
|
||||||
</form>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue