2018-09-12 08:22:17 +02:00
|
|
|
<template>
|
2021-11-08 15:46:39 +01:00
|
|
|
<!-- FIXME: transition should not be included in the modal -->
|
2018-09-12 08:22:17 +02:00
|
|
|
<transition name="modal">
|
2021-09-24 20:08:48 +02:00
|
|
|
<section
|
|
|
|
v-if="enabled"
|
|
|
|
class="modal-mask"
|
|
|
|
:class="[
|
|
|
|
{ 'has-overflow': overflow },
|
|
|
|
variant,
|
|
|
|
]"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="modal-container"
|
2021-09-21 18:37:56 +02:00
|
|
|
:class="{'has-overflow': overflow}"
|
2021-09-24 20:08:48 +02:00
|
|
|
@click.self.prevent.stop="$emit('close')"
|
2021-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'Escape'"
|
2021-09-21 18:37:56 +02:00
|
|
|
>
|
2021-09-24 20:08:48 +02:00
|
|
|
<div
|
|
|
|
class="modal-content"
|
|
|
|
:class="{
|
|
|
|
'has-overflow': overflow,
|
|
|
|
'is-wide': wide
|
|
|
|
}"
|
|
|
|
>
|
2022-02-05 17:29:15 +01:00
|
|
|
<BaseButton
|
|
|
|
@click="emit('close')"
|
|
|
|
class="close"
|
|
|
|
>
|
|
|
|
<icon icon="times"/>
|
|
|
|
</BaseButton>
|
|
|
|
|
2021-01-16 22:15:48 +01:00
|
|
|
<slot>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div class="header">
|
|
|
|
<slot name="header"></slot>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<slot name="text"></slot>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
|
|
|
<x-button
|
|
|
|
@click="$emit('close')"
|
2022-01-04 19:58:06 +01:00
|
|
|
variant="tertiary"
|
2021-01-17 18:57:57 +01:00
|
|
|
class="has-text-danger"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.cancel') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
<x-button
|
|
|
|
@click="$emit('submit')"
|
2022-01-04 19:58:06 +01:00
|
|
|
variant="primary"
|
|
|
|
v-cy="'modalPrimary'"
|
2021-01-17 18:57:57 +01:00
|
|
|
:shadow="false"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.doit') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
|
|
|
</div>
|
2021-01-16 22:15:48 +01:00
|
|
|
</slot>
|
2018-09-12 08:22:17 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-24 20:08:48 +02:00
|
|
|
</section>
|
2018-09-12 08:22:17 +02:00
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-05 17:29:15 +01:00
|
|
|
import BaseButton from '@/components/base/BaseButton.vue'
|
|
|
|
|
2021-09-24 20:08:48 +02:00
|
|
|
export const TRANSITION_NAMES = {
|
|
|
|
MODAL: 'modal',
|
|
|
|
FADE: 'fade',
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VARIANTS = {
|
|
|
|
DEFAULT: 'default',
|
|
|
|
HINT_MODAL: 'hint-modal',
|
|
|
|
SCROLLING: 'scrolling',
|
|
|
|
}
|
|
|
|
|
|
|
|
function validValue(values) {
|
|
|
|
return (value) => Object.values(values).includes(value)
|
|
|
|
}
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'modal',
|
2022-02-05 17:29:15 +01:00
|
|
|
|
|
|
|
components: {
|
|
|
|
BaseButton,
|
|
|
|
},
|
|
|
|
|
2021-09-24 20:08:48 +02:00
|
|
|
mounted() {
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
|
|
// Close the model when escape is pressed
|
|
|
|
if (e.keyCode === 27) {
|
|
|
|
this.$emit('close')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
props: {
|
2021-09-24 20:08:48 +02:00
|
|
|
enabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
overflow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-30 17:17:04 +01:00
|
|
|
wide: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-09-24 20:08:48 +02:00
|
|
|
transitionName: {
|
|
|
|
type: String,
|
|
|
|
default: TRANSITION_NAMES.MODAL,
|
|
|
|
validator: validValue(TRANSITION_NAMES),
|
|
|
|
},
|
|
|
|
variant: {
|
|
|
|
type: String,
|
|
|
|
default: VARIANTS.DEFAULT,
|
|
|
|
validator: validValue(VARIANTS),
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
},
|
2021-08-23 21:18:12 +02:00
|
|
|
emits: ['close', 'submit'],
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2018-09-12 08:22:17 +02:00
|
|
|
</script>
|
2021-09-24 20:08:48 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.modal-mask {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 4000;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background-color: rgba(0, 0, 0, .8);
|
|
|
|
transition: opacity 150ms ease;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-container {
|
|
|
|
transition: all 150ms ease;
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
max-height: 100vh;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.default .modal-content,
|
|
|
|
.hint-modal .modal-content {
|
|
|
|
text-align: center;
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
margin: 0;
|
|
|
|
top: 25%;
|
|
|
|
transform: translate(-50%, -25%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
font-size: 2rem;
|
|
|
|
font-weight: 700;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
|
|
|
margin: 0 0.5rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// scrolling-content
|
|
|
|
// used e.g. for <TaskDetailViewModal>
|
|
|
|
.scrolling .modal-content {
|
|
|
|
max-width: 1024px;
|
|
|
|
width: 100%;
|
|
|
|
margin: 4rem auto;
|
|
|
|
|
|
|
|
max-height: none; // reset bulma
|
|
|
|
overflow: visible; // reset bulma
|
|
|
|
|
|
|
|
@media screen and (min-width: $tablet) {
|
|
|
|
max-height: none; // reset bulma
|
|
|
|
margin: 4rem auto; // reset bulma
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: $desktop) {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.is-wide {
|
|
|
|
max-width: $desktop;
|
|
|
|
width: calc(100% - 2rem);
|
|
|
|
}
|
|
|
|
|
|
|
|
.hint-modal {
|
|
|
|
z-index: 4600;
|
|
|
|
|
2021-10-20 14:33:36 +02:00
|
|
|
:deep(.card-content) {
|
2021-09-24 20:08:48 +02:00
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
.info {
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
|
|
|
|
p {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-05 17:29:15 +01:00
|
|
|
|
|
|
|
.close {
|
|
|
|
position: fixed;
|
|
|
|
top: 5px;
|
|
|
|
right: 26px;
|
|
|
|
color: var(--white);
|
|
|
|
font-size: 2rem;
|
|
|
|
|
|
|
|
@media screen and (max-width: $desktop) {
|
|
|
|
color: var(--dark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
// Close icon SVG uses currentColor, change the color to keep it visible
|
|
|
|
.dark .task-detail-view-modal .close {
|
|
|
|
color: var(--grey-900);
|
|
|
|
}
|
2021-09-24 20:08:48 +02:00
|
|
|
</style>
|