All files / ee/app/assets/javascripts/burndown_chart/components open_timebox_summary.vue

41.66% Statements 5/12
0% Branches 0/1
54.54% Functions 6/11
45.45% Lines 5/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101        6x                                                                                       1x                                   1x                               1x                   1x                
<script>
import { WORKSPACE_GROUP, WORKSPACE_PROJECT } from '~/issues/constants';
import { __ } from '~/locale';
import { unit } from '../constants';
import summaryStatsQuery from '../graphql/iteration_issues_summary.query.graphql';
 
export default {
  apollo: {
    issues: {
      query: summaryStatsQuery,
      variables() {
        return this.queryVariables;
      },
      update(data) {
        return {
          open: data[this.namespaceType]?.openIssues?.[this.displayValue] || 0,
          assigned: data[this.namespaceType]?.assignedIssues?.[this.displayValue] || 0,
          closed: data[this.namespaceType]?.closedIssues?.[this.displayValue] || 0,
        };
      },
      error() {
        this.error = __('Error loading issues');
      },
    },
  },
  props: {
    fullPath: {
      type: String,
      required: true,
    },
    iterationId: {
      type: String,
      required: true,
    },
    namespaceType: {
      type: String,
      required: false,
      default: WORKSPACE_GROUP,
      validator: (value) => [WORKSPACE_GROUP, WORKSPACE_PROJECT].includes(value),
    },
    displayValue: {
      type: String,
      required: false,
      default: unit.count,
      validator: (val) => unit[val],
    },
  },
  data() {
    return {
      issues: {
        assigned: 0,
        open: 0,
        closed: 0,
      },
    };
  },
  computed: {
    queryVariables() {
      return {
        fullPath: this.fullPath,
        id: this.iterationId,
        isGroup: this.namespaceType === WORKSPACE_GROUP,
        weight: this.displayValue === unit.weight,
      };
    },
    columns() {
      return [
        {
          title: __('Completed'),
          value: this.issues.closed,
        },
        {
          title: __('Incomplete'),
          value: this.issues.assigned,
        },
        {
          title: __('Unstarted'),
          value: this.issues.open,
        },
      ];
    },
    total() {
      return this.issues.open + this.issues.assigned + this.issues.closed;
    },
  },
  methods: {
    percent(val) {
      Iif (!this.total) return 0;
      return ((val / this.total) * 100).toFixed(0);
    },
  },
  render() {
    return this.$scopedSlots.default({
      columns: this.columns,
      loading: this.$apollo.queries.issues.loading,
      total: this.total,
    });
  },
};
</script>