akaunting/resources/assets/js/components/AkauntingModal.vue

148 lines
4.2 KiB
Vue
Raw Normal View History

2019-11-16 10:21:14 +03:00
<template>
<SlideYUpTransition :duration="animationDuration">
<div class="modal fade"
@click.self="closeModal"
:class="[{'show d-block': show}, {'d-none': !show}]"
v-show="show"
tabindex="-1"
role="dialog"
:aria-hidden="!show">
<div class="modal-dialog">
<slot name="modal-content">
<div class="modal-content">
<div class="card-header pb-2">
<slot name="card-header">
<h4 class="float-left"> {{ title }} </h4>
<button type="button" class="close" @click="onCancel" aria-hidden="true">&times;</button>
</slot>
</div>
<slot name="modal-body">
<div class="modal-body" v-html="message">
</div>
</slot>
<div class="card-footer border-top-0">
<slot name="card-footer">
<div class="float-right">
<button type="button" class="btn btn-icon btn-outline-secondary" @click="onCancel">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ button_cancel }}</span>
</button>
<button :disabled="form.loading" type="button" class="btn btn-icon btn-danger button-submit" @click="onConfirm">
2019-12-02 16:20:14 +03:00
<div v-if="form.loading" class="aka-loader-frame btn-delete"><div class="aka-loader"></div></div>
2019-12-02 15:32:11 +03:00
<span v-if="!form.loading" class="btn-inner--icon"><i class="fas fa-trash"></i></span>
<span v-if="!form.loading" class="btn-inner--text">{{ button_delete }}</span>
</button>
2019-11-16 10:21:14 +03:00
</div>
</slot>
</div>
</div>
</slot>
</div>
</div>
</SlideYUpTransition>
</template>
<script>
import { SlideYUpTransition } from "vue2-transitions";
import AkauntingRadioGroup from './forms/AkauntingRadioGroup';
import AkauntingSelect from './AkauntingSelect';
import AkauntingDate from './AkauntingDate';
import AkauntingRecurring from './AkauntingRecurring';
import {VMoney} from 'v-money';
2019-11-16 10:21:14 +03:00
export default {
name: 'akaunting-modal',
componentName: 'akaunting-modal',
components: {
SlideYUpTransition,
AkauntingRadioGroup,
AkauntingSelect,
AkauntingDate,
AkauntingRecurring
},
directives: {
money: VMoney
},
2019-11-16 10:21:14 +03:00
props: {
show: Boolean,
title: {
type: String,
default: '',
description: "Modal header title"
},
message: {
type: String,
default: '',
description: "Modal body message"
},
button_cancel: {
type: String,
default: '',
description: "Modal footer cancel button text"
},
button_delete: {
type: String,
default: '',
description: "Modal footer delete button text"
},
animationDuration: {
type: Number,
default: 800,
description: "Modal transition duration"
}
},
data() {
return {
form: {
loading: false,
name: this.name,
enabled: this.enabled
},
display: this.show
};
},
2019-11-16 10:21:14 +03:00
methods: {
closeModal() {
this.$emit("update:show", false);
this.$emit("close");
},
onConfirm() {
2019-12-02 15:32:11 +03:00
this.form.loading = true;
2019-11-16 10:21:14 +03:00
this.$emit("confirm");
},
onCancel() {
this.$emit("cancel");
}
},
watch: {
show(val) {
let documentClasses = document.body.classList;
if (val) {
documentClasses.add("modal-open");
} else {
documentClasses.remove("modal-open");
}
}
}
}
</script>
<style>
.modal.show {
background-color: rgba(0, 0, 0, 0.3);
}
</style>