Skip to content

Commit

Permalink
Added more options for confirm modal
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Computroniks committed Feb 14, 2023
1 parent 66d5408 commit 0d6a8b2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="modal-content">
<div class="modal-header">
<h5 id="exampleModalLabel" class="modal-title">
{{ $t("Confirm") }}
{{ title || $t("Confirm") }}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" />
</div>
Expand All @@ -15,7 +15,7 @@
<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">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @click="no">
{{ noText }}
</button>
</div>
Expand Down Expand Up @@ -44,8 +44,13 @@ export default {
type: String,
default: "No",
},
/** Title to show on modal. Defaults to translated version of "Config" */
title: {
type: String,
default: null,
}
},
emits: [ "yes" ],
emits: [ "yes", "no" ],
data: () => ({
modal: null,
}),
Expand All @@ -63,6 +68,12 @@ export default {
yes() {
this.$emit("yes");
},
/**
* @emits string "no" Notify the parent when No is pressed
*/
no() {
this.$emit("no");
}
},
};
</script>

0 comments on commit 0d6a8b2

Please sign in to comment.