Skip to content

Commit

Permalink
🐞 Adding a voter with not required auth extra fields doesn't work (#405
Browse files Browse the repository at this point in the history
…) (#406)

Parent issue: sequentech/meta#277
  • Loading branch information
edulix authored Nov 6, 2023
1 parent bc73283 commit de01a49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 1 addition & 6 deletions avAdmin/admin-directives/elcensus/add-person-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ angular.module('avAdmin')
for (var i = 0; i < election.census.extra_fields.length; i++) {
var field = election.census.extra_fields[i];
if(!newcensus.hasOwnProperty(field.name)) {
if(
('tlf' === field.name) ||
('email' === field.name && field.type === 'email')
) {
newcensus[field.name] = "";
} else if (field.type === 'date') {
if (field.type === 'date') {
newcensus[field.name] = field.value;
}
} else {
Expand Down
11 changes: 10 additions & 1 deletion avAdmin/csv-load-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ angular.module('avAdmin')
var censusElement = {};
fields.forEach(
function(field, index) {
if (splittedLine.length <= index) {
return;
}
var value = splittedLine[index].trim();
if (value.length === 0) {
return;
}
if (field.type === 'int') {
value = parseInt(value, 10);
}
Expand All @@ -64,7 +70,10 @@ angular.module('avAdmin')
censusElement.children_event_id_list = _.filter(
csvLoadService.scope.election.children_election_info.natural_order,
function (electionId, index) {
return splittedLine[fields.length + index].trim().toLowerCase() === "true";
return (
splittedLine.length >= fields.length + index &&
splittedLine[fields.length + index].trim().toLowerCase() === "true"
);
}
);
}
Expand Down

0 comments on commit de01a49

Please sign in to comment.