From c78828dbfbb3ffccb591e330d011e21d7e4ee9bf Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Fri, 9 Oct 2026 17:34:59 +0200 Subject: [PATCH] bugfixing; update types --- .../wallet/components/input/file-input.vue | 2 +- .../wallet/components/input/i18ninput.vue | 2 +- .../wallet/components/input/input.vue | 2 +- .../preview/fieldgroup-item-preview.vue | 4 +- .../components/preview/pass-preview.vue | 9 +++- .../components/preview/setting-preview.vue | 27 +++++------ .../static/pretixplugins/wallet/helpers.ts | 2 +- .../static/pretixplugins/wallet/index.d.ts | 48 +++++++------------ src/pretix/plugins/wallet/styles/base.py | 4 +- src/pretix/plugins/wallet/styles/google.py | 2 +- src/pretix/plugins/wallet/views.py | 2 +- 11 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/file-input.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/file-input.vue index 868d0d460b..a37cbf0441 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/file-input.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/file-input.vue @@ -8,7 +8,7 @@ defineOptions({ }); const emit = defineEmits<{change: [File]}>() const props = defineProps<{ - label?: I18nString; + label?: LocalizableString; errors?: string[]; help_text?: string; filename?: string; diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/i18ninput.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/i18ninput.vue index 2094555445..734e5e273b 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/i18ninput.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/i18ninput.vue @@ -27,5 +27,5 @@ watchEffect(() => { diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/input.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/input.vue index 3b492f9b0c..2db737fa3c 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/input.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/input/input.vue @@ -15,7 +15,7 @@ const { max=null, defaultVal=null } = defineProps<{ - label?: I18nString; + label?: string; errors?: string[]; type?: string; help_text?: string; 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 index 6ed5cf9e41..5467f87496 100644 --- 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 @@ -6,8 +6,8 @@ import { i18nstringLocalize } from "../../helpers"; const store = inject(StoreKey)!; const props = defineProps<{ - label?: I18nString; - content: I18nString; + label?: LocalizableString; + content: LocalizableString; content_type: FieldContentType; display: FieldGroupDisplay; display_class?: string | string[]; 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 89a14d7f0c..580175fe92 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 @@ -5,7 +5,7 @@ import RowPreview from "./row-preview.vue"; const store = inject(StoreKey)!; -const { layout } = defineProps<{ layout: Array }>(); +const { layout } = defineProps<{ layout: PreviewLayout }>(); const layoutStyle = computed(() => { if (layout.style) { @@ -150,5 +150,12 @@ console.log("layoutStyle", layoutStyle.value); .img-inline { max-height: 3lh; } + .img-circle-sm { + max-height: 2lh; + aspect-ratio: 1; + border-radius: 50%; + background-color: white; + object-fit: fill; + } } diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/setting-preview.vue b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/setting-preview.vue index 3df4c5db9b..bec13d1aa3 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/setting-preview.vue +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/components/preview/setting-preview.vue @@ -7,26 +7,23 @@ import PredefinedFieldgroupPreview from "./predefined-fieldgroup-preview.vue"; const store = inject(StoreKey)!; const { config } = defineProps<{ - config: SettingPreview; + config: SettingPreview; }>(); const settingDef = computed(() => { - return Object.fromEntries( - store.styles[store.layout.style].settings.map((x) => [x.identifier, x]), - )[config.setting]; + return Object.fromEntries( + store.styles[store.layout.style].settings.map((x) => [x.identifier, x]), + )[config.setting]; }); const settingValue = computed(() => { - const val = store.settings[config.setting]; - if (settingDef.value.type == "image" && val && "file" in val && val.file) { - return URL.createObjectURL(val.file); - } else if ( - settingDef.value.type == "image" && - settingDef.value.default - ) { - return settingDef.value.default; - } else { - return val; - } + const val = store.settings[config.setting]; + if (settingDef.value.type == "image" && val && "file" in val && val.file) { + return URL.createObjectURL(val.file); + } else if (val) { + return val; + } else if (settingDef.value.type == "image" && settingDef.value.default) { + return settingDef.value.default; + } }); diff --git a/src/pretix/plugins/wallet/static/pretixplugins/wallet/helpers.ts b/src/pretix/plugins/wallet/static/pretixplugins/wallet/helpers.ts index 390e019882..5c713e421b 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/helpers.ts +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/helpers.ts @@ -1,4 +1,4 @@ -export function i18nstringLocalize(s: I18nString, locale?: string): string { +export function i18nstringLocalize(s: LocalizableString, locale?: string): string { if (typeof s === 'string') { return s } 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 24de73dcca..e2c6a2b544 100644 --- a/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts +++ b/src/pretix/plugins/wallet/static/pretixplugins/wallet/index.d.ts @@ -8,6 +8,7 @@ type Style = { identifier: string; name: string; fieldgroups: FieldGroupDefinition[]; + preview_layout: PreviewLayout[]; settings: Setting[]; }; @@ -22,14 +23,12 @@ type Variables = Record; type VariableConfig = Record; type Platforms = Platform[]; -// - type BaseFieldGroupDefinition = { - type: string; + type: FieldGroupType; identifier: string; name: string; - required: boolean; description: string; + required: boolean; }; type FieldGroupDefinition = @@ -37,6 +36,8 @@ type FieldGroupDefinition = | PredefinedFieldGroupDefinition; type FieldGroupDisplay = "plain" | "with_label" | "code"; +type FieldGroupType = "placeholder" | "predefined"; +type FieldContentType = "text" | "image"; type PlaceholderFieldGroupDefinition = BaseFieldGroupDefinition & { type: "placeholder"; @@ -52,20 +53,19 @@ type PredefinedFieldGroupDefinition = BaseFieldGroupDefinition & { type: "predefined"; }; -type I18nString = null | string | Record; +type LocalizableString = null | string | Record; -type FieldContentType = "text" | "image"; type PlaceholderFieldEntry = { type: "placeholder"; - label?: I18nString; - content?: string; + label: LocalizableString; + content: string; }; type CustomFieldEntry = { type: "custom"; - label?: I18nString; - content?: I18nString; + label?: LocalizableString; + content?: LocalizableString; }; type FieldEntry = PlaceholderFieldEntry | CustomFieldEntry; @@ -76,7 +76,7 @@ type Setting = { type: "text" | "image" | "color" | "float"; required: boolean; help_text: string; - attrs: Record + default: string }; type PlaceholderFieldGroupConfig = { @@ -97,25 +97,8 @@ type LayoutData = { settings?: Record; }; -type PlatformLayout = { - platform: string; - style: string | null; - layout: LayoutData; -}; +type PreviewLayout = {"style": Record, "rows": PreviewRow}; -type WalletLayout = { - name?: string; - platform_layouts: PlatformLayout[]; -}; -type WalletStore = { - platforms: Platforms; - variables: VariableConfig; - locales: Record; - csrfToken: String; - walletLayout: WalletLayout | null; -}; - -type PreviewLayout = Array; type PreviewRow = | { children: Array; @@ -138,7 +121,8 @@ type SettingPreview = { type PreviewFieldgroup = | PredefinedFieldgroupPreview | PlaceholderFieldGroupPreview; -type FixedPreview = { value: I18nString; label?: I18nString } & PreviewProps; + +type FixedPreview = { value: LocalizableString; label?: LocalizableString } & PreviewProps; type PlaceholderFieldGroupPreview = { fieldgroup: string; @@ -150,8 +134,8 @@ type PredefinedFieldgroupPreview = { } & PreviewProps; type PreviewSample = { - content: I18nString; - label: I18nString; + content: LocalizableString; + label: LocalizableString; }; type NewPlatformLayout = { diff --git a/src/pretix/plugins/wallet/styles/base.py b/src/pretix/plugins/wallet/styles/base.py index 7ecdb9e941..ecc24da7b2 100644 --- a/src/pretix/plugins/wallet/styles/base.py +++ b/src/pretix/plugins/wallet/styles/base.py @@ -440,9 +440,7 @@ class PassStyle: settings = {} for setting in self.settings: if isinstance(setting, ImageSettingsField): - settings[setting.identifier] = self.file_settings.get( - setting.identifier - ) + settings[setting.identifier] = self.file_settings[setting.identifier].url if setting.identifier in self.file_settings else None if not settings[setting.identifier] and setting.default: settings[setting.identifier] = setting.default else: diff --git a/src/pretix/plugins/wallet/styles/google.py b/src/pretix/plugins/wallet/styles/google.py index 3cb63a49f6..e61cd63c0d 100644 --- a/src/pretix/plugins/wallet/styles/google.py +++ b/src/pretix/plugins/wallet/styles/google.py @@ -272,7 +272,7 @@ class GoogleWalletDefaultEventTicket(GoogleWalletEventTicketStyle): "rows": [ { "children": [ - {"setting": "logo", "display": ["img-inline"]}, + {"setting": "logo", "display": ["img-circle-sm"]}, { "value": str(self.event.organizer.name), "relSize": 3, diff --git a/src/pretix/plugins/wallet/views.py b/src/pretix/plugins/wallet/views.py index 2130996dc9..b69850f43e 100644 --- a/src/pretix/plugins/wallet/views.py +++ b/src/pretix/plugins/wallet/views.py @@ -83,7 +83,7 @@ class LayoutEditorView(LayoutDetailView): "name": platform.name, "styles": { style.identifier: style(self.request.event).asdict() - for style in AVAILABLE_STYLES.get(platform.identifier) + for style in AVAILABLE_STYLES.get(platform.identifier, []) }, } for platform in AVAILABLE_PLATFORMS