mirror of
https://github.com/pretix/pretix.git
synced 2026-11-11 01:27:08 +00:00
show max_entries in overflow help text
This commit is contained in:
1 parent
f1c1fc90fa
commit
b03ae035ed
3 files changed
+22
-6
No files matched your search
@@ -9,7 +9,8 @@ const props = defineProps<{
|
||||
label?: string
|
||||
choices: Array<[string, string]>
|
||||
errors?: string[],
|
||||
class?: string
|
||||
class?: string,
|
||||
help_text?: string
|
||||
}>()
|
||||
const modelValue = defineModel<string|null>();
|
||||
const id = useId()
|
||||
@@ -28,5 +29,6 @@ watchEffect(() => {
|
||||
label.control-label(v-if="props.label" :for="id") {{ props.label }}
|
||||
select.form-control(:id="id" v-model="modelValue" v-bind="$attrs" required)
|
||||
option(v-for="choice in props.choices" :key="choice[0]" :value="choice[0]") {{ choice[1] }}
|
||||
.help-block(v-if="props.help_text") {{ help_text }}
|
||||
.help-block(v-if="props.errors" v-for="error in props.errors") {{ error }}
|
||||
</template>
|
||||
+17
-3
@@ -9,6 +9,8 @@ import { StoreKey } from "../walletStore";
|
||||
const store = inject(StoreKey)!;
|
||||
|
||||
const gettext = (window as any).gettext;
|
||||
const ngettext = (window as any).ngettext;
|
||||
const interpolate = (window as any).interpolate;
|
||||
|
||||
const props = defineProps<{
|
||||
fieldgroup: PlaceholderFieldGroupDefinition;
|
||||
@@ -60,6 +62,18 @@ const placeholderChoices = computed(() => {
|
||||
choices.push(["other", gettext("Other…")]);
|
||||
return choices;
|
||||
});
|
||||
|
||||
const overflowText = computed(() => {
|
||||
if (!props.fieldgroup.max_entries) {
|
||||
return ""
|
||||
}
|
||||
const formats = ngettext(
|
||||
'Maximum one field in this fieldgroup can be shown on the pass. The remaining fields will be shown in the selected fieldgroup.',
|
||||
'Maximum %s fields in this fieldgroup can be shown on the pass. The remaining fields will be shown in the selected fieldgroup.',
|
||||
props.fieldgroup.max_entries
|
||||
);
|
||||
return interpolate(formats, [props.fieldgroup.max_entries])
|
||||
})
|
||||
</script>
|
||||
|
||||
<template lang="pug">
|
||||
@@ -67,9 +81,9 @@ const placeholderChoices = computed(() => {
|
||||
.panel-heading
|
||||
h3.panel-title {{ fieldgroup.name }}
|
||||
.panel-body(v-if="fieldConfig")
|
||||
span.text-muted(v-if="fieldgroup.description") {{ fieldgroup.description }}
|
||||
h4 {{ gettext("Content") }}
|
||||
.form-group()
|
||||
span.text-muted(v-if="fieldgroup.description") {{ fieldgroup.description }}
|
||||
h4 {{ gettext("Content") }}
|
||||
table.table.table-hover
|
||||
thead
|
||||
tr
|
||||
@@ -97,5 +111,5 @@ const placeholderChoices = computed(() => {
|
||||
button.btn.btn-default(type="button" @click="addVariable")
|
||||
i.fa.fa-plus
|
||||
| {{ gettext("Add field") }}
|
||||
Select(:label="gettext('Overflow to …')" :choices="overflowOptions" v-model="fieldConfig.overflow")
|
||||
Select(:label="gettext('Overflow to …')" :choices="overflowOptions" v-model="fieldConfig.overflow" :help_text="overflowText")
|
||||
</template>
|
||||
@@ -22,8 +22,8 @@ function pgettext (context, msgid) {
|
||||
|
||||
function interpolate (fmt, object, named) {
|
||||
if (named) {
|
||||
return fmt.replace(/%\(\w+\)s/g, function (match) { return String(obj[match.slice(2, -2)]) })
|
||||
return fmt.replace(/%\(\w+\)s/g, function (match) { return String(object[match.slice(2, -2)]) })
|
||||
} else {
|
||||
return fmt.replace(/%s/g, function (match) { return String(obj.shift()) })
|
||||
return fmt.replace(/%s/g, function (match) { return String(object.shift()) })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user