align number field

This commit is contained in:
Pete Matsyburka
2024-03-17 19:06:00 +02:00
parent f6691c110e
commit 95899336b8
6 changed files with 64 additions and 7 deletions
+9
View File
@@ -157,6 +157,7 @@
ref="textContainer"
dir="auto"
class="flex items-center px-0.5 w-full"
:class="alignClasses[field.preferences?.align]"
>
<span v-if="Array.isArray(modelValue)">
{{ modelValue.join(', ') }}
@@ -167,6 +168,7 @@
<span
v-else
class="whitespace-pre-wrap"
:class="{ 'w-full': field.preferences?.align }"
>{{ modelValue }}</span>
</div>
</div>
@@ -253,6 +255,13 @@ export default {
phone: this.t('phone')
}
},
alignClasses () {
return {
center: 'text-center',
left: 'text-left',
right: 'text-right'
}
},
option () {
return this.field.options.find((o) => o.uuid === this.area.option_uuid)
},
+8 -1
View File
@@ -99,7 +99,7 @@
<div
class="flex items-center h-full w-full"
dir="auto"
:class="[bgColors[submitterIndex], field?.default_value ? '' : 'justify-center']"
:class="[bgColors[submitterIndex], field?.default_value ? (alignClasses[field.preferences?.align] || '') : 'justify-center']"
>
<span
v-if="field"
@@ -211,6 +211,13 @@ export default {
defaultName () {
return this.buildDefaultName(this.field, this.template.fields)
},
alignClasses () {
return {
center: 'justify-center',
left: 'justify-start',
right: 'justify-end'
}
},
optionIndexText () {
if (this.area.option_uuid && this.field.options) {
return `${this.field.options.findIndex((o) => o.uuid === this.area.option_uuid) + 1}.`
+26
View File
@@ -115,6 +115,32 @@
@dragstart.prevent.stop
@click="closeDropdown"
>
<div
v-if="['number'].includes(field.type)"
class="py-1.5 px-1 relative"
@click.stop
>
<select
class="select select-bordered select-xs w-full max-w-xs h-7 !outline-0 font-normal"
@change="[field.preferences ||= {}, field.preferences.align = $event.target.value, save()]"
>
<option
v-for="value in ['left', 'right', 'center']"
:key="value"
:selected="field.preferences?.align ? value === field.preferences.align : value === 'left'"
:value="value"
>
{{ t(value) }}
</option>
</select>
<label
:style="{ backgroundColor: backgroundColor }"
class="absolute -top-1 left-2.5 px-1 h-4"
style="font-size: 8px"
>
{{ t('align') }}
</label>
</div>
<div
v-if="['text', 'number'].includes(field.type) && !defaultField"
class="py-1.5 px-1 relative"
+4
View File
@@ -1,4 +1,8 @@
const en = {
align: 'Align',
left: 'Left',
right: 'Right',
center: 'Center',
description: 'Description',
display_title: 'Display title',
with_logo: 'With logo',