refactor podla review

This commit is contained in:
Filip Kaluža committed 2023-01-12 17:53:35 +01:00
1 parent d46a9151fc
commit c542ea7760
14 files changed
+89 -182

No files matched your search

@@ -0,0 +1,7 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.33325 6.66675L9.33325 11.3334" stroke="#14181F" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M6.66675 6.66675L6.66675 11.3334" stroke="#14181F" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4 4V3.5C3.72386 3.5 3.5 3.72386 3.5 4H4ZM12 4H12.5C12.5 3.72386 12.2761 3.5 12 3.5V4ZM4 4.5H12V3.5H4V4.5ZM11.5 4V13.3333H12.5V4H11.5ZM11.3333 13.5H4.66667V14.5H11.3333V13.5ZM4.5 13.3333V4H3.5V13.3333H4.5ZM4.66667 13.5C4.57462 13.5 4.5 13.4254 4.5 13.3333H3.5C3.5 13.9777 4.02233 14.5 4.66667 14.5V13.5ZM11.5 13.3333C11.5 13.4254 11.4254 13.5 11.3333 13.5V14.5C11.9777 14.5 12.5 13.9777 12.5 13.3333H11.5Z" fill="#14181F"/>
<path d="M2.66675 4H13.3334" stroke="#14181F" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M10.6666 4V4.5C10.9427 4.5 11.1666 4.27614 11.1666 4H10.6666ZM5.33325 4H4.83325C4.83325 4.27614 5.05711 4.5 5.33325 4.5V4ZM5.99992 2.5H9.99992V1.5H5.99992V2.5ZM10.1666 2.66667V4H11.1666V2.66667H10.1666ZM10.6666 3.5H5.33325V4.5H10.6666V3.5ZM5.83325 4V2.66667H4.83325V4H5.83325ZM9.99992 2.5C10.092 2.5 10.1666 2.57462 10.1666 2.66667H11.1666C11.1666 2.02233 10.6443 1.5 9.99992 1.5V2.5ZM5.99992 1.5C5.35559 1.5 4.83325 2.02233 4.83325 2.66667H5.83325C5.83325 2.57462 5.90787 2.5 5.99992 2.5V1.5Z" fill="#14181F"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 8.00006L6.82843 10.8285L12.4853 5.17163" stroke="black" stroke-opacity="0.87" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 242 B

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 20H22" stroke="#14181F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M19.6585 9.70128L12.6585 3.57628C12.2815 3.24638 11.7185 3.24638 11.3415 3.57628L4.3415 9.70128C4.12448 9.89117 4 10.1655 4 10.4539V19.0001C4 19.5524 4.44772 20.0001 5 20.0001H9C9.55228 20.0001 10 19.5524 10 19.0001V15.0001C10 14.4478 10.4477 14.0001 11 14.0001H13C13.5523 14.0001 14 14.4478 14 15.0001V19.0001C14 19.5524 14.4477 20.0001 15 20.0001H19C19.5523 20.0001 20 19.5524 20 19.0001V10.4539C20 10.1655 19.8755 9.89117 19.6585 9.70128Z" stroke="#14181F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 740 B

@@ -0,0 +1,3 @@
<svg width="9" height="16" viewBox="0 0 9 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.70711 0.292893C1.31658 -0.0976311 0.683418 -0.0976311 0.292893 0.292893C-0.0976311 0.683418 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM8 8L8.70711 8.70711C9.09763 8.31658 9.09763 7.68342 8.70711 7.29289L8 8ZM0.292893 14.2929C-0.0976311 14.6834 -0.0976311 15.3166 0.292893 15.7071C0.683418 16.0976 1.31658 16.0976 1.70711 15.7071L0.292893 14.2929ZM0.292893 1.70711L7.29289 8.70711L8.70711 7.29289L1.70711 0.292893L0.292893 1.70711ZM7.29289 7.29289L0.292893 14.2929L1.70711 15.7071L8.70711 8.70711L7.29289 7.29289Z" fill="#14181F"/>
</svg>

