WIP Позиционирование карточек
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
@selected-event="transmitEventData"
|
||||
@reset-change-form="transmitResetChangeForm"
|
||||
@delete-event="transmitDeleteEvent"
|
||||
:schedule-body-ref="scheduleBodyRef"
|
||||
)
|
||||
</template>
|
||||
|
||||
@@ -45,6 +46,7 @@ export default {
|
||||
dayStartTime: Number,
|
||||
eventTypes: Array,
|
||||
changeFormWasClosed: Boolean,
|
||||
scheduleBodyRef: Node,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<template lang="pug">
|
||||
.wrapper.cursor-pointer.my-1.relative(
|
||||
:style="themeColors",
|
||||
:class="cardTheme"
|
||||
:class="cardTheme",
|
||||
ref="eventCard"
|
||||
)
|
||||
.card.flex.px-2(
|
||||
:class="{'py-6px flex-col': longCard}",
|
||||
@@ -20,14 +21,15 @@
|
||||
.col
|
||||
ul
|
||||
li.mt-2(v-for="elem in descriptionColumns.rightColumn" :key="elem") {{ elem }}
|
||||
calendar-event-description-card.right-0(
|
||||
calendar-event-description-card(
|
||||
v-if="isOpenDescriptionCard"
|
||||
:style="descriptionCardPosition"
|
||||
:owner-event="ownerEvent"
|
||||
:event-types="eventTypes"
|
||||
@selected-event="transmitEventData"
|
||||
@close-description-card="closeDescriptionCard"
|
||||
@delete-event="transmitDeleteEvent"
|
||||
:schedule-body-ref="scheduleBodyRef"
|
||||
:event-card-size="cardSize"
|
||||
)
|
||||
</template>
|
||||
|
||||
@@ -45,6 +47,7 @@ export default {
|
||||
return [];
|
||||
},
|
||||
},
|
||||
scheduleBodyRef: Node,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -52,6 +55,7 @@ export default {
|
||||
isActive: false,
|
||||
someDetailsShown: true,
|
||||
isOpenDescriptionCard: false,
|
||||
cardSize: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -182,11 +186,6 @@ export default {
|
||||
if (!remainingDetails) this.changeDetailsShown();
|
||||
return remainingDetails;
|
||||
},
|
||||
descriptionCardPosition() {
|
||||
return {
|
||||
top: `calc(${this.cardHeight.height} + 8px)`,
|
||||
};
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
trimTime(time) {
|
||||
@@ -224,6 +223,12 @@ export default {
|
||||
this.hideDescriptionCard();
|
||||
this.setDefaultTheme();
|
||||
},
|
||||
writeCardSize() {
|
||||
this.cardSize = {
|
||||
width: this.$refs["eventCard"].getBoundingClientRect().width,
|
||||
height: this.calculateCardHeight - 8,
|
||||
};
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
changeFormWasClosed: {
|
||||
@@ -236,6 +241,9 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.writeCardSize();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<template lang="pug">
|
||||
.wrapper.px-4.pt-14px.pb-4.font-medium.cursor-auto(
|
||||
:style="typeColor",
|
||||
:style="{...typeColor, ...position}",
|
||||
v-click-outside="close",
|
||||
:class="{'shadow': !disabled}"
|
||||
ref="descriptionCard"
|
||||
)
|
||||
.flex.justify-between.items-center.mb-2
|
||||
.flex
|
||||
@@ -36,10 +37,13 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
scheduleBodyRef: Node,
|
||||
eventCardSize: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isCertainType: true,
|
||||
position: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -111,11 +115,30 @@ export default {
|
||||
return `${object.last_name} ${object.first_name} ${object.patronymic}`;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (!this.$refs.descriptionCard || !this.scheduleBodyRef) return;
|
||||
const cardRect = this.$refs.descriptionCard.getBoundingClientRect();
|
||||
const bodyRect = this.scheduleBodyRef.getBoundingClientRect();
|
||||
//const bodyHeight = this.scheduleBodyRef.clientHeight + bodyRect.y - 20;
|
||||
const bodyWidth = this.scheduleBodyRef.clientWidth + bodyRect.x - 20;
|
||||
if (cardRect.x + cardRect.width > bodyWidth) {
|
||||
this.position = {
|
||||
top: `-${this.eventCardSize.height + 8}px`,
|
||||
left: `-${cardRect.width + 8}px`,
|
||||
};
|
||||
} else {
|
||||
this.position = {
|
||||
top: `-${this.eventCardSize.height + 8}px`,
|
||||
right: `-${this.eventCardSize.width + 8}px`,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="sass" scoped>
|
||||
.wrapper
|
||||
width: 100% !important
|
||||
height: auto !important
|
||||
background-color: var(--default-white)
|
||||
color: var(--font-dark-blue-color)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
@selected-event="transmitEventData"
|
||||
@reset-change-form="transmitResetChangeForm"
|
||||
@delete-event="transmitDeleteEvent"
|
||||
:schedule-body-ref="$refs.scheduleBody"
|
||||
)
|
||||
.flex.w-full.relative
|
||||
.time-coil-wrapper.left-0.-mt-12.pt-9
|
||||
|
||||
Reference in New Issue
Block a user