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

sidebar_time_tracking.js « time_tracking « components « sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e2dba1fb0c2e79cdf56faf92fb54974d36c134ee (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
import '~/smart_interval';

import timeTracker from './time_tracker';

import Store from '../../stores/sidebar_store';
import Mediator from '../../sidebar_mediator';

export default {
  data() {
    return {
      mediator: new Mediator(),
      store: new Store(),
    };
  },
  components: {
    'issuable-time-tracker': timeTracker,
  },
  methods: {
    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.mediator.fetch();
        }
      });
    },
  },
  mounted() {
    this.listenForSlashCommands();
  },
  template: `
    <div class="block">
      <issuable-time-tracker
        :time_estimate="store.timeEstimate"
        :time_spent="store.totalTimeSpent"
        :human_time_estimate="store.humanTimeEstimate"
        :human_time_spent="store.humanTotalTimeSpent"
        :rootPath="store.rootPath"
      />
    </div>
  `,
};