211211 @input =" updateWrittenSignature"
212212 >
213213 <select
214- v-if =" requireSigningReason && !isOtherReason"
214+ v-if =" withSigningReason && !isOtherReason"
215215 class =" select base-input !text-2xl w-full mt-6 text-center"
216216 :class =" { 'text-gray-300': !reason }"
217217 required
226226 >
227227 {{ t('select_a_reason') }}
228228 </option >
229- <option
230- v-for =" (label, option) in defaultReasons"
231- :key =" option"
232- :value =" option"
233- :selected =" reason === option"
234- class =" text-base-content"
235- >
236- {{ label }}
237- </option >
238- <option
239- value =" other"
240- class =" text-base-content"
241- >
242- {{ t('other') }}
243- </option >
229+ <template v-if =" field .preferences ?.reasons " >
230+ <option
231+ v-for =" option in field.preferences.reasons"
232+ :key =" option"
233+ :value =" option"
234+ :selected =" reason === option"
235+ class =" text-base-content"
236+ >
237+ {{ option }}
238+ </option >
239+ </template >
240+ <template v-else >
241+ <option
242+ v-for =" (label, option) in defaultReasons"
243+ :key =" option"
244+ :value =" option"
245+ :selected =" reason === option"
246+ class =" text-base-content"
247+ >
248+ {{ label }}
249+ </option >
250+ <option
251+ value =" other"
252+ class =" text-base-content"
253+ >
254+ {{ t('other') }}
255+ </option >
256+ </template >
244257 </select >
245258 <input
246- v-if =" requireSigningReason && isOtherReason"
259+ v-if =" withSigningReason && isOtherReason"
247260 class =" base-input !text-2xl w-full mt-6"
248261 required
249262 :name =" `values[${field.preferences.reason_field_uuid}]`"
253266 @input =" $emit('update:reason', $event.target.value)"
254267 >
255268 <input
256- v-if =" requireSigningReason "
269+ v-if =" withSigningReason "
257270 hidden
258271 name =" with_reason"
259272 :value =" field.preferences.reason_field_uuid"
@@ -406,6 +419,9 @@ export default {
406419 format () {
407420 return this .field .preferences ? .format
408421 },
422+ withSigningReason () {
423+ return this .requireSigningReason || this .field .preferences ? .reasons ? .length
424+ },
409425 defaultReasons () {
410426 return {
411427 [this .t (' approved_by' )]: this .t (' approved' ),
@@ -424,10 +440,11 @@ export default {
424440 created () {
425441 this .isSignatureStarted = !! this .computedPreviousValue
426442
427- if (this .requireSigningReason ) {
443+ if (this .withSigningReason ) {
428444 this .field .preferences || = {}
429445 this .field .preferences .reason_field_uuid || = v4 ()
430- this .isOtherReason = this .reason && ! this .defaultReasons [this .reason ]
446+ this .isOtherReason = this .reason && ! this .defaultReasons [this .reason ] &&
447+ (! this .field .preferences ? .reasons ? .length || ! this .field .preferences .reasons .includes (this .reason ))
431448 }
432449 },
433450 async mounted () {
0 commit comments