module Workarea module Admin class ChangesViewModel < ApplicationViewModel def id Digest::SHA1.hexdigest(model.to_s) end def present_changes model.reject { |k, v| k.blank? || v.all?(&:blank?) } end def relevant_fields present_changes .keys .map { |k| remove_id_from_field_name(k) } .map(&:humanize) .map(&:downcase) .map { |n| t("workarea.admin.fields.#{n}", default: n) } end def to_html if model.blank? || relevant_fields.blank? t('workarea.admin.fields', count: 0).html_safe elsif relevant_fields.size > 3 %Q( #{t('workarea.admin.fields', count: relevant_fields.size)}
#{relevant_fields.to_sentence}