|
20 | 20 | :key="column.name" |
21 | 21 | v-if="currentValues !== null" |
22 | 22 | class="bg-ligftForm dark:bg-gray-800 dark:border-gray-700 block md:table-row" |
23 | | - :class="{ 'border-b': i !== group.columns.length - 1, 'opacity-50 pointer-events-none': column.editReadonly && source === 'edit'}" |
| 23 | + :class="{ 'border-b': i !== group.columns.length - 1}" |
24 | 24 | > |
25 | 25 | <td class="px-6 py-4 flex items-center block md:table-cell pb-0 md:pb-4" |
26 | 26 | :class="{'rounded-bl-lg border-b-none': i === group.columns.length - 1}"> <!--align-top--> |
|
59 | 59 | :options="columnOptions[column.name] || []" |
60 | 60 | :placeholder = "columnOptions[column.name]?.length ?$t('Select...'): $t('There are no options available')" |
61 | 61 | :modelValue="currentValues[column.name]" |
| 62 | + :isReadonly="column.editReadonly && source === 'edit'" |
62 | 63 | @update:modelValue="setCurrentValue(column.name, $event)" |
63 | 64 | ></Select> |
64 | 65 | <Select |
65 | 66 | class="w-full" |
66 | 67 | v-else-if="column.enum" |
67 | 68 | :options="column.enum" |
68 | 69 | :modelValue="currentValues[column.name]" |
| 70 | + :isReadonly="column.editReadonly && source === 'edit'" |
69 | 71 | @update:modelValue="setCurrentValue(column.name, $event)" |
70 | 72 | ></Select> |
71 | 73 | <Select |
72 | 74 | class="w-full" |
73 | 75 | v-else-if="column.type === 'boolean'" |
74 | 76 | :options="getBooleanOptions(column)" |
75 | 77 | :modelValue="currentValues[column.name]" |
| 78 | + :isReadonly="column.editReadonly && source === 'edit'" |
76 | 79 | @update:modelValue="setCurrentValue(column.name, $event)" |
77 | 80 | ></Select> |
78 | 81 | <input |
|
81 | 84 | step="1" |
82 | 85 | class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-40 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" |
83 | 86 | placeholder="0" |
| 87 | + :isReadonly="column.editReadonly && source === 'edit'" |
84 | 88 | :value="currentValues[column.name]" |
85 | 89 | @input="setCurrentValue(column.name, $event.target.value)" |
86 | 90 | > |
|
90 | 94 | :valueStart="currentValues[column.name]" |
91 | 95 | auto-hide |
92 | 96 | @update:valueStart="setCurrentValue(column.name, $event)" |
| 97 | + :isReadonly="column.editReadonly && source === 'edit'" |
93 | 98 | /> |
94 | 99 | <input |
95 | 100 | v-else-if="['decimal', 'float'].includes(column.type)" |
|
99 | 104 | placeholder="0.0" |
100 | 105 | :value="currentValues[column.name]" |
101 | 106 | @input="setCurrentValue(column.name, $event.target.value)" |
| 107 | + :readonly="column.editReadonly && source === 'edit'" |
102 | 108 | /> |
103 | 109 | <textarea |
104 | 110 | v-else-if="['text', 'richtext'].includes(column.type)" |
105 | 111 | class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" |
106 | 112 | :placeholder="$t('Text')" |
107 | 113 | :value="currentValues[column.name]" |
108 | 114 | @input="setCurrentValue(column.name, $event.target.value)" |
| 115 | + :readonly="column.editReadonly && source === 'edit'" |
109 | 116 | > |
110 | 117 | </textarea> |
111 | 118 | <textarea |
|
126 | 133 | autocomplete="false" |
127 | 134 | data-lpignore="true" |
128 | 135 | readonly |
129 | | - onfocus="this.removeAttribute('readonly');" |
| 136 | + ref="readonlyInputs" |
| 137 | + @focus="onFocusHandler($event, column, source)" |
130 | 138 | > |
131 | 139 |
|
132 | 140 | <button |
|
171 | 179 | columnOptions: any, |
172 | 180 | }>(); |
173 | 181 |
|
| 182 | + const customComponentsInValidity: Ref<Record<string, boolean>> = ref({}); |
| 183 | + const customComponentsEmptiness: Ref<Record<string, boolean>> = ref({}); |
| 184 | +
|
174 | 185 | const getBooleanOptions = (column: any) => { |
175 | 186 | const options: Array<{ label: string; value: boolean | null }> = [ |
176 | 187 | { label: t('Yes'), value: true }, |
|
181 | 192 | } |
182 | 193 | return options; |
183 | 194 | }; |
| 195 | + function onFocusHandler(event:FocusEvent, column:any, source:string, ) { |
| 196 | + const focusedInput = event.target as HTMLInputElement; |
| 197 | + if(!focusedInput) return; |
| 198 | + if (column.editReadonly && source === 'edit') return; |
| 199 | + else { |
| 200 | + focusedInput.removeAttribute('readonly'); |
| 201 | + } |
| 202 | + } |
| 203 | +
|
184 | 204 |
|
185 | 205 | const emit = defineEmits(['update:customComponentsInValidity', 'update:customComponentsEmptiness']); |
186 | 206 |
|
187 | 207 |
|
188 | | - const customComponentsInValidity: Ref<Record<string, boolean>> = ref({}); |
189 | | - const customComponentsEmptiness: Ref<Record<string, boolean>> = ref({}); |
| 208 | +
|
190 | 209 |
|
191 | 210 | watch(customComponentsInValidity, (newVal) => { |
192 | 211 | emit('update:customComponentsInValidity', newVal); |
|
0 commit comments