-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-email-contact-to-tenants
- Loading branch information
Showing
11 changed files
with
274 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
services/tenant-ui/frontend/src/components/common/ToggleJson.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div class="mt-2"> | ||
<div class="flex justify-content-end"> | ||
{{ $t('common.json') }} | ||
<InputSwitch v-model="showRawJson" class="ml-1" @input="toggleJson" /> | ||
</div> | ||
<div v-show="!showRawJson"> | ||
<slot></slot> | ||
</div> | ||
<div v-show="showRawJson"> | ||
<Textarea | ||
id="credentialValuesEdit" | ||
v-model="valuesJson" | ||
:auto-resize="true" | ||
rows="20" | ||
cols="60" | ||
class="w-full mt-1" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts" generic="T"> | ||
// Libraries | ||
import { ref, defineExpose } from 'vue'; | ||
// Source | ||
import InputSwitch from 'primevue/inputswitch'; | ||
import Textarea from 'primevue/textarea'; | ||
const showRawJson = ref<boolean>(false); | ||
const valuesJson = ref<string>(''); | ||
// Undefined indicates that the conversion was a failure | ||
// note that indication of the error should be handled in the | ||
// toJson and fromJson using libraries like vue-toastification | ||
const props = defineProps<{ | ||
toJson: () => string | undefined; | ||
fromJson: (jsonRepresentation: string) => T | undefined; | ||
}>(); | ||
defineExpose({ | ||
showRawJson, | ||
valuesJson, | ||
}); | ||
const toggleJson = () => { | ||
if (showRawJson.value) { | ||
const res = props.toJson(); | ||
if (res) { | ||
valuesJson.value = res; | ||
} else { | ||
showRawJson.value = !showRawJson.value; | ||
} | ||
} else { | ||
if (!props.fromJson(valuesJson.value)) { | ||
showRawJson.value = !showRawJson.value; | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.