Sha256: d61363820f44b4fe4748860f6a7f07e86280911efe3db1f1e4ac46c6770c9fcc

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

module Tawork
  module ApplicationHelper
    [:project, :story, :bug, :task].each do |method|
      define_method("#{method}_path") do |*args|
        ticket_path(*args)
      end

      define_method("#{method.to_s.pluralize}_path") do |*args|
        tickets_path(*args)
      end
    end

    def ticket_types
      Ticket::ALLOWED_TYPES.each_with_object({}) do |type, hash|
        hash[type] = Ticket.filtered_type_class(type).new(
          creator: current_user,
          parent_id: params[:parent_id]
        )
      end
    end

    def title(page_title)
      content_for(:title) { page_title }
    end

    def icon_for(thing)
      case thing
      when Space
        icon = "bullseye"
      when Page
        icon = "file"
      when Attachment
        icon = "paperclip"
      end

      tag(:i, class: "fa fa-#{icon}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tawork-0.0.36 app/helpers/tawork/application_helper.rb
tawork-0.0.35 app/helpers/tawork/application_helper.rb