diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-06 07:59:18 +0300 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-06 10:02:53 +0300 |
commit | 39b6e678da8c431020370dfc26c761255bc3ddf8 (patch) | |
tree | 3d5034b2fdba1cb41576b213d3832cadf77a3d19 /app/helpers | |
parent | fa981c9794de7a76bf225dc243e20d2799b55e53 (diff) |
Simplify HAML code using unless condition and nesting
Extract diff line data attributes to helper methods
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/notes_helper.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 42419aa908e..e1c8152885a 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -24,6 +24,27 @@ module NotesHelper }.to_json end + def note_text_file_data + return {} unless defined?(@comments_target) && @comments_target.any? + + @comments_target.slice(:noteable_id, :noteable_type, :commit_id).merge(note_type: LegacyDiffNote.name) + end + + def note_line_parallel_data(line_code, line_type) + data = { + line_code: line_code, + line_type: line_type, + } + + unless @diff_notes_disabled + data.merge!( + discussion_id: discussion_id(line_code) + ) + end + + data + end + def discussion_id(line_code) LegacyDiffNote.build_discussion_id( @comments_target[:noteable_type], |