Move the bulk of path summary code to JS

This avoids the extra database queries to calculate completion
percentages.
Simplify and fix path summary more

AKA Expand Details link, which was broken since 4980547.
Cosmetic