Skip to content

Commit a7e45c6

Browse files
authored
Merge pull request #3480 from AtlasOfLivingAustralia/feature/ecodata-1078
automatically exclude an electorate's state if it is not already in the included states list
2 parents a6fdc19 + 89a58e4 commit a7e45c6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

grails-app/assets/javascripts/projects.js

+21
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,27 @@ function ProjectViewModel(project) {
248248
}
249249
});
250250

251+
/**
252+
* Automatically exclude an electorate's state if it is not already in the included states list.
253+
*/
254+
self.geographicInfo.otherExcludedElectorates.subscribe(function(newValue) {
255+
// check if excluded electorates' states can also be added to exclude state
256+
if (newValue) {
257+
var states = findStatesElectoratesBelong(newValue);
258+
if (!states)
259+
return;
260+
261+
for (var i = 0; i < states.length; i++) {
262+
var state = states[i],
263+
excludeAbleStates = self.transients.states.statesToExclude();
264+
// exclude-able states are those that are not already selected as primary or in included states lists.
265+
if ((excludeAbleStates.indexOf(state) >= 0) && (self.geographicInfo.otherExcludedStates.indexOf(state) === -1)) {
266+
self.geographicInfo.otherExcludedStates.push(state);
267+
}
268+
}
269+
}
270+
});
271+
251272
self.transients.programs = [];
252273
self.transients.subprograms = {};
253274
self.transients.subprogramsToDisplay = ko.computed(function () {

0 commit comments

Comments
 (0)