|
79 | 79 | <q-btn-toggle |
80 | 80 | v-model="jdbcOrJndi.type" |
81 | 81 | toggle-color="primary" |
| 82 | + @update:model-value="clearType" |
82 | 83 | :options="[ |
83 | 84 | { label: 'JDBC', value: 'JDBC', disabled: readOnly, title: $t('managers.dataSourceManagement.form.jdbcInfo') }, |
84 | 85 | { label: 'JNDI', value: 'JNDI', disabled: readOnly || !currentUser.isSuperadmin, title: $t('managers.dataSourceManagement.form.jndiInfo') } |
|
103 | 104 | </template> |
104 | 105 | </q-input> |
105 | 106 | </div> |
| 107 | + <div v-if="jdbcOrJndi.type == 'JNDI'" class="row q-mt-sm q-col-gutter-sm"> |
| 108 | + <div class="col-12"> |
| 109 | + <q-checkbox |
| 110 | + v-model="datasource.multiSchema" |
| 111 | + size="sm" |
| 112 | + :disable="readOnly" |
| 113 | + :label="$t('managers.dataSourceManagement.form.multischema')" |
| 114 | + @update:model-value="onFieldChange" |
| 115 | + data-test="multischema-checkbox" |
| 116 | + /> |
| 117 | + </div> |
| 118 | + <div v-if="datasource.multiSchema" class="col-12"> |
| 119 | + <q-input |
| 120 | + filled |
| 121 | + dense |
| 122 | + v-model="v$.datasource.schemaAttribute.$model" |
| 123 | + maxlength="45" |
| 124 | + :disable="readOnly" |
| 125 | + :error="v$.datasource.schemaAttribute.$invalid && v$.datasource.schemaAttribute.$dirty" |
| 126 | + :label="$t('managers.dataSourceManagement.form.schemaAttribute')" |
| 127 | + @update:model-value="onFieldChange" |
| 128 | + data-test="schema-attribute-input" |
| 129 | + /> |
| 130 | + <KnValidationMessages :v-comp="v$.datasource.schemaAttribute" :additional-translate-params="{ fieldName: $t('managers.dataSourceManagement.form.schemaAttribute') }" /> |
| 131 | + </div> |
| 132 | + </div> |
106 | 133 | <div v-if="jdbcOrJndi.type == 'JDBC'" class="row q-mt-md q-col-gutter-sm"> |
107 | 134 | <q-input |
108 | 135 | filled |
|
155 | 182 | /* eslint-disable no-prototype-builtins */ |
156 | 183 | import { defineComponent } from 'vue' |
157 | 184 | import { createValidations, ICustomValidatorMap } from '@/helpers/commons/validationHelper' |
| 185 | +import { extendedAlphanumeric } from '@/helpers/commons/regexHelper' |
158 | 186 | import { AxiosResponse } from 'axios' |
159 | 187 | import useValidate from '@vuelidate/core' |
160 | 188 | import dataSourceDescriptor from '../DataSourceDescriptor.json' |
@@ -274,10 +302,14 @@ export default defineComponent({ |
274 | 302 | const jndiTypeFormat = (value) => { |
275 | 303 | return this.jdbcOrJndi.type != 'JNDI' || value.match(/java:comp\/env\/jdbc\/[A-Za-z\d\-_|#$]+/g) |
276 | 304 | } |
| 305 | + const schemaAttributeRegex = (value) => { |
| 306 | + return this.jdbcOrJndi.type != 'JNDI' || !this.datasource.multiSchema || extendedAlphanumeric.test(value ?? '') |
| 307 | + } |
277 | 308 | const customValidators: ICustomValidatorMap = { |
278 | 309 | 'jndi-name-required': jndiTypeRequired('JNDI'), |
279 | 310 | 'jdbc-data-required': jndiTypeRequired('JDBC'), |
280 | | - 'jndi-format': jndiTypeFormat |
| 311 | + 'jndi-format': jndiTypeFormat, |
| 312 | + 'schema-attribute-regex': schemaAttributeRegex |
281 | 313 | } |
282 | 314 | const validationObject = { |
283 | 315 | datasource: createValidations('datasource', dataSourceDetailValidationDescriptor.validations.datasource, customValidators) |
@@ -370,6 +402,7 @@ export default defineComponent({ |
370 | 402 | } |
371 | 403 | } |
372 | 404 | } |
| 405 | + this.onFieldChange() |
373 | 406 | }, |
374 | 407 |
|
375 | 408 | checkIfReadOnly() { |
|
0 commit comments