Skip to content
Snippets Groups Projects
Verified Commit 007dd5e5 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Revert ParameterStringInput.vue to fix bug introduced by defineModel

The user could not select an object via the object select dialog,
because it would automatically switch to the advanced form input
when selecting an option from the HTML select tag

#95
parent 4d4783ec
No related branches found
No related tags found
1 merge request!92Resolve "Add help for creating clomw_info.json"
...@@ -13,6 +13,7 @@ default: ...@@ -13,6 +13,7 @@ default:
- docker - docker
before_script: before_script:
- npm --version # For debugging - npm --version # For debugging
- node --version
- npm install --no-fund - npm install --no-fund
lint: lint:
......
This diff is collapsed.
...@@ -10,8 +10,6 @@ const s3objectRepository = useS3ObjectStore(); ...@@ -10,8 +10,6 @@ const s3objectRepository = useS3ObjectStore();
const resourceRepository = useResourceStore(); const resourceRepository = useResourceStore();
const randomIDSuffix = Math.random().toString(16).substring(2, 8); const randomIDSuffix = Math.random().toString(16).substring(2, 8);
const model = defineModel<string | undefined>({ required: true });
const props = defineProps({ const props = defineProps({
parameter: { parameter: {
type: Object, type: Object,
...@@ -25,6 +23,9 @@ const props = defineProps({ ...@@ -25,6 +23,9 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
modelValue: {
type: String,
},
helpId: { helpId: {
type: String, type: String,
}, },
...@@ -38,6 +39,10 @@ const props = defineProps({ ...@@ -38,6 +39,10 @@ const props = defineProps({
}, },
}); });
const emit = defineEmits<{
(e: "update:modelValue", value?: string): void;
}>();
const s3Path = reactive<{ const s3Path = reactive<{
bucket: string; bucket: string;
key?: string; key?: string;
...@@ -56,8 +61,10 @@ const selectedResource = reactive<{ ...@@ -56,8 +61,10 @@ const selectedResource = reactive<{
const formState = reactive<{ const formState = reactive<{
advancedInput: boolean; advancedInput: boolean;
stringVal?: string;
}>({ }>({
advancedInput: false, advancedInput: false,
stringVal: undefined,
}); });
const stringInput = ref<HTMLInputElement | undefined>(undefined); const stringInput = ref<HTMLInputElement | undefined>(undefined);
...@@ -124,17 +131,22 @@ watch( ...@@ -124,17 +131,22 @@ watch(
}, },
); );
watch(() => formState.stringVal, updateValue);
watch(selectedResource, () => { watch(selectedResource, () => {
if (clowmResource.value && !formState.advancedInput) { if (clowmResource.value && !formState.advancedInput) {
updateStringFromResource(); updateStringFromResource();
} }
}); });
watch(model, (newVal, oldVal) => { watch(
if (newVal && newVal !== oldVal) { () => props.modelValue,
formState.advancedInput = true; (newVal) => {
} if (formState.stringVal != newVal) {
}); formState.stringVal = newVal;
formState.advancedInput = true;
}
},
);
watch( watch(
() => formState.advancedInput, () => formState.advancedInput,
...@@ -149,14 +161,18 @@ watch( ...@@ -149,14 +161,18 @@ watch(
}, },
); );
function updateValue() {
emit("update:modelValue", formState.stringVal);
}
function updateStringFromS3() { function updateStringFromS3() {
model.value = !s3Path.bucket formState.stringVal = !s3Path.bucket
? undefined ? undefined
: `s3://${s3Path.bucket}${s3Path.key ? "/" + s3Path.key : ""}`; : `s3://${s3Path.bucket}${s3Path.key ? "/" + s3Path.key : ""}`;
} }
function updateStringFromResource() { function updateStringFromResource() {
model.value = formState.stringVal =
resourceRepository.resourceMapping[selectedResource.resourceId]?.versions[ resourceRepository.resourceMapping[selectedResource.resourceId]?.versions[
selectedResource.resourceVersionIndex selectedResource.resourceVersionIndex
]?.cluster_path ?? undefined; ]?.cluster_path ?? undefined;
...@@ -172,7 +188,8 @@ function updateKeysInBucket(bucketName?: string) { ...@@ -172,7 +188,8 @@ function updateKeysInBucket(bucketName?: string) {
} }
onMounted(() => { onMounted(() => {
if (model.value) { formState.stringVal = props.modelValue;
if (formState.stringVal) {
formState.advancedInput = true; formState.advancedInput = true;
} }
}); });
...@@ -248,7 +265,7 @@ onMounted(() => { ...@@ -248,7 +265,7 @@ onMounted(() => {
class="form-control border border-secondary" class="form-control border border-secondary"
:class="{ 'rounded-end': props.removeAdvanced && !helpTextPresent }" :class="{ 'rounded-end': props.removeAdvanced && !helpTextPresent }"
type="text" type="text"
v-model="model" v-model="formState.stringVal"
:required="props.required" :required="props.required"
:aria-describedby="props.helpId" :aria-describedby="props.helpId"
:pattern="pattern" :pattern="pattern"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment