diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/app.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/app.vue index 80ba7d4733..5f89729b79 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/app.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/app.vue @@ -28,7 +28,7 @@ function openForm(url: string, data: Record) { document.body.removeChild(form); } -function openPreview(e: SubmitEvent) { +function openPreview(e: Event) { e.preventDefault(); openForm("../../preview/", { csrfmiddlewaretoken: store.csrfToken, @@ -78,7 +78,7 @@ const preview_layout = computed(() => { .panel-body div(v-if="preview_layout") span.text-muted The preview below is only a rough representation of what the pass might look like. Please check the generated pass. - div + div(style="display: grid; gap: 1em; grid-template-columns: repeat(auto-fit, minmax(auto, 360px));") PassPreview(v-for="layout in preview_layout" :layout="layout") div(v-else) Preview not supported //- pre @@ -98,6 +98,7 @@ const preview_layout = computed(() => { .walletsettings-panel .panel-heading { .checkbox { padding: 0; + margin: 0; display: inline-block; input[type=checkbox] { margin-top: 0; @@ -106,6 +107,9 @@ const preview_layout = computed(() => { position: relative; top: 1px; } + label { + padding-left: 0; + } } } \ No newline at end of file diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/predefined-field-settings.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/predefined-field-settings.vue index 4f5539af58..10a0f79725 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/predefined-field-settings.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/predefined-field-settings.vue @@ -22,7 +22,7 @@ watchEffect(() => { .panel-heading h3.panel-title.form-inline .form-group - Checkbox(:label="fieldgroup.name" v-model="fieldConfig.active") + Checkbox(v-if="!!fieldConfig" :label="fieldgroup.name" v-model="fieldConfig.active") .panel-body(v-if="!!fieldgroup.description") .form-group span.text-muted {{ fieldgroup.description }} diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-item-preview.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-item-preview.vue new file mode 100644 index 0000000000..68c8531ec0 --- /dev/null +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-item-preview.vue @@ -0,0 +1,25 @@ + + + \ No newline at end of file diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-preview.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-preview.vue index 4818caf217..440073c4a8 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-preview.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/fieldgroup-preview.vue @@ -22,22 +22,4 @@ const style_def = computed(() => { diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/pass-preview.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/pass-preview.vue index 33f81b85d5..9eab779223 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/pass-preview.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/pass-preview.vue @@ -16,19 +16,18 @@ const props = defineProps<{ layout: Array }>(); + + \ No newline at end of file diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/placeholder-fieldgroup-preview.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/placeholder-fieldgroup-preview.vue index 38ff7fd17f..f753c170f4 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/placeholder-fieldgroup-preview.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/placeholder-fieldgroup-preview.vue @@ -1,7 +1,7 @@ diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts b/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts index d9d078bfa8..144744f900 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts @@ -19,7 +19,7 @@ type PlaceholderFieldGroupDefinition = BaseFieldGroupDefinition & { display: FieldGroupDisplay; min_entries: number | null; max_entries: number | null; - context_args: string[] + context_args: string[]; }; type PredefinedFieldGroupDefinition = BaseFieldGroupDefinition & { @@ -104,10 +104,32 @@ type WalletStore = { }; type PreviewLayout = Array; -type PreviewRow = { children: Array } | PreviewFieldgroup; -type PreviewFieldgroup = { - fieldgroup: string; +type PreviewRow = + | { children: Array; direction?: "row" | "column"; display?: Array;} + | PreviewFieldgroup + | FixedPreview; + +type PreviewProps = { relSize?: number; - direction?: 'row' | 'column', - display?: Array -}; + direction?: "row" | "column"; + display?: Array; +} + +type PreviewFieldgroup = PredefinedFieldgroupPreview | PlaceholderFieldGroupPreview; +type FixedPreview = { + value: I18nString; +} & PreviewProps + +type PlaceholderFieldGroupPreview = { + fieldgroup: string; +} & PreviewProps; + +type PredefinedFieldgroupPreview = { + fieldgroup: string; + sample: PreviewSample[]; +} & PreviewProps; + +type PreviewSample = { + content: I18nString; + label: I18nString; +} \ No newline at end of file diff --git a/src/pretix/plugins/wallet/styles/base.py b/src/pretix/plugins/wallet/styles/base.py index ca8fe6666a..8eb2f67ae3 100644 --- a/src/pretix/plugins/wallet/styles/base.py +++ b/src/pretix/plugins/wallet/styles/base.py @@ -1,6 +1,5 @@ import enum -from typing import Any, TypedDict -from black.nodes import is_vararg +from typing import TypedDict from i18nfield.strings import LazyI18nString import jsonschema from django.core.exceptions import ValidationError @@ -46,7 +45,7 @@ class FieldGroup: remaining_fields: list["FieldGroup"], context: LayoutContext, ) -> dict: - raise NotImplemented() + raise NotImplementedError() def asdict(self): return { @@ -119,7 +118,7 @@ class PredefinedFieldGroup(FieldGroup): remaining_fields: list["FieldGroup"], context: LayoutContext, ): - return {"type": "object"} + return {"type": "object", "properties": {"active": {"type": "boolean"}}} class PlaceholderFieldGroup(FieldGroup): @@ -165,7 +164,7 @@ class PlaceholderFieldGroup(FieldGroup): "display": self.display.value, "min_entries": self.min_entries, "max_entries": self.max_entries, - "context_args": list(sorted(self.context_args)) + "context_args": list(sorted(self.context_args)), } def layout_schema( @@ -257,8 +256,9 @@ class ImageFieldGroup(PlaceholderFieldGroup): class PassStyle: identifier: str # unique within platform name: str - # order here limits in what order users can configure field "overspilling" (if too many fields are defined, where should the rest go) -> can only go down in the list - # we evaluate the fields in this order, so they overspill in this order as well (fields from primary are appended to the overspilling field before fields from secondary are etc) + # order here limits in what order users can configure field "overspilling" (if too many fields are defined, where should the rest go) + # -> can only go down in the list + # we evaluate the fields in this order, so they overspill in this order as well fieldgroups: list[FieldGroup] @property @@ -379,5 +379,8 @@ class PassStyle: raise ValueError("Unknown field group") return fields + def group_is_active(self, identifier: str): + return self.layout['fieldgroups'].get(identifier, {}).get("active", False) + def generate(self, op: OrderPosition): raise NotImplementedError() diff --git a/src/pretix/plugins/wallet/styles/google.py b/src/pretix/plugins/wallet/styles/google.py index de9b52bdd8..16a62dbeeb 100644 --- a/src/pretix/plugins/wallet/styles/google.py +++ b/src/pretix/plugins/wallet/styles/google.py @@ -1,5 +1,3 @@ -from i18nfield.fields import LazyI18nString - from pretix.base.models import Event, OrderPosition from .base import ( @@ -12,7 +10,6 @@ from .base import ( WalletPlatform, ) from django.utils.translation import gettext as _ -import json from walletobjects import ButtonJWT, EventTicketClass, EventTicketObject from walletobjects.comms import Comms @@ -207,7 +204,12 @@ class GoogleWalletStyle(PassStyle): ) ) - return 'googlepaypass', 'text/uri-list', 'https://pay.google.com/gp/v/save/%s' % generated_jwt + return ( + "googlepaypass", + "text/uri-list", + "https://pay.google.com/gp/v/save/%s" % generated_jwt, + ) + class GoogleWalletEventTicket(GoogleWalletStyle): identifier = "event" @@ -266,7 +268,7 @@ class GoogleWalletEventTicket(GoogleWalletStyle): {"value": str(self.event.name), "display": "large"}, ], "direction": "column", - "display": ["tight"] + "display": ["tight"], }, { "fieldgroup": "date", @@ -283,7 +285,15 @@ class GoogleWalletEventTicket(GoogleWalletStyle): ], }, {"fieldgroup": "code"}, - ] + ], + [ + { + "fieldgroup": "venue", + "sample": [ + {"content": self.venue()[1], "label": self.venue()[0]}, + ], + }, + ], ] def venue(self): @@ -291,17 +301,23 @@ class GoogleWalletEventTicket(GoogleWalletStyle): name = {} address = {} - for key, value in self.event.location.data.items(): + for key, value in self.event.location.data.items(): lines = value.splitlines() name[key] = lines[0] # We must provide at least one address line each for the name and address - no way around it. if len(lines) > 1: - address[key] = '\n'.join(value.splitlines()[1:]) + address[key] = "\n".join(value.splitlines()[1:]) else: address[key] = lines[0] return name, address - return None, None + return "", "" + + def _generate_class(self): + output_class = super()._generate_class() + if self.group_is_active("venue") and all(self.venue()): + output_class.venue(*self.venue()) + return output_class def _generate_object(self, op: OrderPosition, class_id: str): output_object = super()._generate_object(op, class_id)