Skip to content

Commit

Permalink
alfio-event#549 - Retrieve fields as a map (object in angularJS) and…
Browse files Browse the repository at this point in the history
… iterate over the object to display fields
  • Loading branch information
Nassim Bounouas committed Dec 1, 2018
1 parent f257f19 commit 262f3d1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ public ResponseEntity<Map<String, Object>> restoreSubscriber(@PathVariable("even
}

@RequestMapping("/fields")
public List<SerializablePair<String, String>> getAllFields(@PathVariable("eventName") String eventName) {
List<SerializablePair<String, String>> fields = new ArrayList<>();
fields.addAll(WaitingQueueDownloader.availableFields().stream().map(f -> SerializablePair.of(f, f)).collect(toList()));
return fields;
public Map<String, String> getAllFields(@PathVariable("eventName") String eventName) {
return new WaitingQueueDownloader().availableFields();
}

private Event loadEvent(String eventName, Principal principal) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package alfio.controller.api.admin;

import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

public class WaitingQueueDownloader {
private static final List<String> FIXED_FIELDS = Arrays.asList("ID", "Creation", "Event", "Status", "Full Name", "First Name", "Last Name", "E-Mail", "Ticket Reservation Id", "Language", "Selected category", "Subscription type");
private Map<String, String> map;

public static List<String> availableFields() {
return FIXED_FIELDS;
public WaitingQueueDownloader() {
map = new HashMap<>();
map.put("id", "ID");
map.put("creation", "Creation");
map.put("event", "Event");
map.put("status", "Status");
map.put("fullname", "Full Name");
map.put("firstname", "First Name");
map.put("lastname", "Last Name");
map.put("email", "E-Mail");
map.put("ticket_reservation_id", "Ticket Reservation Id");
map.put("language", "Language");
map.put("selected_category", "Selected category");
map.put("subscription_type", "Subscription type");
}

public Map<String, String> availableFields() {
return this.map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h3>Download waiting queue : select fields</h3>
</div>
<div class="modal-body">
<ul style="list-style-type:none;padding:0">
<li data-ng-repeat="field in fields"><label><input type="checkbox" ng-model="selected[field.key]"> {{field.value}}</label></li>
<li data-ng-repeat="(key, value) in fields"><label><input type="checkbox" ng-model="selected[key]">{{value}}</label></li>
</ul>
<hr>
<p>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/resources/js/admin/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@
$scope.format = 'excel';
service.getWaitingQueueFields(event.shortName).then(function(fields) {
$scope.fields = fields.data;
angular.forEach(fields.data, function(v) {
$scope.selected[v.key] = false;
angular.forEach(fields.data, function(key, value) {
$scope.selected[key] = false;
})
});

Expand Down

0 comments on commit 262f3d1

Please sign in to comment.