Skip to content

Commit

Permalink
Merge pull request #12 from Remexllee/master
Browse files Browse the repository at this point in the history
Enhance sort logbook from most recent to less recent
  • Loading branch information
andreban authored Apr 21, 2017
2 parents 269c851 + db9ff77 commit 68177f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class App {
_addWorkout(workoutTable, rowtemplate, workout) {
rowtemplate.querySelector('.logentry__date').textContent = formatDate(workout.date);
rowtemplate.querySelector('.logentry__time').textContent =
formatTime(new Date(workout.timeElapsed * 1000));
formatTime(new Date(workout.timeElapsed * 1000));
rowtemplate.querySelector('.logentry__distance').textContent = workout.distance;
const clone = document.importNode(rowtemplate, true);
workoutTable.appendChild(clone);
Expand All @@ -162,9 +162,11 @@ class App {

const rowtemplate = document.querySelector('#logbook-record').content;
const workoutTable = document.querySelector('.logbook-records');
workouts.forEach(workout => {
this._addWorkout(workoutTable, rowtemplate, workout);
});
workouts
.sort((workoutA, workoutB) => workoutB.date - workoutA.date)
.forEach(workout => {
this._addWorkout(workoutTable, rowtemplate, workout);
});
const noWorkout = document.querySelector('.no-workout');
noWorkout.classList.add('no-workout_hidden');
});
Expand Down

0 comments on commit 68177f0

Please sign in to comment.