Skip to content

Commit

Permalink
Always show graph filters, even if they’re unused
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Nov 25, 2018
1 parent 04b6fe9 commit 71dd990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed
- Make the dataset search search on more fields ([#93](https://github.com/pwyf/iati-decipher/issues/93) – thanks to [@matmaxgeds](https://github.com/matmaxgeds) and [@kndm](https://github.com/kndm))
- Always show graph filters, even if they’re unused ([#94](https://github.com/pwyf/iati-decipher/issues/94))

## [1.2.1] - 2018-11-15
### Fixed
Expand Down
23 changes: 11 additions & 12 deletions src/js/TimeGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,29 @@ function TimeGraph ($org, options) {
}

var breakdownCats = self.breakdownCats()
$breakdown = $('<div class="form-group col-sm-6"><label for="breakdown-select">Filter by ' + self.breakdown.name + '</label><select class="form-control" id="breakdown-select"></select></div>')
var $breakdownSelect = $('#breakdown-select', $breakdown)
if (breakdownCats.length > 0) {
$breakdown = $('<div class="form-group col-sm-6"><label for="breakdown-select">Filter by ' + self.breakdown.name + '</label><select class="form-control" id="breakdown-select"><option value="">Total across ' + self.breakdown.name + 's</option></select></div>')
var $breakdownSelect = $('#breakdown-select', $breakdown)
$breakdownSelect.append($('<option value="">Total across ' + self.breakdown.name + 's</option>'))
breakdownCats.forEach(function (item) {
$breakdownSelect.append($('<option data-value-field="' + item.valueField + '" value="' + item.attr + '">' + item.text + '</option>'))
})
$breakdownSelect.on('change', function () {
self.show()
})
} else {
$breakdownSelect.prop('disabled', 'disabled')
}

$('#main').html('')

if ($filter || $breakdown) {
var $controlForm = $('<form class="container"><div class="row"></div></form>')
var $controlRow = $('.row', $controlForm)
if ($filter) {
$controlRow.append($filter)
}
if ($breakdown) {
$controlRow.append($breakdown)
}
$('#main').append($controlForm)
var $controlForm = $('<form class="container"><div class="row"></div></form>')
var $controlRow = $('.row', $controlForm)
if ($filter) {
$controlRow.append($filter)
}
$controlRow.append($breakdown)
$('#main').append($controlForm)

$('#main').append($('<div class="container" id="chart-content"></div>'))
$('#main').append($('<div id="chart"></div>'))
Expand Down

0 comments on commit 71dd990

Please sign in to comment.