Skip to content

Commit

Permalink
Merge pull request #2924 from akvo/issue/2770-maps-form-filter
Browse files Browse the repository at this point in the history
Manage how the form filter handles submissions(connect #2770)
  • Loading branch information
valllllll2000 authored Nov 14, 2018
2 parents d153ed3 + d0f80da commit 54a32a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
24 changes: 18 additions & 6 deletions Dashboard/app/js/lib/controllers/maps-controllers-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ FLOW.MapsController = Ember.ArrayController.extend({
// first deselect others
if (!Ember.none(FLOW.router.mapsController.get('selectedMarker'))) {
if (FLOW.router.mapsController.selectedMarker.target.options.placemarkId != marker.target.options.placemarkId) {
FLOW.router.mapsController.selectedMarker.target.options.selected = false;
FLOW.router.mapsController.selectedMarker.target.setStyle({
color:'#d46f12',
fillColor:'#edb660'});
FLOW.router.mapsController.set('selectedMarker',null);
FLOW.questionAnswerControl.set('content', null); //clear answers from side bar
FLOW.router.mapsController.clearMarker();
}
}

Expand All @@ -129,6 +124,20 @@ FLOW.MapsController = Ember.ArrayController.extend({
}
},

clearMarker: function () {
if (!Ember.none(FLOW.router.mapsController.get('selectedMarker'))) {
FLOW.router.mapsController.selectedMarker.target.options.selected = false;
FLOW.router.mapsController.selectedMarker.target.setStyle({
color:'#d46f12',
fillColor:'#edb660'});
}
FLOW.router.mapsController.set('selectedMarker',null);
FLOW.questionAnswerControl.set('content', null); //clear answers from side bar
FLOW.placemarkDetailController.set('dataPoint', null); //clear details panel header
FLOW.placemarkDetailController.set('dataPointCollectionDate', null); //in case previous point's collection date is still cached
FLOW.placemarkDetailController.set('noSubmissions', false); //can't confirm absence of data if we haven't checked
},

formatDate: function(date) {
if (date && !isNaN(date.getTime())) {
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
Expand All @@ -143,6 +152,7 @@ FLOW.placemarkDetailController = Ember.ArrayController.create({
dataPoint: null,

dataPointCollectionDate: null,
noSubmissions: false,

dataPointDisplayName: function () {
return this.dataPoint && this.dataPoint.get('displayName')
Expand Down Expand Up @@ -189,9 +199,11 @@ FLOW.placemarkDetailController = Ember.ArrayController.create({
var formInstance = formInstances.filterProperty('surveyId', formId).get('firstObject');

if (formInstance) {
this.set('noSubmissions', false);
this.set('dataPointCollectionDate', formInstance.get('collectionDate'));
FLOW.questionAnswerControl.doQuestionAnswerQuery(formInstance);
} else {
this.set('noSubmissions', true);
this.set('dataPointCollectionDate', null);
}
}.observes('FLOW.surveyInstanceControl.content.isLoaded'),
Expand Down
3 changes: 1 addition & 2 deletions Dashboard/app/js/lib/views/maps/map-views-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ FLOW.NavMapsView = FLOW.View.extend({
}.observes('FLOW.selectedControl.selectedSurveyGroup'),

clearMap: function (trigger) {
FLOW.router.mapsController.set('selectedMarker',null);
FLOW.questionAnswerControl.set('content', null);
FLOW.router.mapsController.clearMarker();
this.set('detailsPaneVisible', false);
if (!Ember.empty(FLOW.router.mapsController.allPlacemarks) && trigger == "survey-selection") {
FLOW.router.mapsController.allPlacemarks.clearLayers();
Expand Down
6 changes: 4 additions & 2 deletions Dashboard/app/js/templates/navMaps/nav-maps-common.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<li></li>
</ul>
<div class="mapInfoDetail">
{{#if FLOW.placemarkDetailController.noSubmissions}}
<p class="noDetails">{{t _no_submissions_on_point}}</p>
{{else}}
{{#each responseSubList in FLOW.questionAnswerControl.contentByGroup}}
{{#each iterations in responseSubList}}
<p></p>
Expand All @@ -46,9 +49,8 @@
{{drawGeoshapes}}
{{/each}}
{{/each}}
{{else}}
<p class="noDetails">{{t _no_submissions_on_point}}</p>
{{/each}}
{{/if}}
</div>
{{else}}
<p class="noDetails">{{t _no_details}}</p>
Expand Down

0 comments on commit 54a32a2

Please sign in to comment.