web/admin: fix error in firefox when creating token
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
c15d0c3d17
commit
663dffd8be
|
@ -141,6 +141,14 @@ export class Form<T> extends LitElement {
|
|||
element.type === "datetime-local"
|
||||
) {
|
||||
json[element.name] = new Date(element.valueAsNumber);
|
||||
} else if (
|
||||
element.tagName.toLowerCase() === "input" &&
|
||||
"type" in element.dataset &&
|
||||
element.dataset["type"] === "datetime-local"
|
||||
) {
|
||||
// Workaround for Firefox <93, since 92 and older don't support
|
||||
// datetime-local fields
|
||||
json[element.name] = new Date(element.value);
|
||||
} else if (element.tagName.toLowerCase() === "input" && element.type === "checkbox") {
|
||||
json[element.name] = element.checked;
|
||||
} else {
|
||||
|
|
|
@ -43,6 +43,7 @@ export class InvitationForm extends ModelForm<Invitation, string> {
|
|||
<ak-form-element-horizontal label=${t`Expires`} ?required=${true} name="expires">
|
||||
<input
|
||||
type="datetime-local"
|
||||
data-type="datetime-local"
|
||||
class="pf-c-form-control"
|
||||
required
|
||||
value="${dateTimeLocal(first(this.instance?.expires, new Date()))}"
|
||||
|
|
|
@ -7,7 +7,6 @@ import "../../elements/forms/HorizontalFormElement";
|
|||
import "../../elements/forms/FormGroup";
|
||||
import { dateTimeLocal, first } from "../../utils";
|
||||
import { ModelForm } from "../../elements/forms/ModelForm";
|
||||
import { until } from "lit-html/directives/until";
|
||||
|
||||
@customElement("ak-token-form")
|
||||
export class TokenForm extends ModelForm<Token, string> {
|
||||
|
@ -51,27 +50,6 @@ export class TokenForm extends ModelForm<Token, string> {
|
|||
${t`Unique identifier the token is referenced by.`}
|
||||
</p>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal label=${t`User`} ?required=${true} name="user">
|
||||
<select class="pf-c-form-control">
|
||||
${until(
|
||||
new CoreApi(DEFAULT_CONFIG)
|
||||
.coreUsersList({
|
||||
ordering: "username",
|
||||
})
|
||||
.then((users) => {
|
||||
return users.results.map((user) => {
|
||||
return html`<option
|
||||
value=${user.pk}
|
||||
?selected=${this.instance?.user === user.pk}
|
||||
>
|
||||
${user.username}
|
||||
</option>`;
|
||||
});
|
||||
}),
|
||||
html`<option>${t`Loading...`}</option>`,
|
||||
)}
|
||||
</select>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal label=${t`Intent`} ?required=${true} name="intent">
|
||||
<select class="pf-c-form-control">
|
||||
<option
|
||||
|
@ -111,6 +89,7 @@ export class TokenForm extends ModelForm<Token, string> {
|
|||
<ak-form-element-horizontal label=${t`Expires on`} name="expires">
|
||||
<input
|
||||
type="datetime-local"
|
||||
data-type="datetime-local"
|
||||
value="${dateTimeLocal(first(this.instance?.expires, new Date()))}"
|
||||
class="pf-c-form-control"
|
||||
/>
|
||||
|
|
Reference in New Issue