bugfixing; update types

This commit is contained in:
Kara Engelhardt committed 2026-10-27 17:52:47 +01:00
1 parent 06788085e4
commit c78828dbfb
11 files changed
+45 -59

No files matched your search

@@ -8,7 +8,7 @@ defineOptions({
});
const emit = defineEmits<{change: [File]}>()
const props = defineProps<{
label?: I18nString;
label?: LocalizableString;
errors?: string[];
help_text?: string;
filename?: string;
@@ -27,5 +27,5 @@ watchEffect(() => {
<template lang="pug">
input.form-control(v-if="!!modelValue" v-for="(human_readable, locale) in store.locales" v-model="modelValue[locale]" v-bind="$attrs" :lang="locale" :title="human_readable" :placeholder="placeholders[locale] || human_readable")
.help-block(v-if="props.errors" v-for="error in props.errors") {{ error }}
.help-block(v-if="!!errors" v-for="error in errors") {{ error }}
</template>
@@ -15,7 +15,7 @@ const {
max=null,
defaultVal=null
} = defineProps<{
label?: I18nString;
label?: string;
errors?: string[];
type?: string;
help_text?: string;
@@ -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[];
@@ -5,7 +5,7 @@ import RowPreview from "./row-preview.vue";
const store = inject(StoreKey)!;
const { layout } = defineProps<{ layout: Array<PreviewLayout> }>();
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;
}
}
</style>
@@ -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;
}
});
</script>
@@ -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
}
@@ -8,6 +8,7 @@ type Style = {
identifier: string;
name: string;
fieldgroups: FieldGroupDefinition[];
preview_layout: PreviewLayout[];
settings: Setting[];
};
@@ -22,14 +23,12 @@ type Variables = Record<string, Variable>;
type VariableConfig = Record<string, Variables>;
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<string, string>;
type LocalizableString = null | string | Record<string, string>;
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<string, any>
default: string
};
type PlaceholderFieldGroupConfig = {
@@ -97,25 +97,8 @@ type LayoutData = {
settings?: Record<string, any>;
};
type PlatformLayout = {
platform: string;
style: string | null;
layout: LayoutData;
};
type PreviewLayout = {"style": Record<string, string | {settting: string}>, "rows": PreviewRow};
type WalletLayout = {
name?: string;
platform_layouts: PlatformLayout[];
};
type WalletStore = {
platforms: Platforms;
variables: VariableConfig;
locales: Record<string, string>;
csrfToken: String;
walletLayout: WalletLayout | null;
};
type PreviewLayout = Array<PreviewRow>;
type PreviewRow =
| {
children: Array<PreviewRow>;
@@ -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 = {
+1 -3
View File
@@ -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:
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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