diff --git a/Gemfile b/Gemfile index a25b66697..bc6c0fb4e 100644 --- a/Gemfile +++ b/Gemfile @@ -60,6 +60,7 @@ gem 'webpacker' gem 'sidekiq' +gem 'diffy' gem 'paper_trail' gem 'sendgrid-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index 009a10965..08340fc4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,6 +162,7 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.5.1) + diffy (3.4.3) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -549,6 +550,7 @@ DEPENDENCIES country_select (~> 8.0) database_cleaner (~> 2.0) devise (~> 4.8) + diffy dotenv-rails draper (~> 4.0) factory_bot_rails diff --git a/app/assets/stylesheets/modules/_proposal.scss b/app/assets/stylesheets/modules/_proposal.scss index dd0de0d17..c996496a8 100644 --- a/app/assets/stylesheets/modules/_proposal.scss +++ b/app/assets/stylesheets/modules/_proposal.scss @@ -267,3 +267,9 @@ div.col-md-4 { padding-bottom: 0; } } + +.diff-view { + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid grey; +} diff --git a/app/helpers/proposal_helper.rb b/app/helpers/proposal_helper.rb index 63563d945..24ea072c2 100644 --- a/app/helpers/proposal_helper.rb +++ b/app/helpers/proposal_helper.rb @@ -1,4 +1,11 @@ module ProposalHelper + def diff(content1, content2) + changes = Diffy::Diff.new(content1, content2, + include_plus_and_minus_in_html: true, + include_diff_info: true) + changes.to_s.present? ? changes.to_s(:html).html_safe : 'No Changes' + end + def rating_tooltip <<-HTML

Ratings Guide

diff --git a/app/views/proposals/_contents.html.haml b/app/views/proposals/_contents.html.haml index e847dc688..bc83da51f 100644 --- a/app/views/proposals/_contents.html.haml +++ b/app/views/proposals/_contents.html.haml @@ -22,3 +22,14 @@ %div = value.capitalize %div + +- unless proposal.changeset_fields.blank? + %h2.fieldset-legend Proposal Diff... + - proposal.versions.each do |version| + #diff-view + - version.changeset.each do |k, (old, new)| + %h3.control-label= k.titleize + %div= diff old, new + +:css + = #{Diffy::CSS}