Skip to content

Commit

Permalink
Default to displaying form in ToggleJson.vue
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Jaeger-Freeborn <[email protected]>
  • Loading branch information
Gavinok committed Apr 8, 2024
1 parent ea0d06f commit cd5ac72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions services/tenant-ui/frontend/src/components/common/ToggleJson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<div class="mt-2">
<div class="flex justify-content-end">
{{ $t('common.json') }}
<InputSwitch v-model="showRawJson" class="ml-1" @input="toggleJson" />
<InputSwitch v-model="displayAsForm" class="ml-1" @input="toggleJson" />
</div>
<div v-show="!showRawJson">
<div v-show="displayAsForm">
<slot></slot>
</div>
<div v-show="showRawJson">
<div v-show="!displayAsForm">
<Textarea
id="credentialValuesEdit"
v-model="valuesJson"
Expand All @@ -27,7 +27,7 @@ import { ref } from 'vue';
import InputSwitch from 'primevue/inputswitch';
import Textarea from 'primevue/textarea';
const showRawJson = ref<boolean>(false);
const displayAsForm = ref<boolean>(true);
const valuesJson = ref<string>('');
// Undefined indicates that the conversion was a failure
Expand All @@ -39,21 +39,21 @@ const props = defineProps<{
}>();
defineExpose({
showRawJson,
displayAsForm,
valuesJson,
});
const toggleJson = () => {
if (showRawJson.value) {
if (displayAsForm.value) {
const res = props.toJson();
if (res) {
valuesJson.value = res;
} else {
showRawJson.value = !showRawJson.value;
displayAsForm.value = !displayAsForm.value;
}
} else {
if (!props.fromJson(valuesJson.value)) {
showRawJson.value = !showRawJson.value;
displayAsForm.value = !displayAsForm.value;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function jsonToCredentialValue(
credentialValuesRaw.value = parsed;
return parsed;
} else {
toast.warning('The JSON you inputted has invalid syntax');
toast.warning('This JSON is invalid syntax');
return undefined;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function jsonToSchema(jsonString: string): SchemaSendRequest | undefined {
formFields.version = parsed.schema_version;
return parsed;
} else {
toast.error('The JSON you inputted has invalid syntax');
toast.error('Invalid JSON detected');
return undefined;
}
}
Expand Down

0 comments on commit cd5ac72

Please sign in to comment.