After

Width:  |  Height:  |  Size: 655 B

@@ -0,0 +1,3 @@
<svg width="10" height="17" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.79289 16.2071C8.18342 16.5976 8.81658 16.5976 9.20711 16.2071C9.59763 15.8166 9.59763 15.1834 9.20711 14.7929L7.79289 16.2071ZM1.5 8.5L0.792893 7.79289C0.402369 8.18342 0.402369 8.81658 0.792893 9.20711L1.5 8.5ZM9.20711 2.20711C9.59763 1.81658 9.59763 1.18342 9.20711 0.792893C8.81658 0.402369 8.18342 0.402369 7.79289 0.792893L9.20711 2.20711ZM9.20711 14.7929L2.20711 7.79289L0.792893 9.20711L7.79289 16.2071L9.20711 14.7929ZM2.20711 9.20711L9.20711 2.20711L7.79289 0.792893L0.792893 7.79289L2.20711 9.20711Z" fill="#14181F"/>
</svg>

After

Width:  |  Height:  |  Size: 643 B

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.33341 13.3334V13.8334C5.46602 13.8334 5.5932 13.7807 5.68697 13.6869L5.33341 13.3334ZM2.66675 13.3334H2.16675C2.16675 13.6095 2.39061 13.8334 2.66675 13.8334V13.3334ZM2.66675 10.6667L2.31319 10.3132C2.21943 10.4069 2.16675 10.5341 2.16675 10.6667H2.66675ZM10.1953 3.13813L10.5489 3.49169V3.49169L10.1953 3.13813ZM11.1382 3.13813L10.7846 3.49169V3.49169L11.1382 3.13813ZM12.862 4.86199L13.2156 4.50844V4.50844L12.862 4.86199ZM12.862 5.8048L12.5085 5.45125L12.862 5.8048ZM5.33341 12.8334H2.66675V13.8334H5.33341V12.8334ZM3.16675 13.3334V10.6667H2.16675V13.3334H3.16675ZM3.0203 11.0203L10.5489 3.49169L9.84179 2.78458L2.31319 10.3132L3.0203 11.0203ZM10.7846 3.49169L12.5085 5.21554L13.2156 4.50844L11.4917 2.78458L10.7846 3.49169ZM12.5085 5.45125L4.97986 12.9798L5.68697 13.6869L13.2156 6.15835L12.5085 5.45125ZM12.5085 5.21554C12.5735 5.28063 12.5735 5.38616 12.5085 5.45125L13.2156 6.15835C13.6712 5.70274 13.6712 4.96405 13.2156 4.50844L12.5085 5.21554ZM10.5489 3.49169C10.614 3.4266 10.7195 3.4266 10.7846 3.49169L11.4917 2.78458C11.0361 2.32897 10.2974 2.32897 9.84179 2.78458L10.5489 3.49169Z" fill="#14181F"/>
<path d="M8 5.33325L10.6667 7.99992" stroke="#14181F" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,466 @@
<template>
<div class="calendar-wrapper">
<Vue-cal
:hide-view-selector="true"
:hide-title-bar="true"
:disable-views="['years', 'year', 'month', 'week']"
active-view="day"
:selected-date="calConfig.date"
:onEventClick="taskClicked"
:editable-events="vueCalConfig.editing"
:events="calData.tasks"
:unscheduledTime="calData.unscheduled_times"
:overlaps-per-time-step="false"
:showTimeInCells="false"
:time-cell-height="timeCellHeight"
:snap-to-time="15"
:scroll-to-hour="calConfig.scrollHour"
:split-days="splits"
:sticky-split-labels="true"
:min-split-width="300"
@ready="onReady()"
@view-change="weekChanged"
@event-drop="eventMoved"
@event-focus="eventFocused"
>
<template v-slot:split-label="{ split }">
<div class="w-100 h-100 d-flex flex-column">
<span v-if="split.date" class="d-flex align-center">
<img v-if="getHeadingDate(split.date) == 'Dnes'" :src="require('./_img/home-icon.svg')" class="mr-2">
<p class="weekday-label">{{ getHeadingDate(split.date) }}</p>
</span>
<span v-else class="d-flex align-center">
<p class="weekday-label">{{ split.firstName }}</p>
</span>
<div v-if="split.unscheduledTime && split.initials" class="unscheduled-time d-flex align-center text-left">
<div class="unscheduled-time-initials d-flex align-center justify-center me-4">
<p>{{split.initials}}</p>
</div>
<div>
<p class="mb-0 mt-0 unscheduled-time-name">{{split.name}}</p>
<h1 class="mb-0 mt-0">{{split.unscheduledTime}} h</h1>
</div>
</div>
</div>
</template>
<template v-slot:time-cell="{ hours, minutes }">
<span class="d-flex align-center justify-center">
<p>{{hours}}:{{String(minutes).padStart(2, '0')}}</p>
<div class="time-column-line"></div>
</span>
</template>
<template v-slot:event="{ event }">
<!-- <div v-if="!event.nonWorking" @click.stop="editTask(event.id)" class="w-100 h-100 d-flex flex-column justify-space-between" :class="{'short-event' : getEventLenght(event) <= 9000000, 'mini-event' : getEventLenght(event) <= 5400000, 'micro-event' : getEventLenght(event) <= 3600000}"> -->
<div v-if="!event.nonWorking" class="w-100 h-100 d-flex flex-column justify-space-between" :class="{'short-event' : getEventLenght(event) <= 9000000, 'mini-event' : getEventLenght(event) <= 5400000, 'micro-event' : getEventLenght(event) <= 3600000}">
<div class="event-content">
<small v-if="(event.project_code && !event.is_blocker)" class="project-code">{{ event.project_code }}</small>
<h3>{{ event.title }}</h3>
<div class="d-flex align-center event-details event-initials-wrapper">
<div class="event-initials d-flex justify-center align-center">
<small>{{ getUserInitials(event) }}</small>
</div>
<small class="event-initials-date">{{ new Date(event.starts_at).toLocaleDateString('sk-SK') }}</small>
</div>
</div>
<div class="event-footer d-flex">
<v-btn rounded class="event-footer-button me-2" :class="{'completed': event.completed}" @click="clickCompleteTask(event)"><img :src="require('./_img/checkmark.svg')" alt=""></v-btn>
<v-btn rounded class="event-footer-button me-2" @click.stop="editTask(event.id, true)"><img :src="require('./_img/pencil.svg')" alt=""></v-btn>
<v-btn rounded class="event-footer-button me-2" @click.stop="this.showDeleteModal = {task: event}"><img :src="require('./_img/bin.svg')" alt=""></v-btn>
</div>
</div>
<div v-else class="non-working-event w-100 h-100 d-flex flex-column justify-center">
<div class="d-flex justify-center align-center">
<v-icon icon="mdi-cancel" color="black"></v-icon>
<h3 class="mb-0 ms-2">{{ event.title }}</h3>
</div>
</div>
</template>
</Vue-cal>
<Z-sub-task-modal ref="z-sub-task-modal" />
<!-- Kravarik: Prerobit modaly na novy sposob -->
<Z-complete-task-modal v-if="showCompleteModal" :visible="showCompleteModal ? true : false" :task="showCompleteModal.task" @completeTask="completeTask" @close="showCompleteModal = null" />
<Z-delete-task-modal v-if="showDeleteModal" :visible="showDeleteModal ? true : false" :task="showDeleteModal.task" @deleteTask="deleteTask" @close="showDeleteModal = null" />
</div>
</template>
<script>
import ZCompleteTaskModal from '@/plugins/tm@modal/task/z-complete-task-modal.vue'
import ZDeleteTaskModal from '@/plugins/tm@modal/task/z-delete-task-modal.vue'
import ZSubTaskModal from '@/plugins/tm@modal/sub-task/z-sub-task-modal.vue'
export default {
components: {
ZCompleteTaskModal,
ZDeleteTaskModal,
ZSubTaskModal
},
props: {
calData: {
type: Object,
required: true,
default() {
return {}
}
},
calConfig: {
type: Object,
required: true,
default() {
return {date: new Date(), scrollHour: 7}
}
},
splits: {
type: Array,
required: false,
default() {
return []
}
}
},
data() {
return {
vueCalConfig: {
editing: {
title: false,
drag: true,
resize: false,
delete: false,
create: false
}
},
focusedEventId: null,
showCompleteModal: null,
showDeleteModal: null,
timeCellHeight: 100,
}
},
methods: {
weekChanged() {
const scrollContainer = this.$el.getElementsByClassName('vuecal__scrollable-body')[0]
scrollContainer.scrollLeft = 0
},
async eventMoved(e) {
this.focusedEventId = e.event.id
this.$emit('eventMoved', e)
},
onReady() {
this.correctMargins()
},
correctMargins() {
if (!this.$el.getElementsByClassName('vuecal__split-days-headers').length)
return
const heightOfDayHeader = this.$el.getElementsByClassName('vuecal__split-days-headers')[0].clientHeight
this.$el.getElementsByClassName('vuecal__time-column')[0].style.marginTop = `${heightOfDayHeader}px`
this.$el.getElementsByClassName('vuecal__cells-body')[0].style.marginTop = `${heightOfDayHeader}px`
},
getHeadingDate(value) {
const date = new Date(value)
const today = new Date()
const yesterday = new Date((new Date()).setDate(today.getDate() - 1))
const tomorrow = new Date((new Date()).setDate(today.getDate() + 1))
if (today.toLocaleDateString('sk-SK') === date.toLocaleDateString('sk-SK')) return "Dnes"
if (yesterday.toLocaleDateString('sk-SK') === date.toLocaleDateString('sk-SK')) return "Včera"
if (tomorrow.toLocaleDateString('sk-SK') === date.toLocaleDateString('sk-SK')) return "Zajtra"
return date.toLocaleDateString('sk-SK')
},
getUserInitials(event) {
return event.name.charAt(0).toUpperCase() + event.surname.charAt(0).toUpperCase()
},
getEventLenght(event) {
return event.end.getTime() - event.start.getTime()
},
taskClicked(task) {
if (task.nonWorking) return
console.log("task", task)
if (task.end.getTime() - task.start.getTime() <= 3600000) {
console.log("ShortTask")
}
},
eventFocused(event) {
this.focusedEventId = event.task_id
// console.log(`Focused: ${event.task_id}`)
},
clickCompleteTask(event) {
if (event.completed) this.completeTask(event.id)
else this.showCompleteModal = {task: event}
},
completeTask(id) {
this.$emit('completeTask', id)
},
editTask(subTask, editMode) {
this.$refs['z-sub-task-modal'].create(subTask, editMode)
},
deleteTask(id) {
this.$emit('deleteTask', id)
}
}
}
</script>
<style lang="sass" scoped>
.vuecal
box-shadow: none !important
.calendar-wrapper
width: 100%
height: 100%
// padding: 0 20px 0 0
&:deep()
.vuecal__cells
-ms-overflow-style: none
scrollbar-width: none
&::-webkit-scrollbar
display: none
border-left: 1px solid rgba(0, 0, 0, .1)
padding-left: 20px
.vuecal__flex
flex-wrap: nowrap !important
// TIME COLUMN
.vuecal__time-column
width: 150px
box-shadow: none !important
.time-column-line
width: 40px
height: 0
border: 1px solid rgba(33, 33, 33, 0.08)
margin-left: 10px
@media (max-width: 450px)
.vuecal__time-column
width: 70px
.time-column-line
width: 10px
// HEADING
// .vuecal__weekdays-headings,
.vuecal__cell:before
border: none
.vuecal__scrollable-body
position: relative
// .vuecal__weekdays-headings
.vuecal__split-days-headers
position: absolute
top: 0
left: 20px
z-index: 999
background: white
padding-bottom: 15px
width: calc( 100% - 20px )
.vuecal__cell-split
margin-right: 20px
.day-split-header
height: fit-content
min-height: 100%
padding-right: 20px
.weekday-label
justify-content: start !important
font-size: 24px
font-weight: 700
.unscheduled-time
background: rgba(0, 0, 0, 0.04)
border-radius: 24px
padding: 10px 15px
margin-top: 10px
.unscheduled-time-name
font-weight: 400
font-size: 15px
.unscheduled-time-initials
width: 50px
height: 50px
background: #6200EE
border-radius: 50%
p
font-weight: 400
font-size: 20px
color: white
// BODY
.vuecal__body
-ms-overflow-style: none
scrollbar-width: none
&::-webkit-scrollbar
display: none
.vuecal__now-line
display: none !important
// .vuecal__cell
// padding: 10px 20px 10px 0px
.vuecal:not(.vuecal--day-view) .vuecal__cell--selected:not(.vuecal__cell--today) ,
.vuecal__cell--current:not(.vuecal__cell--today),
.vuecal__cell--today,
.vuecal__cell--highlighted,
.vuecal__cell--selected
background-color: white
// EVENT
.vuecal__event
border-radius: 16px
padding: 20px 10px
text-align: left
background: rgba(248, 248, 248, 1)
min-height: 40px
transition: min-height .4s, height .4s, box-shadow .4s, width .4s, left .4s
&:has(.completed)
background: rgb(251, 251, 251) !important
border: 1px solid #cccccc !important
&:has(.non-working-event)
background: repeating-linear-gradient(135deg, rgba(215, 215, 215, 1), rgba(215, 215, 215, 1) 1px, rgba(224, 224, 224, 1) 1px, rgba(224, 224, 224, 1) 20px)
border: 1px solid rgba(215, 215, 215, 1)
&.vuecal__event--focus
z-index: 100 !important
min-height: 250px !important
width: 100% !important
left: 0 !important
&:not(.vuecal__event--focus)
&:has(.short-event)
padding: 10px !important
&:has(.micro-event)
padding: 5px 10px !important
.short-event
.project-code
display: none !important
h3
font-size: 16px !important
.mini-event
.event-content
display: flex
align-items: center
flex-wrap: nowrap
justify-content: space-between
width: 100%
.event-initials-wrapper
margin-bottom: 0
.event-initials
margin-right: 0
h3
font-size: 14px !important
text-overflow: ellipsis
width: calc( 100% - 35px )
white-space: nowrap
overflow: hidden
margin: 0
.event-initials-date
display: none !important
.micro-event
.event-footer
display: none !important
&.event-blocker
background: #B00020 !important
h3,
.event-details *
color: white !important
.event-details .event-initials
border: 1px solid white
.event-footer
border-top: 1px solid rgba(255, 255, 255, 0.19)
.project-code
margin: 0 0 20px
display: block
h3
font-size: 18px
font-weight: 400
color: Black
margin: 0 0 10px
max-height: 100%
small
color: black
.event-initials-wrapper
margin-bottom: 20px
.event-initials
height: 30px
width: 30px
border: 1px solid black
border-radius: 50%
padding: 5px
margin-right: 7px
small
font-size: 11px
.event-footer
padding-top: 15px
border-top: 1px solid rgba(33, 33, 33, 0.08)
.event-footer-button
box-shadow: none !important
padding: 9px !important
min-height: fit-content
height: fit-content
min-width: fit-content
width: fit-content
&.completed
background: #06dece
img
width: 18px
</style>