web/admin: fix application form's provider selection not working

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-11 13:33:35 +02:00
parent 8df29235bb
commit ab4569e5d6
4 changed files with 8 additions and 13 deletions

View File

@ -100,8 +100,3 @@ class ProxyOutpostConfigViewSet(ReadOnlyModelViewSet):
queryset = ProxyProvider.objects.filter(application__isnull=False) queryset = ProxyProvider.objects.filter(application__isnull=False)
serializer_class = ProxyOutpostConfigSerializer serializer_class = ProxyOutpostConfigSerializer
ordering = ["name"] ordering = ["name"]
def get_queryset(self):
qs = super().get_queryset()
print(qs)
return qs

View File

@ -72,7 +72,7 @@ export class ApplicationForm extends Form<Application> {
${Array.from(m).map(([group, providers]) => { ${Array.from(m).map(([group, providers]) => {
return html`<optgroup label=${group}> return html`<optgroup label=${group}>
${providers.map(p => { ${providers.map(p => {
const selected = (this.application?.provider?.pk === p.pk) || (this.provider === p.pk); const selected = (this.application?.provider === p.pk) || (this.provider === p.pk);
return html`<option ?selected=${selected} value=${ifDefined(p.pk)}>${p.name}</option>`; return html`<option ?selected=${selected} value=${ifDefined(p.pk)}>${p.name}</option>`;
})} })}
</optgroup>`; </optgroup>`;
@ -98,7 +98,7 @@ export class ApplicationForm extends Form<Application> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Provider`} label=${t`Provider`}
name="parent"> name="provider">
<select class="pf-c-form-control"> <select class="pf-c-form-control">
<option value="" ?selected=${this.application?.provider === undefined}>---------</option> <option value="" ?selected=${this.application?.provider === undefined}>---------</option>
${until(new ProvidersApi(DEFAULT_CONFIG).providersAllList({}).then(providers => { ${until(new ProvidersApi(DEFAULT_CONFIG).providersAllList({}).then(providers => {

View File

@ -75,11 +75,11 @@ export class ApplicationListPage extends TablePage<Application> {
</a>`, </a>`,
html`<code>${item.slug}</code>`, html`<code>${item.slug}</code>`,
item.provider ? item.provider ?
html`<a href="#/core/providers/${item.provider.pk}"> html`<a href="#/core/providers/${item.providerObj?.pk}">
${item.provider?.name} ${item.providerObj?.name}
</a>` : </a>` :
html`-`, html`-`,
html`${item.provider?.verboseName || "-"}`, html`${item.providerObj?.verboseName || "-"}`,
html` html`
<ak-forms-modal> <ak-forms-modal>
<span slot="submit"> <span slot="submit">

View File

@ -81,15 +81,15 @@ export class ApplicationViewPage extends LitElement {
<div class="pf-c-card__title">${t`Related`}</div> <div class="pf-c-card__title">${t`Related`}</div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<dl class="pf-c-description-list"> <dl class="pf-c-description-list">
${this.application.provider ? ${this.application.providerObj ?
html`<div class="pf-c-description-list__group"> html`<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term"> <dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`Provider`}</span> <span class="pf-c-description-list__text">${t`Provider`}</span>
</dt> </dt>
<dd class="pf-c-description-list__description"> <dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text"> <div class="pf-c-description-list__text">
<a href="#/core/providers/${this.application.provider.pk}"> <a href="#/core/providers/${this.application.providerObj?.pk}">
${this.application.provider.name} ${this.application.providerObj?.name}
</a> </a>
</div> </div>
</dd> </dd>