forked from openWB/openwb-ui-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenwbBaseModalDialog.vue
119 lines (118 loc) · 2.52 KB
/
OpenwbBaseModalDialog.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
<teleport to="body" v-if="show">
<div class="modal-backdrop fade show"></div>
<div class="modal fade d-block show" role="dialog" @click="handleClick">
<div
class="modal-dialog modal-dialog-centered modal-dialog-scrollable"
role="document"
>
<div class="modal-content">
<!-- modal header -->
<div class="modal-header" :class="'bg-' + subtype">
<h4 class="modal-title">{{ title }}</h4>
<button
v-if="!preventClose"
type="button"
class="close"
@click="handleClick"
>
×
</button>
</div>
<!-- modal body -->
<div class="modal-body">
<slot># Body #</slot>
</div>
<!-- modal footer -->
<div
v-if="myButtons.length > 0"
class="modal-footer d-flex"
:class="'justify-content-' + footerAlignment"
>
<button
v-for="button in myButtons"
:key="button.text"
type="button"
class="btn"
:class="
button.subtype
? 'btn-' + button.subtype
: 'btn-secondary'
"
data-dismiss="modal"
:data-event="button.event ? button.event : 'close'"
@click="handleClick"
>
{{ button.text }}
</button>
</div>
</div>
</div>
</div>
</teleport>
</template>
<script>
export default {
name: "OpenwbModalDialog",
emits: ["modal-result"],
props: {
title: String,
subtype: {
type: String,
validator: function (value) {
return (
[
"info",
"success",
"warning",
"danger",
"primary",
"secondary",
"light",
"dark",
].indexOf(value) !== -1
);
},
default: "secondary",
},
buttons: { type: Array, default: undefined },
footerAlignment: {
type: String,
validator: function (value) {
return (
["around", "between", "center", "end", "start"].indexOf(
value,
) !== -1
);
},
default: "end",
},
preventClose: { type: Boolean, default: false },
show: { type: Boolean, default: false },
},
computed: {
myButtons() {
var buttons = [];
if (this.buttons !== undefined) {
buttons = this.buttons;
}
if (!this.preventClose) {
buttons.push({ text: "Schließen", event: "close" });
}
return buttons;
},
},
methods: {
handleClick(event) {
event.stopPropagation();
let data = event.target.getAttribute("data-event");
if (data === null) {
data = "close";
}
if (data != "close" || !this.preventClose) {
this.$emit("modal-result", data);
}
},
},
};
</script>