-
Notifications
You must be signed in to change notification settings - Fork 31
Feature/handle proxy #756
Feature/handle proxy #756
Changes from all commits
24d72a7
3332e7f
dba84e5
efeed05
05b3a8d
ba202c4
743058e
a942329
ac7ea87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
var _ = require('underscore'); | ||
|
||
var tables = require('./tables'); | ||
var helpers = require('./helpers'); | ||
var decoders = require('./decoders'); | ||
|
||
var sizeInfo = { | ||
|
@@ -42,11 +43,19 @@ var filings = { | |
className: 'all', | ||
orderable: false, | ||
render: function(data, type, row, meta) { | ||
var cycle = tables.buildCycle(row); | ||
var cycle = tables.getCycle(row); | ||
if (row.candidate_name) { | ||
return tables.buildEntityLink(row.candidate_name, '/candidate/' + row.candidate_id + cycle, 'candidate'); | ||
return tables.buildEntityLink( | ||
row.candidate_name, | ||
helpers.buildAppUrl(['candidate', row.candidate_id], cycle), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identifier 'candidate_id' is not in camel case. |
||
'candidate' | ||
); | ||
} else if (row.committee_name) { | ||
return tables.buildEntityLink(row.committee_name, '/committee/' + row.committee_id + cycle, 'committee'); | ||
return tables.buildEntityLink( | ||
row.committee_name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identifier 'committee_name' is not in camel case. |
||
helpers.buildAppUrl(['committee', row.committee_id], cycle), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identifier 'committee_id' is not in camel case. |
||
'committee' | ||
); | ||
} else { | ||
return ''; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
/* global require, module, Intl, API_LOCATION, API_VERSION, API_KEY */ | ||
/* global require, module, Intl, BASE_PATH, API_LOCATION, API_VERSION, API_KEY */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
|
||
var URI = require('URIjs'); | ||
var _ = require('underscore'); | ||
|
@@ -26,6 +26,8 @@ function datetime(value) { | |
} | ||
Handlebars.registerHelper('datetime', datetime); | ||
|
||
Handlebars.registerHelper('basePath', BASE_PATH); | ||
|
||
function cycleDates(year) { | ||
return { | ||
min: '01-01-' + (year - 1), | ||
|
@@ -43,6 +45,13 @@ function filterNull(params) { | |
.value(); | ||
} | ||
|
||
function buildAppUrl(path, query) { | ||
return URI() | ||
.path(Array.prototype.concat(BASE_PATH, path || [], '').join('/')) | ||
.addQuery(query || {}) | ||
.toString(); | ||
} | ||
|
||
function buildUrl(path, query) { | ||
return URI(API_LOCATION) | ||
.path(Array.prototype.concat(API_VERSION, path, '').join('/')) | ||
|
@@ -56,5 +65,6 @@ module.exports = { | |
datetime: datetime, | ||
cycleDates: cycleDates, | ||
filterNull: filterNull, | ||
buildAppUrl: buildAppUrl, | ||
buildUrl: buildUrl | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,15 +68,15 @@ function mapFilters(filters) { | |
|
||
var parsedFilters; | ||
|
||
function buildCycle(datum) { | ||
function getCycle(datum) { | ||
if (parsedFilters && parsedFilters.cycle) { | ||
var cycles = _.intersection( | ||
_.map(parsedFilters.cycle, function(cycle) {return parseInt(cycle);}), | ||
datum.cycles | ||
); | ||
return '?cycle=' + _.max(cycles); | ||
return {cycle: _.max(cycles)}; | ||
} else { | ||
return ''; | ||
return {}; | ||
} | ||
} | ||
|
||
|
@@ -172,15 +172,15 @@ var barCurrencyColumn = barColumn(helpers.currency); | |
|
||
var candidateColumn = formattedColumn(function(data) { | ||
if (data) { | ||
return buildEntityLink(data.name, '/candidate/' + data.candidate_id, 'candidate'); | ||
return buildEntityLink(data.name, helpers.buildAppUrl(['candidate', data.candidate_id]), 'candidate'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
} else { | ||
return ''; | ||
} | ||
}); | ||
|
||
var committeeColumn = formattedColumn(function(data) { | ||
if (data) { | ||
return buildEntityLink(data.name, '/committee/' + data.committee_id, 'committee'); | ||
return buildEntityLink(data.name, helpers.buildAppUrl(['committee', data.committee_id]), 'committee'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
} else { | ||
return ''; | ||
} | ||
|
@@ -497,7 +497,7 @@ var seekCallbacks = { | |
module.exports = { | ||
simpleDOM: simpleDOM, | ||
yearRange: yearRange, | ||
buildCycle: buildCycle, | ||
getCycle: getCycle, | ||
buildAggregateUrl: buildAggregateUrl, | ||
buildTotalLink: buildTotalLink, | ||
buildEntityLink: buildEntityLink, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var $ = require('jquery'); | |
var _ = require('underscore'); | ||
|
||
var tables = require('../modules/tables'); | ||
var helpers = require('../modules/helpers'); | ||
var candidatesTemplate = require('../../templates/candidates.hbs'); | ||
|
||
var columns = [ | ||
|
@@ -16,7 +17,7 @@ var columns = [ | |
render: function(data, type, row, meta) { | ||
return tables.buildEntityLink( | ||
data, | ||
'/candidate/' + row.candidate_id + tables.buildCycle(row), | ||
helpers.buildAppUrl(['candidate', row.candidate_id], tables.getCycle(row)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
'candidate' | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var $ = require('jquery'); | |
var _ = require('underscore'); | ||
|
||
var tables = require('../modules/tables'); | ||
var helpers = require('../modules/helpers'); | ||
var committeesTemplate = require('../../templates/committees.hbs'); | ||
|
||
var columns = [ | ||
|
@@ -14,7 +15,11 @@ var columns = [ | |
className: 'all', | ||
width: '280px', | ||
render: function(data, type, row, meta) { | ||
return tables.buildEntityLink(data, '/committee/' + row.committee_id + tables.buildCycle(row), 'committee'); | ||
return tables.buildEntityLink( | ||
data, | ||
helpers.buildAppUrl(['committee', row.committee_id], tables.getCycle(row)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
'committee' | ||
); | ||
} | ||
}, | ||
{data: 'treasurer_name', className: 'min-desktop hide-panel'}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier 'candidate_name' is not in camel case.