debian-mirror-gitlab/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue

139 lines
3.9 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2018-10-15 14:42:47 +05:30
import TimeTrackingHelpState from './help_state.vue';
2018-05-09 12:01:36 +05:30
import TimeTrackingCollapsedState from './collapsed_state.vue';
2018-10-15 14:42:47 +05:30
import TimeTrackingSpentOnlyPane from './spent_only_pane.vue';
import TimeTrackingNoTrackingPane from './no_tracking_pane.vue';
import TimeTrackingEstimateOnlyPane from './estimate_only_pane.vue';
2018-05-09 12:01:36 +05:30
import TimeTrackingComparisonPane from './comparison_pane.vue';
2017-08-17 22:00:37 +05:30
import eventHub from '../../event_hub';
export default {
2018-03-27 19:54:05 +05:30
name: 'IssuableTimeTracker',
components: {
2018-05-09 12:01:36 +05:30
TimeTrackingCollapsedState,
2018-10-15 14:42:47 +05:30
TimeTrackingEstimateOnlyPane,
TimeTrackingSpentOnlyPane,
TimeTrackingNoTrackingPane,
2018-05-09 12:01:36 +05:30
TimeTrackingComparisonPane,
2018-10-15 14:42:47 +05:30
TimeTrackingHelpState,
2018-03-27 19:54:05 +05:30
},
2017-08-17 22:00:37 +05:30
props: {
2018-12-05 23:21:45 +05:30
timeEstimate: {
2017-08-17 22:00:37 +05:30
type: Number,
required: true,
},
2018-12-05 23:21:45 +05:30
timeSpent: {
2017-08-17 22:00:37 +05:30
type: Number,
required: true,
},
2018-12-05 23:21:45 +05:30
humanTimeEstimate: {
2017-08-17 22:00:37 +05:30
type: String,
required: false,
default: '',
},
2018-12-05 23:21:45 +05:30
humanTimeSpent: {
2017-08-17 22:00:37 +05:30
type: String,
required: false,
default: '',
},
rootPath: {
type: String,
required: true,
},
},
data() {
return {
showHelp: false,
};
},
computed: {
hasTimeSpent() {
return !!this.timeSpent;
},
hasTimeEstimate() {
return !!this.timeEstimate;
},
showComparisonState() {
return this.hasTimeEstimate && this.hasTimeSpent;
},
showEstimateOnlyState() {
return this.hasTimeEstimate && !this.hasTimeSpent;
},
showSpentOnlyState() {
return this.hasTimeSpent && !this.hasTimeEstimate;
},
showNoTimeTrackingState() {
return !this.hasTimeEstimate && !this.hasTimeSpent;
},
showHelpState() {
return !!this.showHelp;
},
},
2018-03-27 19:54:05 +05:30
created() {
eventHub.$on('timeTracker:updateData', this.update);
},
2017-08-17 22:00:37 +05:30
methods: {
toggleHelpState(show) {
this.showHelp = show;
},
update(data) {
2018-12-05 23:21:45 +05:30
const { timeEstimate, timeSpent, humanTimeEstimate, humanTimeSpent } = data;
this.timeEstimate = timeEstimate;
this.timeSpent = timeSpent;
this.humanTimeEstimate = humanTimeEstimate;
this.humanTimeSpent = humanTimeSpent;
2017-08-17 22:00:37 +05:30
},
},
2018-03-27 19:54:05 +05:30
};
</script>
<template>
2018-12-23 12:14:25 +05:30
<div v-cloak class="time_tracker time-tracking-component-wrap">
2018-03-27 19:54:05 +05:30
<time-tracking-collapsed-state
:show-comparison-state="showComparisonState"
:show-no-time-tracking-state="showNoTimeTrackingState"
:show-help-state="showHelpState"
:show-spent-only-state="showSpentOnlyState"
:show-estimate-only-state="showEstimateOnlyState"
2018-12-05 23:21:45 +05:30
:time-spent-human-readable="humanTimeSpent"
:time-estimate-human-readable="humanTimeEstimate"
2018-03-27 19:54:05 +05:30
/>
<div class="title hide-collapsed">
{{ __('Time tracking') }}
2018-12-23 12:14:25 +05:30
<div v-if="!showHelpState" class="help-button float-right" @click="toggleHelpState(true);">
<i class="fa fa-question-circle" aria-hidden="true"> </i>
2018-03-27 19:54:05 +05:30
</div>
<div
v-if="showHelpState"
2018-11-08 19:23:39 +05:30
class="close-help-button float-right"
2018-12-23 12:14:25 +05:30
@click="toggleHelpState(false);"
2018-03-27 19:54:05 +05:30
>
2018-12-23 12:14:25 +05:30
<i class="fa fa-close" aria-hidden="true"> </i>
2018-03-27 19:54:05 +05:30
</div>
</div>
<div class="time-tracking-content hide-collapsed">
<time-tracking-estimate-only-pane
v-if="showEstimateOnlyState"
2018-12-05 23:21:45 +05:30
:time-estimate-human-readable="humanTimeEstimate"
2018-03-27 19:54:05 +05:30
/>
<time-tracking-spent-only-pane
v-if="showSpentOnlyState"
2018-12-05 23:21:45 +05:30
:time-spent-human-readable="humanTimeSpent"
2018-03-27 19:54:05 +05:30
/>
2018-12-23 12:14:25 +05:30
<time-tracking-no-tracking-pane v-if="showNoTimeTrackingState" />
2018-03-27 19:54:05 +05:30
<time-tracking-comparison-pane
v-if="showComparisonState"
:time-estimate="timeEstimate"
:time-spent="timeSpent"
2018-12-05 23:21:45 +05:30
:time-spent-human-readable="humanTimeSpent"
:time-estimate-human-readable="humanTimeEstimate"
2017-08-17 22:00:37 +05:30
/>
2018-03-27 19:54:05 +05:30
<transition name="help-state-toggle">
2018-12-23 12:14:25 +05:30
<time-tracking-help-state v-if="showHelpState" :root-path="rootPath" />
2018-03-27 19:54:05 +05:30
</transition>
2017-08-17 22:00:37 +05:30
</div>
2018-03-27 19:54:05 +05:30
</div>
</template>