Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issuable_time_tracking.js « time_tracking « components « issuable « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62c05169666d3cf335f9d3f3a34ad5614b6439b7 (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
50
51
52
53
54
55
56
57
58
59
import '~/smart_interval';

import timeTracker from './time_tracker';
import eventHub from '../../event_hub';

export default {
  el: '#issuable-time-tracker',
  data() {
    const selector = this.$options.el;
    const element = document.querySelector(selector);

    const docsUrl = element.dataset.docsUrl;

    return {
      issuable: {},
      docsUrl,
    };
  },
  components: {
    'issuable-time-tracker': timeTracker,
  },
  methods: {
    fetchIssuable() {
      eventHub.$emit('fetchIssuable');
    },
    updateState(data) {
      this.issuable = data;
    },
    listenForSlashCommands() {
      $(document).on('ajax:success', '.gfm-form', (e, data) => {
        const subscribedCommands = ['spend_time', 'time_estimate'];
        const changedCommands = data.commands_changes
          ? Object.keys(data.commands_changes)
          : [];
        if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) {
          this.fetchIssuable();
        }
      });
    },
  },
  created() {
    eventHub.$on('receivedIssuable', data => this.updateState(data));
  },
  mounted() {
    this.fetchIssuable();
    this.listenForSlashCommands();
  },
  template: `
    <div class="block">
      <issuable-time-tracker
        :time_estimate="issuable.time_estimate"
        :time_spent="issuable.total_time_spent"
        :human_time_estimate="issuable.human_time_estimate"
        :human_time_spent="issuable.human_total_time_spent"
        :docs-url="docsUrl"
      />
    </div>
  `,
};