From f35c4ff3f54b8c7c5b43f1760a94c5c97cb7e809 Mon Sep 17 00:00:00 2001 From: Eugene Alvin Villar Date: Tue, 7 Feb 2017 17:52:53 +0800 Subject: [PATCH] Fix #1088: Make DataTables search work with archived filter (#1089) --- .github/PULL_REQUEST_TEMPLATE | 2 +- cadasta/core/static/js/dataTables.selectFiltering.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 45a18a653..b8352d78f 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -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 diff --git a/cadasta/core/static/js/dataTables.selectFiltering.js b/cadasta/core/static/js/dataTables.selectFiltering.js index 22cb283ae..92b212622 100644 --- a/cadasta/core/static/js/dataTables.selectFiltering.js +++ b/cadasta/core/static/js/dataTables.selectFiltering.js @@ -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; @@ -12,11 +12,14 @@ { value: 'archived-True' , label: gettext('Archived') }, { value: '' , label: gettext('All' ) }, ]; - var html = ''; + html += ''; + var selectOptions = document.createElement('label'); + selectOptions.innerHTML = html; + return selectOptions; } // When there are archived objects @@ -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(