Skip to content

Commit

Permalink
Merge pull request #49 from ctco-dev/timepicker
Browse files Browse the repository at this point in the history
#38 Timepicker field
  • Loading branch information
St-Filer authored Aug 30, 2018
2 parents a889743 + d8bb9c0 commit 9879ceb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public EventDto getEventById(@PathParam("id") Long id) throws IllegalArgumentExc
Optional<Event> event = eventStore.getEventById(id);
if (event.isPresent()) {
Event e = event.get();
return new EventDto(e.getName(), e.getDescription(), e.getDate(), e.getId(), e.getAgenda());
return new EventDto(e.getName(), e.getDescription(), e.getDate(), e.getTime(), e.getId(), e.getAgenda());
} else {
throw new EntityNotFoundException();
}
Expand All @@ -80,7 +80,7 @@ public List<EventDto> getAllAuthorEvents() {
List<Event> event = eventStore.getAuthorEvents(userStore.getCurrentUser());

return event.stream()
.map(e -> new EventDto(e.getName(), e.getDescription(), e.getDate(), e.getId(), e.getAgenda()))
.map(e -> new EventDto(e.getName(), e.getDescription(), e.getDate(), e.getTime(), e.getId(), e.getAgenda()))
.collect(Collectors.toList());
}
}
27 changes: 21 additions & 6 deletions src/main/java/lv/ctco/javaschool/eventorganaizer/entity/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import java.util.Date;

@Entity
public class Event {
Expand All @@ -20,20 +21,25 @@ public class Event {

private String date;

private String time;

private String description;

private String agenda;

private EventStatus status;

public Event(String name, User author, String description, String agenda, String date) {
public Event(String name, User author, String description, String agenda, String date, String time) {
this.name = name;
this.author = author;
this.description = description;
this.agenda = agenda;
this.date = date;
this.time = time;
this.status = EventStatus.OPEN;
}

public Event() {
}

public EventStatus getStatus() {
Expand All @@ -44,9 +50,6 @@ public void setStatus(EventStatus status) {
this.status = status;
}

public Event() {
}

public void setId(Long id) {
this.id = id;
}
Expand Down Expand Up @@ -83,11 +86,23 @@ public String getDescription() {
return description;
}

public String getTime() {
return time;
}

public void setTime(String time) {
this.time = time;
}

public void setDescription(String description) {
this.description = description;
}

public String getAgenda() { return agenda; }
public String getAgenda() {
return agenda;
}

public void setAgenda(String agenda) { this.agenda = agenda; }
public void setAgenda(String agenda) {
this.agenda = agenda;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ public class EventDto {
private String eventName;
private String eventDescription;
private String eventDate;
private String eventTime;
private Long eventID;
private String eventAgenda;

public EventDto(){

}

public EventDto(String name, String description, String date, Long id, String agenda) {
public EventDto(String name, String description, String date, String time, Long id, String agenda) {
this.eventName = name;
this.eventDescription = description;
this.eventDate = date;
this.eventTime = time;
this.eventID = id;
this.eventAgenda = agenda;
}
Expand Down Expand Up @@ -51,7 +53,19 @@ public void setEventDate(String eventDate) {
this.eventDate = eventDate;
}

public String getEventAgenda() { return eventAgenda; }
public String getEventAgenda() {
return eventAgenda;
}

public void setEventAgenda(String eventAgenda) {
this.eventAgenda = eventAgenda;
}

public void setEventAgenda(String eventAgenda) { this.eventAgenda = eventAgenda; }
public String getEventTime() {
return eventTime;
}

public void setEventTime(String eventTime) {
this.eventTime = eventTime;
}
}
Empty file.
16 changes: 10 additions & 6 deletions src/main/webapp/app/jsp/add-event.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="pagesStyle.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.css" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.js"></script>
</head>
<body onload="checkFunction()">
<header id="add" class="w3-hide"><h1>Add New Event</h1></header>
Expand All @@ -21,6 +23,8 @@
<p><textarea name="agenda" id="agenda"></textarea></p>
<p><b>Date</b></p>
<p><input type="text" id="datepicker"></p>
<p><b>Time</b></p>
<p><input type="text" id="timepicker"></p>
</form>

<div id="buttons">
Expand Down Expand Up @@ -48,6 +52,9 @@
data["description"] = description.value;
var agenda = document.getElementById("agenda");
data["agenda"] = agenda.value;
var eventtime=document.getElementById("timepicker");
data["time"] = eventtime.value;
if (id) {
data["id"] = id;
}
Expand Down Expand Up @@ -82,8 +89,6 @@
}).then(function (response) {
location.href = "<c:url value='/app/jsp/start.jsp'/>";
});
}
function updateData() {
Expand All @@ -96,10 +101,7 @@
}, body: JSON.stringify(data)
}).then(function (response) {
location.href = "<c:url value='/app/jsp/start.jsp'/>";
});
}
function getEventDataFromDB() {
Expand All @@ -117,6 +119,7 @@
document.getElementById("name").value = event.eventName;
document.getElementById("description").value = event.eventDescription;
document.getElementById("datepicker").value = event.eventDate;
document.getElementById("timepicker").value = event.eventTime;
document.getElementById("agenda").value = event.eventAgenda;
})
}
Expand All @@ -134,7 +137,8 @@
}
$(function () {
$("#datepicker").datepicker();
$( "#datepicker" ).datepicker();
$( "#timepicker" ).timepicker();
});
</script>
Expand Down
7 changes: 5 additions & 2 deletions src/main/webapp/app/jsp/event.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
<button type="button" onclick="myEvents()">My Events</button>
<button type="button" onclick="addEvent()">Add Event</button>
</div>
<div id="event-field" class="w3-hide" >
<div id="event-field" class="w3-hide">
<h1>{{eventName}}</h1>
<h4>{{eventDate}}</h4>
<div>
<h4>{{eventDate}} &nbsp</h4>
<h4>{{eventTime}}</h4>
</div>
<p>{{eventDescription}}</p>
<p>{{eventAgenda}}</p>
</div>
Expand Down

0 comments on commit 9879ceb

Please sign in to comment.