mirror of
https://github.com/pretix/pretix.git
synced 2026-06-12 01:35:16 +00:00
use placeholder name as label default
This commit is contained in:
@@ -92,7 +92,7 @@ class CustomFieldEntry(FieldEntry[LazyI18nString]):
|
|||||||
|
|
||||||
class PredefinedFieldGroup(FieldGroup):
|
class PredefinedFieldGroup(FieldGroup):
|
||||||
type = FieldGroupType.PREDEFINED
|
type = FieldGroupType.PREDEFINED
|
||||||
|
|
||||||
def layout_schema(
|
def layout_schema(
|
||||||
self,
|
self,
|
||||||
remaining_fields: list["FieldGroup"],
|
remaining_fields: list["FieldGroup"],
|
||||||
@@ -101,7 +101,7 @@ class PredefinedFieldGroup(FieldGroup):
|
|||||||
return {
|
return {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlaceholderFieldGroup(FieldGroup):
|
class PlaceholderFieldGroup(FieldGroup):
|
||||||
type = FieldGroupType.PLACEHOLDER
|
type = FieldGroupType.PLACEHOLDER
|
||||||
content_type: FieldContentType
|
content_type: FieldContentType
|
||||||
@@ -275,7 +275,7 @@ class PassStyle:
|
|||||||
|
|
||||||
def generate(self, layout, context):
|
def generate(self, layout, context):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def render_placeholder(self, context, content_type, content):
|
def render_placeholder(self, context, content_type, content):
|
||||||
placeholder = (
|
placeholder = (
|
||||||
context.get("placeholders")
|
context.get("placeholders")
|
||||||
@@ -287,7 +287,10 @@ class PassStyle:
|
|||||||
*context.get("evaluation_context", [])
|
*context.get("evaluation_context", [])
|
||||||
)
|
)
|
||||||
if placeholder_value:
|
if placeholder_value:
|
||||||
return placeholder_value
|
return placeholder["label"], placeholder_value
|
||||||
|
|
||||||
|
return None, None
|
||||||
|
|
||||||
def get_pass_fields(self, layout, context):
|
def get_pass_fields(self, layout, context):
|
||||||
fields = {}
|
fields = {}
|
||||||
for group in self.fieldgroups:
|
for group in self.fieldgroups:
|
||||||
@@ -301,7 +304,10 @@ class PassStyle:
|
|||||||
if group.labels:
|
if group.labels:
|
||||||
field_entry["label"] = LazyI18nString(field["label"])
|
field_entry["label"] = LazyI18nString(field["label"])
|
||||||
if field["type"] == FieldEntryType.PLACEHOLDER.value:
|
if field["type"] == FieldEntryType.PLACEHOLDER.value:
|
||||||
field_entry["value"] = self.render_placeholder(context, group.content_type.value, field['content'])
|
label, field_entry["value"] = self.render_placeholder(context, group.content_type.value, field['content'])
|
||||||
|
if group.labels and not str(field_entry['label']) and label:
|
||||||
|
field_entry['label'] = LazyI18nString(label)
|
||||||
|
|
||||||
elif field["type"] == FieldEntryType.CUSTOM.value:
|
elif field["type"] == FieldEntryType.CUSTOM.value:
|
||||||
field_entry["value"] = LazyI18nString(field["content"])
|
field_entry["value"] = LazyI18nString(field["content"])
|
||||||
if "value" in field_entry and field_entry["value"]:
|
if "value" in field_entry and field_entry["value"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user