uptime-kuma/src/components/Confirm.vue

80 lines
2.2 KiB
Vue
Raw Normal View History

2021-06-25 13:55:49 +00:00
<template>
2021-07-27 17:47:13 +00:00
<div ref="modal" class="modal fade" tabindex="-1">
2021-06-25 13:55:49 +00:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
2021-07-27 17:47:13 +00:00
<h5 id="exampleModalLabel" class="modal-title">
{{ title || $t("Confirm") }}
2021-07-27 17:47:13 +00:00
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" />
2021-06-25 13:55:49 +00:00
</div>
<div class="modal-body">
2021-07-27 17:47:13 +00:00
<slot />
2021-06-25 13:55:49 +00:00
</div>
<div class="modal-footer">
2021-07-27 17:47:13 +00:00
<button type="button" class="btn" :class="btnStyle" data-bs-dismiss="modal" @click="yes">
{{ yesText }}
2021-07-27 17:47:13 +00:00
</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @click="no">
{{ noText }}
2021-07-27 17:47:13 +00:00
</button>
2021-06-25 13:55:49 +00:00
</div>
</div>
</div>
</div>
</template>
<script>
2022-04-13 16:30:32 +00:00
import { Modal } from "bootstrap";
2021-06-25 13:55:49 +00:00
export default {
props: {
/** Style of button */
2021-06-25 13:55:49 +00:00
btnStyle: {
type: String,
2021-07-27 17:47:13 +00:00
default: "btn-primary",
},
/** Text to use as yes */
yesText: {
type: String,
default: "Yes", // TODO: No idea what to translate this
},
/** Text to use as no */
noText: {
type: String,
default: "No",
},
/** Title to show on modal. Defaults to translated version of "Config" */
title: {
type: String,
default: null,
}
2021-06-25 13:55:49 +00:00
},
emits: [ "yes", "no" ],
2021-06-25 13:55:49 +00:00
data: () => ({
2021-07-27 17:47:13 +00:00
modal: null,
2021-06-25 13:55:49 +00:00
}),
mounted() {
2022-04-13 16:30:32 +00:00
this.modal = new Modal(this.$refs.modal);
2021-06-25 13:55:49 +00:00
},
methods: {
/** Show the confirm dialog */
2021-06-25 13:55:49 +00:00
show() {
2022-04-13 16:30:32 +00:00
this.modal.show();
2021-06-25 13:55:49 +00:00
},
/**
* @emits string "yes" Notify the parent when Yes is pressed
*/
2021-06-25 13:55:49 +00:00
yes() {
2021-07-27 17:47:13 +00:00
this.$emit("yes");
},
/**
* @emits string "no" Notify the parent when No is pressed
*/
no() {
this.$emit("no");
}
2021-07-27 17:47:13 +00:00
},
2022-04-13 16:30:32 +00:00
};
2021-06-25 13:55:49 +00:00
</script>