debian-mirror-gitlab/app/assets/javascripts/cycle_analytics/components/total_time.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.2 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2021-10-27 15:23:28 +05:30
import { n__, s__ } from '~/locale';
2018-12-13 13:39:08 +05:30
export default {
props: {
time: {
type: Object,
required: false,
default: () => ({}),
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
computed: {
hasData() {
return Object.keys(this.time).length;
2018-03-17 18:26:18 +05:30
},
2021-10-27 15:23:28 +05:30
calculatedTime() {
const {
time: { days = null, mins = null, hours = null, seconds = null },
} = this;
if (days) {
return {
duration: days,
units: n__('day', 'days', days),
};
}
if (hours) {
return {
duration: hours,
units: n__('Time|hr', 'Time|hrs', hours),
};
}
if (mins && !days) {
return {
duration: mins,
units: n__('Time|min', 'Time|mins', mins),
};
}
if ((seconds && this.hasData === 1) || seconds === 0) {
return {
duration: seconds,
units: s__('Time|s'),
};
}
return { duration: null, units: null };
},
2018-12-13 13:39:08 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<span class="total-time">
<template v-if="hasData">
2021-10-27 15:23:28 +05:30
{{ calculatedTime.duration }} <span>{{ calculatedTime.units }}</span>
2018-03-17 18:26:18 +05:30
</template>
2021-03-08 18:12:59 +05:30
<template v-else> -- </template>
2018-03-17 18:26:18 +05:30
</span>
</template>