summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/cycle_analytics/components/total_time_component.vue
blob: 4db50134208a95700bc572ce931a4c17a522bb47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<script>
export default {
  props: {
    time: {
      type: Object,
      required: false,
      default: () => ({}),
    },
  },
  computed: {
    hasData() {
      return Object.keys(this.time).length;
    },
  },
};
</script>
<template>
  <span class="total-time">
    <template v-if="hasData">
      <template v-if="time.days">
        {{ time.days }}
        <span>
          {{ n__('day', 'days', time.days) }}
        </span>
      </template>
      <template v-if="time.hours">
        {{ time.hours }}
        <span>
          {{ n__('Time|hr', 'Time|hrs', time.hours) }}
        </span>
      </template>
      <template v-if="time.mins && !time.days">
        {{ time.mins }}
        <span>
          {{ n__('Time|min', 'Time|mins', time.mins) }}
        </span>
      </template>
      <template v-if="time.seconds && hasData === 1 || time.seconds === 0">
        {{ time.seconds }}
        <span>
          {{ s__('Time|s') }}
        </span>
      </template>
    </template>
    <template v-else>
      --
    </template>
  </span>
</template>