gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/popup_dialog.vue

100 lines
1.9 KiB
Vue
Raw Normal View History

<script>
2017-08-15 18:16:42 +00:00
export default {
name: 'popup-dialog',
props: {
2017-08-15 18:16:42 +00:00
title: {
type: String,
required: true,
2017-08-15 18:16:42 +00:00
},
text: {
2017-08-15 18:16:42 +00:00
type: String,
required: false,
2017-08-15 18:16:42 +00:00
},
kind: {
type: String,
2017-08-15 18:16:42 +00:00
required: false,
default: 'primary',
},
2017-10-12 21:04:17 +00:00
closeKind: {
type: String,
required: false,
default: 'default',
},
closeButtonLabel: {
type: String,
2017-08-15 18:16:42 +00:00
required: false,
default: 'Cancel',
},
primaryButtonLabel: {
type: String,
2017-08-15 18:16:42 +00:00
required: true,
},
},
computed: {
2017-08-15 18:16:42 +00:00
btnKindClass() {
return {
[`btn-${this.kind}`]: true,
};
2017-08-01 13:41:24 +00:00
},
2017-10-12 21:04:17 +00:00
btnCancelKindClass() {
return {
[`btn-${this.closeKind}`]: true,
};
},
},
methods: {
close() {
this.$emit('toggle', false);
},
2017-08-15 18:16:42 +00:00
emitSubmit(status) {
this.$emit('submit', status);
2017-08-01 13:41:24 +00:00
},
},
};
</script>
2017-08-15 18:16:42 +00:00
<template>
<div
class="modal popup-dialog"
role="dialog"
tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button"
class="close"
@click="close"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{this.title}}</h4>
</div>
<div class="modal-body">
<slot name="body" :text="text">
<p>{{text}}</p>
</slot>
</div>
<div class="modal-footer">
<button
type="button"
class="btn"
:class="btnCancelKindClass"
@click="close">
{{ closeButtonLabel }}
</button>
<button
type="button"
class="btn"
:class="btnKindClass"
@click="emitSubmit(true)">
{{ primaryButtonLabel }}
</button>
</div>
</div>
</div>
</div>
2017-08-01 13:41:24 +00:00
</template>