Commit 2518af49 authored by Bryce Johnson's avatar Bryce Johnson

Shush eslint.

parent 50b16e78
//= require vue
((global) => {
(() => {
/**
* This directive ensures the text used to populate a Bootstrap tooltip is
* updated dynamically. The tooltip's `title` is not stored or accessed
......@@ -16,5 +15,4 @@
el.setAttribute('data-original-title', updatedValue);
},
});
})(window.gl || (window.gl = {}));
//= vue
((global) => {
(() => {
gl.IssuableTimeTracker = Vue.component('issuable-time-tracker', {
name: 'issuable-time-tracker',
props: [ 'time_estimate', 'time_spent', 'human_time_estimate', 'human_time_spent' ],
data: function() {
props: ['time_estimate', 'time_spent', 'human_time_estimate', 'human_time_spent'],
data() {
return {
displayHelp: false,
}
};
},
computed: {
/* Select panels to show */
......@@ -55,33 +55,32 @@
},
/* Diff values for comparison meter */
diffMinutes () {
const time_estimate = this.time_estimate;
const time_spent = this.time_spent;
return time_estimate - time_spent;
diffMinutes() {
return this.time_estimate - this.time_spent;
},
diffPercent() {
const estimate = this.time_estimate;
return Math.floor((this.time_spent / this.time_estimate * 100)) + '%';
return `${Math.floor(((this.time_spent / this.time_estimate) * 100))}%`;
},
diffStatusClass() {
return this.time_estimate >= this.time_spent ? 'within_estimate' : 'over_estimate';
}
},
},
methods: {
secondsToMinutes(seconds) {
return Math.abs(seconds / 60);
},
parseSeconds (seconds) {
const DAYS_PER_WEEK = 5, HOURS_PER_DAY = 8, MINUTES_PER_HOUR = 60;
const MINUTES_PER_WEEK = DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR;
parseSeconds(seconds) {
const DAYS_PER_WEEK = 5;
const HOURS_PER_DAY = 8;
const MINUTES_PER_HOUR = 60;
const MINUTES_PER_WEEK = DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR;
const MINUTES_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR;
const timePeriodConstraints = {
weeks: MINUTES_PER_WEEK,
days: MINUTES_PER_DAY,
hours: MINUTES_PER_HOUR,
minutes: 1
minutes: 1,
};
let unorderedMinutes = this.secondsToMinutes(seconds);
......@@ -104,7 +103,7 @@
stringifyTime(obj) {
const reducedTime = _.reduce(obj, (memo, unitValue, unitName) => {
const isNonZero = !!unitValue;
return isNonZero ? (memo + `${unitValue}${unitName.charAt(0)} `) : memo;
return isNonZero ? `${memo} ${unitValue}${unitName.charAt(0)} ` : memo;
}, '').trim();
return reducedTime.length ? reducedTime : '0m';
},
......
......@@ -13,7 +13,7 @@
* @param { integer } incrementByFactorOf `currentInterval` is incremented by this factor
* @param { boolean } lazyStart Configure if timer is initialized on instantiation or lazily
*/
constructor({ callback, startingInterval, maxInterval, incrementByFactorOf, lazyStart = false }) {
constructor({ callback, startingInterval, maxInterval, incrementByFactorOf, lazyStart }) {
this.cfg = {
callback,
startingInterval,
......@@ -84,8 +84,6 @@
}
initVisibilityChangeHandling() {
const cfg = this.cfg;
// cancel interval when tab no longer shown (prevents cached pages from polling)
$(document)
.off('visibilitychange').on('visibilitychange', (e) => {
......@@ -95,8 +93,6 @@
}
initPageUnloadHandling() {
const cfg = this.cfg;
// prevent interval continuing after page change, when kept in cache by Turbolinks
$(document).on('page:before-unload', () => this.cancel());
}
......
//= require vue
//= require vue-resource
((global) => {
(() => {
/*
* SubbableResource can be extended to provide a pubsub-style service for one-off REST
* calls. Subscribe by passing a callback or render method you will use to handle responses.
......@@ -11,6 +11,7 @@
class SubbableResource {
constructor(resourcePath) {
this.endpoint = resourcePath;
// TODO: Switch to axios.create
this.resource = $.ajax;
this.subscribers = [];
......@@ -28,23 +29,23 @@
return newResponse;
}
get(data) {
return this.resource(data)
get(payload) {
return this.resource(payload)
.then(data => this.publish(data));
}
post(data) {
return this.resource(data)
post(payload) {
return this.resource(payload)
.then(data => this.publish(data));
}
put(data) {
return this.resource(data)
put(payload) {
return this.resource(payload)
.then(data => this.publish(data));
}
delete(data) {
return this.resource(data)
delete(payload) {
return this.resource(payload)
.then(data => this.publish(data));
}
}
......
......@@ -3,7 +3,7 @@
//= smart_interval
//= subbable_resource
((global) => {
(() => {
/* This Vue instance represents what will become the parent instance for the
* sidebar. It will be responsible for managing `issuable` state and propagating
* changes to sidebar components.
......@@ -16,17 +16,17 @@
}
initComponent(parsedIssuable) {
return new Vue({
this.parentInstance = new Vue({
el: '#issuable-time-tracker',
data: {
issuable: parsedIssuable,
},
methods: {
fetchIssuable() {
return gl.IssuableResource.get.call(gl.IssuableResource, { type: 'GET', url: gl.IssuableResource.endpoint });
return gl.IssuableResource.get.call(gl.IssuableResource, { type: 'GET', url: gl.IssuableResource.endpoint });
},
initPolling() {
new gl.SmartInterval({
return new gl.SmartInterval({
callback: this.fetchIssuable,
startingInterval: 5000,
maxInterval: 20000,
......@@ -41,7 +41,7 @@
gl.IssuableResource.subscribe(data => this.updateState(data));
},
listenForSlashCommands() {
$(document).on('ajax:success', '.gfm-form', (e) => {
$(document).on('ajax:success', '.gfm-form', () => {
// TODO: check for slash command
this.fetchIssuable();
});
......@@ -54,7 +54,7 @@
this.initPolling();
this.subscribeToUpdates();
this.listenForSlashCommands();
}
},
});
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment