Skip to content

Commit

Permalink
Fix #1088: Make DataTables search work with archived filter
Browse files Browse the repository at this point in the history
  • Loading branch information
seav authored and oliverroick committed Feb 7, 2017
1 parent 9ee55a0 commit 58c3daf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ environments.]

- [ ] **Is this PR explained thoroughly?** All code changes must be accounted for in the PR description.
- [ ] **Is the PR labeled correctly?** It should have the `migration` label if a new migration is added.
**Is the risk level assessment sufficient?** The risks section should contain all risks that might be introduced with the PR and which actions we need to take to mitigate these risks. Possible risks are database migrations, new libraries that need to be installed or changes to deployment scripts.
- [ ] **Is the risk level assessment sufficient?** The risks section should contain all risks that might be introduced with the PR and which actions we need to take to mitigate these risks. Possible risks are database migrations, new libraries that need to be installed or changes to deployment scripts.

#### Functionality

Expand Down
11 changes: 7 additions & 4 deletions cadasta/core/static/js/dataTables.selectFiltering.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
(function(window, document, $) {
$(document).on('init.dt', function(e, dtSettings) {
$(document).on('init.dt', function(e) {

if ( e.namespace !== 'dt' ) {
return;
Expand All @@ -12,11 +12,14 @@
{ value: 'archived-True' , label: gettext('Archived') },
{ value: '' , label: gettext('All' ) },
];
var html = '<label><select class="form-control input-sm" id="archive-filter">';
var html = '<select class="form-control input-sm" id="archive-filter">';
for (var i = 0; i < options.length; i++) {
html += '<option value="' + options[i].value + '">' + options[i].label + '</option>';
}
return html + '</select></label>';
html += '</select>';
var selectOptions = document.createElement('label');
selectOptions.innerHTML = html;
return selectOptions;
}

// When there are archived objects
Expand All @@ -30,7 +33,7 @@
if (hasArchived) {

// Add archived filter select field
dtSettings.nTableWrapper.childNodes[0].childNodes[0].innerHTML += addSelectOptions()
$('.dataTables_filter')[0].appendChild(addSelectOptions());

// Register custom DataTables search function for the archived filter field
$.fn.dataTable.ext.search.push(
Expand Down

0 comments on commit 58c3daf

Please sign in to comment.