Skip to content

Commit d70893e

Browse files
committed
"10/16/24"
1 parent cff69ac commit d70893e

5 files changed

Lines changed: 49 additions & 6 deletions

File tree

src/main/java/org/launchcode/codingevents/controllers/EventController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import jakarta.validation.Valid;
44
import org.launchcode.codingevents.data.EventData;
55
import org.launchcode.codingevents.models.Event;
6+
import org.launchcode.codingevents.models.EventType;
67
import org.springframework.stereotype.Controller;
78
import org.springframework.validation.Errors;
89
import org.springframework.web.bind.annotation.*;
@@ -29,6 +30,7 @@ public String displayAllEvents(Model model) {
2930
public String displayCreateEventForm(Model model) {
3031
model.addAttribute("title", "Create Event");
3132
model.addAttribute(new Event());
33+
model.addAttribute("types", EventType.values());
3234
return "events/create";
3335
}
3436

src/main/java/org/launchcode/codingevents/models/Event.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,25 @@ public class Event {
3838
@Future(message = "Event must have a future date.")
3939
private LocalDate eventDate;
4040

41+
private EventType type;
42+
4143
public Event(String name, String description, String contactEmail,
42-
String location, int numberOfAttendees, LocalDate eventDate) {
44+
String location, int numberOfAttendees, LocalDate eventDate, EventType type) {
45+
this();
4346
this.name = name;
4447
this.description = description;
4548
this.contactEmail = contactEmail;
4649
this.location = location;
4750
this.numberOfAttendees = numberOfAttendees;
4851
this.eventDate = eventDate;
52+
this.type = type;
53+
}
54+
55+
public Event(){
4956
this.id = nextId;
5057
nextId++;
5158
}
5259

53-
public Event(){}
54-
5560
public String getName() {
5661
return name;
5762
}
@@ -112,6 +117,14 @@ public void setEventDate(LocalDate eventDate) {
112117
this.eventDate = eventDate;
113118
}
114119

120+
public EventType getType() {
121+
return type;
122+
}
123+
124+
public void setType(EventType type) {
125+
this.type = type;
126+
}
127+
115128
@Override
116129
public String toString() {
117130
return name;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.launchcode.codingevents.models;
2+
3+
public enum EventType {
4+
5+
CONFERENCE("Conference"),
6+
MEETUP("Meetup"),
7+
WORKSHOP("Workshop"),
8+
SOCIAL("Social");
9+
10+
private final String displayName;
11+
12+
EventType(String displayName) {
13+
this.displayName = displayName;
14+
}
15+
16+
public String getDisplayName() {
17+
return displayName;
18+
}
19+
}

src/main/resources/templates/events/create.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,32 @@
3838
</div>
3939
<div class="form-group">
4040
<label>Registration Required
41-
<!-- <input type="text" name="contactEmail" class="form-control">-->
4241
<input th:field="${event.registrationRequired}" class="form-control">
4342
</label>
4443
<p class="error" th:errors="${event.registrationRequired}"></p>
4544
</div>
4645
<div class="form-group">
4746
<label>Number of Attendees
48-
<!-- <input type="text" name="contactEmail" class="form-control">-->
4947
<input th:field="${event.numberOfAttendees}" class="form-control">
5048
</label>
5149
<p class="error" th:errors="${event.numberOfAttendees}"></p>
5250
</div>
5351
<div class="form-group">
5452
<label>Event Date
55-
<!-- <input type="text" name="contactEmail" class="form-control">-->
5653
<input th:field="${event.eventDate}" class="form-control">
5754
</label>
5855
<p class="error" th:errors="${event.eventDate}"></p>
5956
</div>
57+
<div class="form-group">
58+
<label>Type
59+
<select th:field="${event.type}">
60+
<option th:each="type : ${types}"
61+
th:value ="${type}"
62+
th:text="${type.displayName}"
63+
></option>
64+
</select>
65+
</label>
66+
</div>
6067
<div class="form-group">
6168
<input type="submit" value="Create" class="btn btn-success">
6269
</div>

src/main/resources/templates/events/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<th>Registration Required</th>
1717
<th>Number of Attendees</th>
1818
<th>Event Date</th>
19+
<th>Event Type</th>
1920
</tr>
2021
</thead>
2122
<tr th:each="event : ${events}">
@@ -27,6 +28,7 @@
2728
<td th:text="${event.registrationRequired}"></td>
2829
<td th:text="${event.numberOfAttendees}"></td>
2930
<td th:text="${event.eventDate}"></td>
31+
<td th:text="${event.type}"></td>
3032
</tr>
3133
</table>
3234

0 commit comments

Comments
 (0)