Commit 9f6660b1 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'refactor-graphs-bundle' into 'master'

Refactor graphs bundle to ES module syntax

See merge request !9502
parents c49ee361 52426c65
require('./stat_graph_contributors_graph');
require('./stat_graph_contributors_util');
require('./stat_graph_contributors');
require('./stat_graph');
import ContributorsStatGraph from './stat_graph_contributors';
// export to global scope
window.ContributorsStatGraph = ContributorsStatGraph;
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-return-assign, max-len */
(function() {
this.StatGraph = (function() {
function StatGraph() {}
StatGraph.log = {};
StatGraph.get_log = function() {
return this.log;
};
StatGraph.set_log = function(data) {
return this.log = data;
};
return StatGraph;
})();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign */
/* global ContributorsGraph */
/* global ContributorsAuthorGraph */
/* global ContributorsMasterGraph */
/* global ContributorsStatGraphUtil */
/* global d3 */
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign, no-shadow */
window.d3 = require('d3');
import d3 from 'd3';
import { ContributorsGraph, ContributorsAuthorGraph, ContributorsMasterGraph } from './stat_graph_contributors_graph';
import ContributorsStatGraphUtil from './stat_graph_contributors_util';
(function() {
this.ContributorsStatGraph = (function() {
export default (function() {
function ContributorsStatGraph() {}
ContributorsStatGraph.prototype.init = function(log) {
......@@ -112,5 +108,4 @@ window.d3 = require('d3');
};
return ContributorsStatGraph;
})();
}).call(window);
})();
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return */
/* global d3 */
/* global ContributorsGraph */
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return, no-shadow */
window.d3 = require('d3');
import d3 from 'd3';
(function() {
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
const bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
const extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
const hasProp = {}.hasOwnProperty;
this.ContributorsGraph = (function() {
export const ContributorsGraph = (function() {
function ContributorsGraph() {}
ContributorsGraph.prototype.MARGIN = {
......@@ -91,9 +88,9 @@ window.d3 = require('d3');
};
return ContributorsGraph;
})();
})();
this.ContributorsMasterGraph = (function(superClass) {
export const ContributorsMasterGraph = (function(superClass) {
extend(ContributorsMasterGraph, superClass);
function ContributorsMasterGraph(data1) {
......@@ -195,9 +192,9 @@ window.d3 = require('d3');
};
return ContributorsMasterGraph;
})(ContributorsGraph);
})(ContributorsGraph);
this.ContributorsAuthorGraph = (function(superClass) {
export const ContributorsAuthorGraph = (function(superClass) {
extend(ContributorsAuthorGraph, superClass);
function ContributorsAuthorGraph(data1) {
......@@ -272,5 +269,4 @@ window.d3 = require('d3');
};
return ContributorsAuthorGraph;
})(ContributorsGraph);
}).call(window);
})(ContributorsGraph);
/* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */
(function() {
window.ContributorsStatGraphUtil = {
export default {
parse_log: function(log) {
var by_author, by_email, data, entry, i, len, total, normalized_email;
total = {};
......@@ -134,5 +134,4 @@
return false;
}
}
};
}).call(window);
};
/* eslint-disable quotes, jasmine/no-suite-dupes, vars-on-top, no-var, max-len */
/* global d3 */
/* global ContributorsGraph */
/* global ContributorsMasterGraph */
/* eslint-disable quotes, jasmine/no-suite-dupes, vars-on-top, no-var */
require('~/graphs/stat_graph_contributors_graph');
import d3 from 'd3';
import { ContributorsGraph, ContributorsMasterGraph } from '~/graphs/stat_graph_contributors_graph';
describe("ContributorsGraph", function () {
describe("#set_x_domain", function () {
......
/* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */
/* global ContributorsStatGraphUtil */
require('~/graphs/stat_graph_contributors_util');
import ContributorsStatGraphUtil from '~/graphs/stat_graph_contributors_util';
describe("ContributorsStatGraphUtil", function () {
describe("#parse_log", function () {
......
/* eslint-disable quotes */
/* global StatGraph */
require('~/graphs/stat_graph');
describe("StatGraph", function () {
describe("#get_log", function () {
it("returns log", function () {
StatGraph.log = "test";
expect(StatGraph.get_log()).toBe("test");
});
});
describe("#set_log", function () {
it("sets the log", function () {
StatGraph.set_log("test");
expect(StatGraph.log).toBe("test");
});
});
});
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