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

Shush eslint.

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