Use named slot translation when has multi-slot

pull/451/head
zsxeee 3 years ago
parent 138ddf5608
commit 0f2059cde0
No known key found for this signature in database
GPG Key ID: 895CFFFD8313B3B8

@ -68,11 +68,11 @@
</template>
<script lang="ts">
import { Modal } from "bootstrap"
import { ucfirst } from "../util.ts"
import { Modal } from "bootstrap";
import { ucfirst } from "../util.ts";
import Confirm from "./Confirm.vue";
import NotificationFormList from "./notifications"
import NotificationFormList from "./notifications";
export default {
components: {
@ -93,15 +93,15 @@ export default {
isDefault: false,
// Do not set default value here, please scroll to show()
}
}
};
},
computed: {
currentForm() {
if (!this.notification.type) {
return null
return null;
}
return NotificationFormList[this.notification.type]
return NotificationFormList[this.notification.type];
}
},
@ -120,13 +120,13 @@ export default {
},
},
mounted() {
this.modal = new Modal(this.$refs.modal)
this.modal = new Modal(this.$refs.modal);
},
methods: {
deleteConfirm() {
this.modal.hide();
this.$refs.confirmDelete.show()
this.$refs.confirmDelete.show();
},
show(notificationID) {
@ -145,19 +145,19 @@ export default {
name: "",
type: null,
isDefault: false,
}
};
// Set Default value here
this.notification.type = this.notificationTypes[0];
}
this.modal.show()
this.modal.show();
},
submit() {
this.processing = true;
this.$root.getSocket().emit("addNotification", this.notification, this.id, (res) => {
this.$root.toastRes(res)
this.$root.toastRes(res);
this.processing = false;
if (res.ok) {
@ -169,45 +169,45 @@ export default {
}
}
})
});
},
test() {
this.processing = true;
this.$root.getSocket().emit("testNotification", this.notification, (res) => {
this.$root.toastRes(res)
this.$root.toastRes(res);
this.processing = false;
})
});
},
deleteNotification() {
this.processing = true;
this.$root.getSocket().emit("deleteNotification", this.id, (res) => {
this.$root.toastRes(res)
this.$root.toastRes(res);
this.processing = false;
if (res.ok) {
this.modal.hide()
this.modal.hide();
}
})
});
},
/**
* @param {keyof NotificationFormList} notificationKey
* @return {string}
*/
getUniqueDefaultName(notificationKey) {
let index = 1
let name = ""
let index = 1;
let name = "";
do {
name = this.$t("defaultNotificationName", [
this.$t(notificationKey).replace(/\(.+\)/, "").trim(),
index++
]);
} while (this.$root.notificationList.find(it => it.name === name))
return name
name = this.$t("defaultNotificationName", {
notification: this.$t(notificationKey).replace(/\(.+\)/, "").trim(),
number: index++
});
} while (this.$root.notificationList.find(it => it.name === name));
return name;
}
},
}
};
</script>
<style lang="scss" scoped>

@ -18,8 +18,10 @@
<div class="form-text">
<p>"application/json" is good for any modern http servers such as express.js</p>
<i18n-t tag="p" keypath="webhookFormDataDesc">
"multipart/form-data"
<template #multipart>"multipart/form-data"</template>
<template #decodeFunction>
<strong>json_decode($_POST['data'])</strong>
</template>
</i18n-t>
</div>
</div>

@ -179,7 +179,7 @@ export default {
"Edit Status Page": "Edit Status Page",
"Go to Dashboard": "Go to Dashboard",
// Start notification form
defaultNotificationName: "My {0} Alert ({1})",
defaultNotificationName: "My {notification} Alert ({number})",
here: "here",
"Required": "Required",
"telegram": "Telegram",
@ -194,7 +194,7 @@ export default {
"Post URL": "Post URL",
"Content Type": "Content Type",
webhookJsonDesc: "{0} is good for any modern http servers such as express.js",
webhookFormDataDesc: "{0} is good for PHP, you just need to parse the json by {1}",
webhookFormDataDesc: "{multipart} is good for PHP, you just need to parse the json by {decodeFunction}",
"smtp": "Email (SMTP)",
secureOptionNone: "None / STARTTLS (25, 587)",
secureOptionTLS: "TLS (465)",

Loading…
Cancel
Save