Sha256: 9de19b36da5b122089aa45fc436a5cecc3ca0c1ea60f36f70713ee673072d43d

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module RailsAdminGlobalizeField
  class Tab
    LABEL_KEY = 'admin.globalize_field.tab_label'

    attr_reader :locale, :translation

    def initialize(locale, translation, validate: true)
      @locale = locale
      @translation = translation
      @validate = validate
    end

    def id
      ['pane', translation.model_name.param_key, locale].join('-')
    end

    def label
      if I18n.exists?(LABEL_KEY, locale: locale)
        I18n.t(LABEL_KEY, locale: locale)
      else
        locale
      end
    end

    def active!
      @active = true
    end

    def active?
      @active
    end

    def valid?
      !@validate || translation.valid?
    end

    def invalid?
      !valid?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_admin_globalize_field-1.2.0 lib/rails_admin_globalize_field/tab.rb