Skip to content

Commit

Permalink
Add points from empty calendar page
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Raible authored Oct 15, 2018
1 parent 9b700ce commit 6798770
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/webapp/app/entities/points/points.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ export class PointsResolve implements Resolve<IPoints> {
if (id) {
return this.service.find(id).pipe(map((points: HttpResponse<Points>) => points.body));
} else {
// populate date with current date if new
const points = new Points();
points.date = moment();
// populate date with current date if date not passed in
const date = route.queryParams['date'];
if (date) {
points.date = moment(date);
} else {
points.date = moment();
}
// default to the best day possible
points.exercise = 1;
points.meals = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/app/history/history.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ export class HistoryComponent implements OnInit, OnDestroy {
if (isSameMonth(date, this.viewDate)) {
if ((isSameDay(this.viewDate, date) && this.activeDayIsOpen === true) || events.length === 0) {
this.activeDayIsOpen = false;
// if no events, clicking on day brings up add points
if (events.length === 0) {
this.router.navigateByUrl('/points/new?date=' + format(date, 'YYYY-MM-DD'));
}
} else {
this.activeDayIsOpen = true;
this.viewDate = date;
Expand Down

0 comments on commit 6798770

Please sign in to comment.