2018-12-13 13:39:08 +05:30
|
|
|
<script>
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlTooltip, GlIcon } from '@gitlab/ui';
|
2022-10-11 01:57:18 +05:30
|
|
|
import dateFormat from '~/lib/dateformat';
|
2019-02-15 15:39:39 +05:30
|
|
|
import {
|
|
|
|
getDayDifference,
|
|
|
|
getTimeago,
|
|
|
|
dateInWords,
|
|
|
|
parsePikadayDate,
|
|
|
|
} from '~/lib/utils/datetime_utility';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { __ } from '~/locale';
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
GlIcon,
|
2018-12-13 13:39:08 +05:30
|
|
|
GlTooltip,
|
|
|
|
},
|
|
|
|
props: {
|
2020-04-08 14:13:33 +05:30
|
|
|
closed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
date: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
cssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
tooltipPlacement: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'bottom',
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
const timeago = getTimeago();
|
|
|
|
const { timeDifference, standardDateFormat } = this;
|
2020-01-01 13:55:28 +05:30
|
|
|
const formattedDate = standardDateFormat;
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
if (timeDifference >= -1 && timeDifference < 7) {
|
2020-01-01 13:55:28 +05:30
|
|
|
return `${timeago.format(this.issueDueDate)} (${formattedDate})`;
|
2018-12-13 13:39:08 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return timeago.format(this.issueDueDate);
|
|
|
|
},
|
|
|
|
body() {
|
|
|
|
const { timeDifference, issueDueDate, standardDateFormat } = this;
|
|
|
|
|
|
|
|
if (timeDifference === 0) {
|
|
|
|
return __('Today');
|
|
|
|
} else if (timeDifference === 1) {
|
|
|
|
return __('Tomorrow');
|
|
|
|
} else if (timeDifference === -1) {
|
|
|
|
return __('Yesterday');
|
|
|
|
} else if (timeDifference > 0 && timeDifference < 7) {
|
2019-07-07 11:18:12 +05:30
|
|
|
return dateFormat(issueDueDate, 'dddd');
|
2018-12-13 13:39:08 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return standardDateFormat;
|
|
|
|
},
|
|
|
|
issueDueDate() {
|
2019-02-15 15:39:39 +05:30
|
|
|
return parsePikadayDate(this.date);
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
timeDifference() {
|
|
|
|
const today = new Date();
|
|
|
|
return getDayDifference(today, this.issueDueDate);
|
|
|
|
},
|
|
|
|
isPastDue() {
|
2020-04-08 14:13:33 +05:30
|
|
|
if (this.timeDifference >= 0 || this.closed) return false;
|
2018-12-13 13:39:08 +05:30
|
|
|
return true;
|
|
|
|
},
|
|
|
|
standardDateFormat() {
|
|
|
|
const today = new Date();
|
|
|
|
const isDueInCurrentYear = today.getFullYear() === this.issueDueDate.getFullYear();
|
|
|
|
|
|
|
|
return dateInWords(this.issueDueDate, true, isDueInCurrentYear);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<span>
|
2022-10-11 01:57:18 +05:30
|
|
|
<span
|
|
|
|
ref="issueDueDate"
|
|
|
|
:class="cssClass"
|
|
|
|
class="board-card-info gl-mr-3 gl-text-secondary gl-cursor-help"
|
|
|
|
>
|
2021-04-17 20:07:23 +05:30
|
|
|
<gl-icon
|
|
|
|
:class="{ 'text-danger': isPastDue }"
|
|
|
|
class="board-card-info-icon gl-mr-2"
|
|
|
|
name="calendar"
|
|
|
|
/>
|
2019-02-15 15:39:39 +05:30
|
|
|
<time :class="{ 'text-danger': isPastDue }" datetime="date" class="board-card-info-text">{{
|
|
|
|
body
|
|
|
|
}}</time>
|
2018-12-13 13:39:08 +05:30
|
|
|
</span>
|
2019-02-15 15:39:39 +05:30
|
|
|
<gl-tooltip :target="() => $refs.issueDueDate" :placement="tooltipPlacement">
|
2020-04-08 14:13:33 +05:30
|
|
|
<span class="bold">{{ __('Due date') }}</span>
|
|
|
|
<br />
|
2019-02-15 15:39:39 +05:30
|
|
|
<span :class="{ 'text-danger-muted': isPastDue }">{{ title }}</span>
|
2018-12-13 13:39:08 +05:30
|
|
|
</gl-tooltip>
|
|
|
|
</span>
|
|
|
|
</template>
|