Skip to content

Commit

Permalink
Show country name instead of country id on answers to map questions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed May 21, 2019
1 parent ce272dc commit fa100f8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions client/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ var GLClient = angular.module("GLClient", [
$rootScope.submission_statuses = result.submission_statuses;

angular.forEach($rootScope.questionnaires_by_id, function(element, key) {
$rootScope.fieldUtilities.parseQuestionnaire($rootScope.questionnaires_by_id[key]);
$rootScope.questionnaires_by_id[key].steps = $filter("orderBy")($rootScope.questionnaires_by_id[key].steps, "presentation_order");
});

Expand Down
14 changes: 0 additions & 14 deletions client/app/js/controllers/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,6 @@ controller("SubmissionFormFieldCtrl", ["$scope", "fieldUtilities",
};

d3.json($scope.field.attrs.topojson.value).then(function(topojson) {
$scope.field.attrs.topojson.geojson = fieldUtilities.topoToGeo(topojson);

var projection = d3.geoMercator();
var path = d3.geoPath();

Expand Down Expand Up @@ -607,18 +605,6 @@ controller("SubmissionFormFieldCtrl", ["$scope", "fieldUtilities",
}
$scope.$apply();
});

svg.selectAll("text")
.data(topojson.features)
.enter()
.append("svg:circle")
.attr("fill", "#000").attr("r", 1.5)
.attr("cx", function(d){
return path.centroid(d)[0];
})
.attr("cy", function(d){
return path.centroid(d)[1];
});
});
}
}]).
Expand Down
2 changes: 2 additions & 0 deletions client/app/js/controllers/tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ GLClient.controller("TipCtrl",
};

$scope.preprocessTipAnswers = function(tip) {
$scope.fieldUtilities.parseQuestionnaire(tip.questionnaires[0]);

var i, j, k, step, child;
for (i=0; i<tip.questionnaires[0].steps.length; i++) {
step = tip.questionnaires[0].steps[i];
Expand Down
8 changes: 8 additions & 0 deletions client/app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,14 @@ factory("AdminUtils", ["AdminContextResource", "AdminQuestionnaireResource", "Ad
field.children.forEach(function(field) {
self.parseField(field, parsedFields);
});
} else if (field.type === "map") {
d3.json(field.attrs.topojson.value).then(function(topojson) {
field.attrs.topojson.geojson = self.topoToGeo(topojson);
field.attrs.topojson.id_name_map = {};
field.attrs.topojson.geojson.features.forEach(function(feature) {
field.attrs.topojson.id_name_map[feature.id] = feature.properties.name;
});
});
}
},

Expand Down
2 changes: 1 addition & 1 deletion client/app/views/partials/tip_field_answer_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</span>

<span data-ng-switch-when="map">{{entry['value']}}</span>
<span data-ng-switch-when="map">{{field.attrs.topojson.id_name_map[entry['value']]}}</span>

<span data-ng-switch-when="date">{{entry['value'] | date:'dd-MM-yyyy'}}</span>

Expand Down

0 comments on commit fa100f8

Please sign in to comment.