Class: WorkActivity::FileChanges
- Defined in:
- app/models/work_activity.rb
Constant Summary
Constants inherited from Renderer
Renderer::DATE_FORMAT, Renderer::DATE_TIME_FORMAT, Renderer::SORTABLE_DATE_TIME_FORMAT, Renderer::UNKNOWN_USER
Instance Method Summary collapse
-
#body_html ⇒ Object
Returns the message formatted to display file changes that were logged as an activity.
Methods inherited from Renderer
#created_by_user_html, #created_sortable_html, #created_updated_html, #initialize, #title_html, #to_html
Constructor Details
This class inherits a constructor from WorkActivity::Renderer
Instance Method Details
#body_html ⇒ Object
Returns the message formatted to display file changes that were logged as an activity
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'app/models/work_activity.rb', line 223 def body_html changes = JSON.parse(@work_activity.) if changes.is_a?(Hash) changes = [changes] end files_added = changes.select { |v| v["action"] == "added" } files_deleted = changes.select { |v| v["action"] == "removed" } files_replaced = changes.select { |v| v["action"] == "replaced" } changes_html = [] unless files_added.empty? label = "Files Added: " label += files_added.length.to_s changes_html << "<tr><td>#{label}</td></tr>" end unless files_deleted.empty? label = "Files Deleted: " label += files_deleted.length.to_s changes_html << "<tr><td>#{label}</td></tr>" end unless files_replaced.empty? label = "Files Replaced: " label += files_replaced.length.to_s changes_html << "<tr><td>#{label}</td></tr>" end "<table>#{changes_html.join}</table>" end |