Sha256: 174ba8fde27cad80e9cb103b284a7a0f3e5fb86a88de7fd3ead86ec2c4ac1ce4

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

Stored size: 890 Bytes

Contents

module Adhoq
  module ApplicationHelper
    def human(klass, attr = nil)
      if attr
        klass.human_attribute_name(attr)
      else
        klass.model_name.humanize
      end
    end

    def icon_fa(name, additional_classes = [])
      tag('i', class: ['fa', "fa-#{name}", *additional_classes])
    end

    def schema_version
      connection = Adhoq::Executor::ConnectionWrapper.new
      result = connection.select("SELECT MAX(version) AS current_version FROM #{ActiveRecord::SchemaMigration.table_name}")
      result.rows.first.first
    end

    # TODO extract into presenter
    def query_friendly_name(query)
      "Query: #{query.name}"
    end

    def table_order_key(ar_class)
      ar_class.primary_key || ar_class.columns.first.name
    end

    def query_parameter_field(name)
      text_field_tag "parameters[#{name}]", nil, class: "form-control"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adhoq-1.0.1 app/helpers/adhoq/application_helper.rb
adhoq-1.0.0 app/helpers/adhoq/application_helper.rb
adhoq-0.5.0 app/helpers/adhoq/application_helper.rb
adhoq-0.5.0.beta1 app/helpers/adhoq/application_helper.rb
adhoq-0.4.0 app/helpers/adhoq/application_helper.rb
adhoq-0.3.0 app/helpers/adhoq/application_helper.rb
adhoq-0.2.0 app/helpers/adhoq/application_helper.rb