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

130 lines
2.6 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: false,
2017-08-15 18:16:42 +00:00
},
text: {
2017-08-15 18:16:42 +00:00
type: String,
required: false,
},
hideFooter: {
type: Boolean,
required: false,
default: false,
2017-08-15 18:16:42 +00:00
},
kind: {
type: String,
2017-08-15 18:16:42 +00:00
required: false,
default: 'primary',
},
modalDialogClass: {
type: String,
required: false,
default: '',
},
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,
},
submitDisabled: {
type: Boolean,
required: false,
default: false,
},
},
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-open">
<div
class="modal popup-dialog"
role="dialog"
tabindex="-1"
>
<div
:class="modalDialogClass"
class="modal-dialog"
role="document"
>
<div class="modal-content">
<div class="modal-header">
<slot name="header">
<h4 class="modal-title pull-left">
{{this.title}}
</h4>
<button
type="button"
class="close pull-right"
@click="close"
aria-label="Close"
>
<span aria-hidden="true">&times;</span>
</button>
</slot>
</div>
<div class="modal-body">
<slot name="body" :text="text">
<p>{{this.text}}</p>
</slot>
</div>
2017-10-31 19:02:11 +00:00
<div class="modal-footer" v-if="!hideFooter">
<button
type="button"
class="btn pull-left"
:class="btnCancelKindClass"
@click="close">
{{ closeButtonLabel }}
</button>
<button
type="button"
class="btn pull-right"
:disabled="submitDisabled"
:class="btnKindClass"
@click="emitSubmit(true)">
{{ primaryButtonLabel }}
</button>
</div>
</div>
</div>
</div>
<div class="modal-backdrop fade in" />
</div>
2017-08-01 13:41:24 +00:00
</template>