mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-28 01:04:05 +00:00
0d6a8b2101
The ability to set the title of the modal has been added, as well as custom callbacks for the no option. Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
79 lines
2.2 KiB
Vue
79 lines
2.2 KiB
Vue
<template>
|
|
<div ref="modal" class="modal fade" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 id="exampleModalLabel" class="modal-title">
|
|
{{ title || $t("Confirm") }}
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" />
|
|
</div>
|
|
<div class="modal-body">
|
|
<slot />
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn" :class="btnStyle" data-bs-dismiss="modal" @click="yes">
|
|
{{ yesText }}
|
|
</button>
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @click="no">
|
|
{{ noText }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { Modal } from "bootstrap";
|
|
|
|
export default {
|
|
props: {
|
|
/** Style of button */
|
|
btnStyle: {
|
|
type: String,
|
|
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,
|
|
}
|
|
},
|
|
emits: [ "yes", "no" ],
|
|
data: () => ({
|
|
modal: null,
|
|
}),
|
|
mounted() {
|
|
this.modal = new Modal(this.$refs.modal);
|
|
},
|
|
methods: {
|
|
/** Show the confirm dialog */
|
|
show() {
|
|
this.modal.show();
|
|
},
|
|
/**
|
|
* @emits string "yes" Notify the parent when Yes is pressed
|
|
*/
|
|
yes() {
|
|
this.$emit("yes");
|
|
},
|
|
/**
|
|
* @emits string "no" Notify the parent when No is pressed
|
|
*/
|
|
no() {
|
|
this.$emit("no");
|
|
}
|
|
},
|
|
};
|
|
</script>
|