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

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

@ -179,7 +179,7 @@ export default {
"Edit Status Page": "Edit Status Page", "Edit Status Page": "Edit Status Page",
"Go to Dashboard": "Go to Dashboard", "Go to Dashboard": "Go to Dashboard",
// Start notification form // Start notification form
defaultNotificationName: "My {0} Alert ({1})", defaultNotificationName: "My {notification} Alert ({number})",
here: "here", here: "here",
"Required": "Required", "Required": "Required",
"telegram": "Telegram", "telegram": "Telegram",
@ -194,7 +194,7 @@ export default {
"Post URL": "Post URL", "Post URL": "Post URL",
"Content Type": "Content Type", "Content Type": "Content Type",
webhookJsonDesc: "{0} is good for any modern http servers such as express.js", 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)", "smtp": "Email (SMTP)",
secureOptionNone: "None / STARTTLS (25, 587)", secureOptionNone: "None / STARTTLS (25, 587)",
secureOptionTLS: "TLS (465)", secureOptionTLS: "TLS (465)",

Loading…
Cancel
Save