Update NotificationSettingForm.vue
This commit is contained in:
@@ -238,7 +238,9 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['save', 'cancel']);
|
const emit = defineEmits(['save', 'cancel']);
|
||||||
|
|
||||||
const store = useNotificationsStore();
|
const store = useNotificationsStore();
|
||||||
|
console.log('[NotificationSettingForm] Setup started.'); // Log setup start
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
console.log('[NotificationSettingForm] useI18n initialized.'); // Log i18n init
|
||||||
const formError = ref<string | null>(null);
|
const formError = ref<string | null>(null);
|
||||||
const headerError = ref<string | null>(null);
|
const headerError = ref<string | null>(null);
|
||||||
const testError = ref<string | null>(null);
|
const testError = ref<string | null>(null);
|
||||||
@@ -309,6 +311,7 @@ const webhookHeadersString = ref('{}'); // For textarea binding
|
|||||||
|
|
||||||
// Watch for initialData changes (when editing)
|
// Watch for initialData changes (when editing)
|
||||||
watch(() => props.initialData, (newData) => {
|
watch(() => props.initialData, (newData) => {
|
||||||
|
console.log('[NotificationSettingForm] Watch initialData triggered. New data:', newData); // Log initialData change
|
||||||
if (newData) {
|
if (newData) {
|
||||||
Object.assign(formData, newData);
|
Object.assign(formData, newData);
|
||||||
// Populate specific config refs based on channel type
|
// Populate specific config refs based on channel type
|
||||||
@@ -346,10 +349,12 @@ watch(() => props.initialData, (newData) => {
|
|||||||
testError.value = null; // Reset test error
|
testError.value = null; // Reset test error
|
||||||
testResult.value = null; // Reset test result
|
testResult.value = null; // Reset test result
|
||||||
testingNotification.value = false; // Reset testing state
|
testingNotification.value = false; // Reset testing state
|
||||||
|
console.log('[NotificationSettingForm] Form data initialized/updated from initialData. Current channel_type:', formData.channel_type); // Log after init/update
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
// Watch channel type change to reset specific config
|
// Watch channel type change to reset specific config
|
||||||
watch(() => formData.channel_type, (newType, oldType) => {
|
watch(() => formData.channel_type, (newType, oldType) => {
|
||||||
|
console.log(`[NotificationSettingForm] Watch channel_type changed from ${oldType} to ${newType}`); // Log channel type change
|
||||||
if (newType !== oldType && !isEditing.value) { // Only reset if not editing or type changes during add mode
|
if (newType !== oldType && !isEditing.value) { // Only reset if not editing or type changes during add mode
|
||||||
webhookConfig.value = { url: '', method: 'POST', headers: {}, bodyTemplate: '' };
|
webhookConfig.value = { url: '', method: 'POST', headers: {}, bodyTemplate: '' };
|
||||||
emailConfig.value = {
|
emailConfig.value = {
|
||||||
@@ -393,6 +398,7 @@ watch(emailConfig, () => {
|
|||||||
const getEventDisplayName = (event: NotificationEvent): string => {
|
const getEventDisplayName = (event: NotificationEvent): string => {
|
||||||
// Use i18n key, fallback to formatted name if key not found
|
// Use i18n key, fallback to formatted name if key not found
|
||||||
const i18nKey = `settings.notifications.events.${event}`;
|
const i18nKey = `settings.notifications.events.${event}`;
|
||||||
|
console.log(`[NotificationSettingForm] Translating event display name for key: ${i18nKey}`); // Log event key translation attempt
|
||||||
const translated = t(i18nKey);
|
const translated = t(i18nKey);
|
||||||
// If translation returns the key itself, it means translation is missing
|
// If translation returns the key itself, it means translation is missing
|
||||||
if (translated === i18nKey) {
|
if (translated === i18nKey) {
|
||||||
@@ -403,6 +409,7 @@ const getEventDisplayName = (event: NotificationEvent): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
console.log('[NotificationSettingForm] handleSubmit called.'); // Log submit start
|
||||||
formError.value = null;
|
formError.value = null;
|
||||||
if (headerError.value) return; // Don't submit if headers are invalid
|
if (headerError.value) return; // Don't submit if headers are invalid
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user