diff options
author | Chris Schlaeger <chris@linux.com> | 2014-11-14 17:17:22 +0100 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-11-14 17:17:22 +0100 |
commit | b5fbdd898233d5ec855f329941fd0be9b8b46a2c (patch) | |
tree | daaf45e309ed1e551f3695ec0a168f6b2738d301 /lib | |
parent | a92f1d3eb8b8a890df2e2f2846d5beedf78b5955 (diff) | |
download | postrunner-b5fbdd898233d5ec855f329941fd0be9b8b46a2c.zip |
Fix: Set proper forward/back links for newly added activities.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/postrunner/ActivitiesDB.rb | 14 | ||||
-rw-r--r-- | lib/postrunner/Activity.rb | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/postrunner/ActivitiesDB.rb b/lib/postrunner/ActivitiesDB.rb index 9aef9de..ea51dab 100644 --- a/lib/postrunner/ActivitiesDB.rb +++ b/lib/postrunner/ActivitiesDB.rb @@ -99,6 +99,9 @@ module PostRunner activity.register_records(@records) + # Generate HTML file for this activity. + activity.generate_html_view + # The HTML activity views contain links to their predecessors and # successors. After inserting a new activity, we need to re-generate # these views as well. @@ -116,8 +119,8 @@ module PostRunner end def delete(activity) - pred = predecessor(activities) - succ = successor(activities) + pred = predecessor(activity) + succ = successor(activity) @activities.delete(activity) @@ -189,11 +192,12 @@ module PostRunner @activities[idx - 1] end - # Return the previous Activity before the provided activity. Note that - # this has a higher index. If none is found, return nil. + # Return the previous Activity before the provided activity. + # If none is found, return nil. def predecessor(activity) idx = @activities.index(activity) - return nil if idx.nil? || idx >= @activities.length - 2 + return nil if idx.nil? + # Activities indexes are reversed. The predecessor has a higher index. @activities[idx + 1] end diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 0e8f4fe..d885a06 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -40,8 +40,6 @@ module PostRunner instance_variable_set(v_str, fit_activity.send(v)) self.class.send(:attr_reader, v.to_sym) end - # Generate HTML file for this activity. - generate_html_view end # YAML::load() does not call initialize(). We don't have all attributes |