Sha256: 439af58d2df78a65ce9fd18c83f80dce18d2e7d0e8d91a11cc2e784b7502f5f5

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module Peoplefinder
  module ApplicationHelper
    def last_update
      current_object = @person || @group
      if current_object && current_object.updated_at.present?
        "Last updated: #{
          current_object.updated_at.strftime('%d %b %Y %H:%M')
        }."
      end
    end

    def govspeak(source)
      options = { header_offset: 2 }
      doc = Govspeak::Document.new(source, options)
      doc.to_html.html_safe
    end

    def breadcrumbs(items)
      render partial: 'peoplefinder/shared/breadcrumbs',
             locals: { items: items }
    end

    FLASH_NOTICE_KEYS = %w[ error notice warning ]

    def flash_messages
      messages = flash.keys.map(&:to_s) & FLASH_NOTICE_KEYS
      return if messages.empty?
      content_tag(:div, class: 'inner-block') {
        content_tag(:div, id: 'flash-messages') {
          messages.map { |type| flash_message(type) }.join.html_safe
        }
      }
    end

    def info_text(key)
      t(key, scope: %w[peoplefinder views info_text].join('.')).html_safe
    end

  private

    def flash_message(type)
      content_tag(:div, class: "flash-message #{type}") {
        flash[type]
      }
    end

    def editing_mode
      @editing_mode = true
      content_for :editing_alert do
        render partial: 'peoplefinder/shared/editing_alert'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peoplefinder-0.0.2 app/helpers/peoplefinder/application_helper.rb