Add :maxlength property to EditableField component

This commit is contained in:
Johannes Zellner
2025-12-01 11:50:19 +01:00
parent 5160f22d91
commit 03a13df47b

View File

@@ -14,6 +14,7 @@ const props = defineProps({
multiline: { type: Boolean, default: false },
markdown: { type: Boolean, default: false },
rows: { type: Number, default: 2 },
maxlength: { type: Number, default: -1 },
});
const emit = defineEmits(['save']);
@@ -56,8 +57,8 @@ function cancel() {
<FormGroup>
<label>{{ label }} <sup v-if="helpUrl"><a :href="helpUrl" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
<div v-if="editing" style="display: flex; align-items: center; gap: 6px">
<TextInput v-if="!multiline" ref="textInput" v-model="draftValue" @keydown.enter="save()" :disabled="saving" :required="required ? true : null"/>
<textarea v-else ref="textInput" :rows="rows" cols="80" v-model="draftValue" :disabled="saving" :required="required ? true : null"></textarea>
<TextInput v-if="!multiline" ref="textInput" v-model="draftValue" @keydown.enter="save()" :disabled="saving" :required="required ? true : null" :maxlength="maxlength === -1 ? null : maxlength"/>
<textarea v-else ref="textInput" :rows="rows" cols="80" v-model="draftValue" :disabled="saving" :required="required ? true : null" :maxlength="maxlength === -1 ? null : maxlength"></textarea>
<Button tool @click="save" :disabled="saving || (required && !draftValue)">{{ $t('main.dialog.save') }}</Button>
<Button tool plain secondary @click="cancel" :disabled="saving">{{ $t('main.dialog.cancel') }}</Button>
</div>