Variable name and key binding

pull/427/head
zsxeee 3 years ago
parent 66e40d9fcb
commit 2fb3c40307
No known key found for this signature in database
GPG Key ID: 895CFFFD8313B3B8

@ -13,7 +13,7 @@
<div class="mb-3"> <div class="mb-3">
<label for="notification-type" class="form-label">{{ $t("Notification Type") }}</label> <label for="notification-type" class="form-label">{{ $t("Notification Type") }}</label>
<select id="notification-type" v-model="notification.type" class="form-select"> <select id="notification-type" v-model="notification.type" class="form-select">
<option v-for="type in notificationTypes" :value="type">{{ $t(type) }}</option> <option v-for="type in notificationTypes" :key="type" :value="type">{{ $t(type) }}</option>
</select> </select>
</div> </div>
@ -72,7 +72,7 @@ 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 NotificationForm from "./notifications" import NotificationFormList from "./notifications"
export default { export default {
components: { components: {
@ -85,10 +85,10 @@ export default {
model: null, model: null,
processing: false, processing: false,
id: null, id: null,
notificationTypes: Object.keys(NotificationForm), notificationTypes: Object.keys(NotificationFormList),
notification: { notification: {
name: "", name: "",
/** @type { null | keyof NotificationForm } */ /** @type { null | keyof NotificationFormList } */
type: null, type: null,
isDefault: false, isDefault: false,
// Do not set default value here, please scroll to show() // Do not set default value here, please scroll to show()
@ -101,7 +101,7 @@ export default {
if (!this.notification.type) { if (!this.notification.type) {
return null return null
} }
return NotificationForm[this.notification.type] return NotificationFormList[this.notification.type]
} }
}, },

@ -21,7 +21,7 @@ import Mattermost from "./Mattermost.vue";
* *
* @type { Record<string, any> } * @type { Record<string, any> }
*/ */
const NotificationForm = { const NotificationFormList = {
"telegram": Telegram, "telegram": Telegram,
"webhook": Webhook, "webhook": Webhook,
"smtp": STMP, "smtp": STMP,
@ -41,4 +41,4 @@ const NotificationForm = {
"mattermost": Mattermost "mattermost": Mattermost
} }
export default NotificationForm export default NotificationFormList

Loading…
Cancel
Save