Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically exclude an electorate's state if it is not already in the included states list #3480

Merged
merged 4 commits into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions grails-app/assets/javascripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,27 @@ function ProjectViewModel(project) {
}
});

/**
* Automatically exclude an electorate's state if it is not already in the included states list.
*/
self.geographicInfo.otherExcludedElectorates.subscribe(function(newValue) {
// check if excluded electorates' states can also be added to exclude state
if (newValue) {
var states = findStatesElectoratesBelong(newValue);
if (!states)
return;

for (var i = 0; i < states.length; i++) {
var state = states[i],
excludeAbleStates = self.transients.states.statesToExclude();
// exclude-able states are those that are not already selected as primary or in included states lists.
if ((excludeAbleStates.indexOf(state) >= 0) && (self.geographicInfo.otherExcludedStates.indexOf(state) === -1)) {
self.geographicInfo.otherExcludedStates.push(state);
}
}
}
});

self.transients.programs = [];
self.transients.subprograms = {};
self.transients.subprogramsToDisplay = ko.computed(function () {
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/home/_projectFinder.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<g:elseif test="${results?.hits?.total?:0 > 0}">
<div class="row">
<div id="facetsCol" class="bg-white" style="display:none;">
<g:set var="reqParams" value="query,sort,order,max,fq,fromDate,toDate"/>
<g:set var="reqParams" value="query,sort,order,max,fq,fromDate,toDate,isFilterByCompletedProjects"/>
<div class="visible-phone pull-right" style="margin-top: 5px;">
<a href="#" id="toggleFacetDisplay" rel="facetsContent" role="button" class="btn btn-sm btn-inverse" style="color:white;">
<span>show</span> options&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import pages.RlpProjectPage
@Slf4j
class ImportProjectsSpec extends StubbedCasSpec {

def setup() {
def setupSpec() {
useDataSet('dataset2')
loginAsAlaAdmin(browser)
to AdminTools
clearMetadata()
to AdminClearCachePage
clearProgramListCache()
at AdminClearCachePage // reset at check time
clearServiceListCache()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,22 @@ class ProjectExplorerSpec extends StubbedCasSpec {
projects.size() == 1
}

when: "We organisation facet is selected, date option selection should remain checked"
at ProjectExplorer
organisationFacet.click()
waitFor {
organisationFacetItems.displayed
}
organisationFacetItems[0].click()

then:
dateOption.value() == "true"

when: "We clear dates"
at ProjectExplorer
waitFor {
clearDatesBtn.displayed
}
clearDatesBtn.click()

then:
Expand Down
2 changes: 2 additions & 0 deletions src/integration-test/groovy/pages/ProjectExplorer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class ProjectExplorer extends ReloadablePage {
dateOption(required: false, wait: true) { $("#isFilterByCompletedProjectsOption", dynamic: true) }
dateFacet(required: false) { $("#projectDates", dynamic: true) }
clearDatesBtn(required: false) { $("#facet-dates .clearDates", dynamic: true) }
organisationFacet(required: false) { $("#organisationFacet", dynamic: true) }
organisationFacetItems(required: false) { $("#facet-organisationFacet > div > ul > li > a", dynamic: true) }
inputText{ $("#keywords")}

dashboardContent (required: false) {$("div#dashboard-content")}
Expand Down
Loading