web/elements: Fix display in deleteform when object has no name

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-06 17:27:53 +02:00
parent a13d89fcde
commit fb409a73a1
4 changed files with 23 additions and 15 deletions

View File

@ -101,9 +101,11 @@ class PolicyBindingSerializer(ModelSerializer):
class PolicyBindingViewSet(ModelViewSet):
"""PolicyBinding Viewset"""
queryset = PolicyBinding.objects.all().select_related(
"target", "group", "user"
).prefetch_related("policy") # prefetching policy so we resolve the subclass
queryset = (
PolicyBinding.objects.all()
.select_related("target", "group", "user")
.prefetch_related("policy")
) # prefetching policy so we resolve the subclass
serializer_class = PolicyBindingSerializer
filterset_fields = ["policy", "target", "enabled", "order", "timeout"]
search_fields = ["policy__name"]

View File

@ -49,6 +49,12 @@ export class DeleteForm extends ModalButton {
}
renderModalInner(): TemplateResult {
let objName = this.obj?.name;
if (objName) {
objName = ` "${objName}"`;
} else {
objName = "";
}
return html`<section class="pf-c-page__main-section pf-m-light">
<div class="pf-c-content">
<h1 class="pf-c-title pf-m-2xl">
@ -59,7 +65,7 @@ export class DeleteForm extends ModalButton {
<section class="pf-c-page__main-section pf-m-light">
<form class="pf-c-form pf-m-horizontal">
<p>
${t`Are you sure you want to delete ${this.objectLabel} "${this.obj?.name}"?`}
${t`Are you sure you want to delete ${this.objectLabel} ${objName} ?`}
</p>
</form>
</section>

View File

@ -188,9 +188,9 @@ msgstr ""
"Are you sure you want to clear the policy cache?\n"
"This will cause all policies to be re-evaluated on their next usage."
#: src/elements/forms/DeleteForm.ts:62
msgid "Are you sure you want to delete {0} \"{1}\"?"
msgstr "Are you sure you want to delete {0} \"{1}\"?"
#: src/elements/forms/DeleteForm.ts:69
msgid "Are you sure you want to delete {0} {objName} ?"
msgstr "Are you sure you want to delete {0} {objName} ?"
#: src/pages/users/UserActiveForm.ts:52
msgid "Are you sure you want to update {0} \"{1}\"?"
@ -385,7 +385,7 @@ msgid "Can be in the format of 'unix://' when connecting to a local docker daemo
msgstr "Can be in the format of 'unix://' when connecting to a local docker daemon, or 'https://:2376' when connecting to a remote system."
#: src/elements/forms/ConfirmationForm.ts:75
#: src/elements/forms/DeleteForm.ts:79
#: src/elements/forms/DeleteForm.ts:86
#: src/elements/forms/ModalForm.ts:71
#: src/pages/users/UserActiveForm.ts:73
msgid "Cancel"
@ -813,7 +813,7 @@ msgstr "Decides what this Flow is used for. For example, the Authentication flow
msgid "Define how notifications are sent to users, like Email or Webhook."
msgstr "Define how notifications are sent to users, like Email or Webhook."
#: src/elements/forms/DeleteForm.ts:72
#: src/elements/forms/DeleteForm.ts:79
#: src/pages/applications/ApplicationListPage.ts:102
#: src/pages/crypto/CertificateKeyPairListPage.ts:86
#: src/pages/events/RuleListPage.ts:82
@ -861,7 +861,7 @@ msgstr "Delete account"
msgid "Delete temporary users after"
msgstr "Delete temporary users after"
#: src/elements/forms/DeleteForm.ts:55
#: src/elements/forms/DeleteForm.ts:62
msgid "Delete {0}"
msgstr "Delete {0}"

View File

@ -184,8 +184,8 @@ msgid ""
"This will cause all policies to be re-evaluated on their next usage."
msgstr ""
#: src/elements/forms/DeleteForm.ts:62
msgid "Are you sure you want to delete {0} \"{1}\"?"
#: src/elements/forms/DeleteForm.ts:69
msgid "Are you sure you want to delete {0} {objName} ?"
msgstr ""
#: src/pages/users/UserActiveForm.ts:52
@ -381,7 +381,7 @@ msgid "Can be in the format of 'unix://' when connecting to a local docker daemo
msgstr ""
#: src/elements/forms/ConfirmationForm.ts:75
#: src/elements/forms/DeleteForm.ts:79
#: src/elements/forms/DeleteForm.ts:86
#: src/elements/forms/ModalForm.ts:71
#: src/pages/users/UserActiveForm.ts:73
msgid "Cancel"
@ -809,7 +809,7 @@ msgstr ""
msgid "Define how notifications are sent to users, like Email or Webhook."
msgstr ""
#: src/elements/forms/DeleteForm.ts:72
#: src/elements/forms/DeleteForm.ts:79
#: src/pages/applications/ApplicationListPage.ts:102
#: src/pages/crypto/CertificateKeyPairListPage.ts:86
#: src/pages/events/RuleListPage.ts:82
@ -857,7 +857,7 @@ msgstr ""
msgid "Delete temporary users after"
msgstr ""
#: src/elements/forms/DeleteForm.ts:55
#: src/elements/forms/DeleteForm.ts:62
msgid "Delete {0}"
msgstr ""