debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/deprecated_modal.vue

174 lines
3.8 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
/* eslint-disable vue/require-default-prop */
export default {
2018-05-09 12:01:36 +05:30
name: 'DeprecatedModal', // use GlModal instead
2018-03-17 18:26:18 +05:30
props: {
id: {
type: String,
required: false,
},
title: {
type: String,
required: false,
},
text: {
type: String,
required: false,
},
hideFooter: {
type: Boolean,
required: false,
default: false,
},
kind: {
type: String,
required: false,
default: 'primary',
},
modalDialogClass: {
type: String,
required: false,
default: '',
},
closeKind: {
type: String,
required: false,
default: 'default',
},
closeButtonLabel: {
type: String,
required: false,
default: 'Cancel',
},
primaryButtonLabel: {
type: String,
required: false,
default: '',
},
secondaryButtonLabel: {
type: String,
required: false,
default: '',
},
submitDisabled: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
btnKindClass() {
return {
[`btn-${this.kind}`]: true,
};
},
btnCancelKindClass() {
return {
[`btn-${this.closeKind}`]: true,
};
},
},
methods: {
emitCancel(event) {
this.$emit('cancel', event);
},
emitSubmit(event) {
this.$emit('submit', event);
},
},
};
</script>
<template>
<div class="modal-open">
<div
:id="id"
2018-11-08 19:23:39 +05:30
:class="id ? '' : 'd-block'"
2018-03-17 18:26:18 +05:30
class="modal"
role="dialog"
tabindex="-1"
>
<div
:class="modalDialogClass"
class="modal-dialog"
role="document"
>
<div class="modal-content">
<div class="modal-header">
<slot name="header">
2018-11-08 19:23:39 +05:30
<h4 class="modal-title float-left">
2018-03-17 18:26:18 +05:30
{{ title }}
</h4>
<button
type="button"
2018-11-08 19:23:39 +05:30
class="close float-right"
2018-03-17 18:26:18 +05:30
data-dismiss="modal"
aria-label="Close"
2018-11-08 19:23:39 +05:30
@click="emitCancel($event)"
2018-03-17 18:26:18 +05:30
>
<span aria-hidden="true">&times;</span>
</button>
</slot>
</div>
<div class="modal-body">
<slot
:text="text"
2018-11-08 19:23:39 +05:30
name="body"
2018-03-17 18:26:18 +05:30
>
<p>{{ text }}</p>
</slot>
</div>
<div
v-if="!hideFooter"
2018-11-08 19:23:39 +05:30
class="modal-footer"
2018-03-17 18:26:18 +05:30
>
<button
2018-11-08 19:23:39 +05:30
:class="btnCancelKindClass"
2018-03-17 18:26:18 +05:30
type="button"
class="btn"
data-dismiss="modal"
2018-11-08 19:23:39 +05:30
@click="emitCancel($event)"
2018-03-17 18:26:18 +05:30
>
{{ closeButtonLabel }}
</button>
<slot
v-if="secondaryButtonLabel"
name="secondary-button"
>
<button
v-if="secondaryButtonLabel"
type="button"
class="btn"
data-dismiss="modal"
>
{{ secondaryButtonLabel }}
</button>
</slot>
<button
v-if="primaryButtonLabel"
:disabled="submitDisabled"
:class="btnKindClass"
2018-11-08 19:23:39 +05:30
type="button"
class="btn js-primary-button"
2018-03-17 18:26:18 +05:30
data-dismiss="modal"
2018-11-08 19:23:39 +05:30
@click="emitSubmit($event)"
2018-03-17 18:26:18 +05:30
>
{{ primaryButtonLabel }}
</button>
</div>
</div>
</div>
</div>
<div
v-if="!id"
2018-11-08 19:23:39 +05:30
class="modal-backdrop fade show"
2018-03-17 18:26:18 +05:30
>
</div>
</div>
</template>