Sha256: bca3b741e78dd37aea912a7102830968783c05e896d7d661584a505c26506aa2

Contents?: true

Size: 995 Bytes

Versions: 172

Compression:

Stored size: 995 Bytes

Contents

module WithStudentPathNavigation
  class Navigation
    def initialize(template)
      @template = template
    end

    def button(navigable)
      sibling = sibling_for(navigable)
      link_to link_icon(sibling),
              sibling,
              merge_confirmation_classes(navigable, class: clazz) if sibling && sibling != navigable
    end

    def link_icon(sibling)
      fa_icon(icon, text: I18n.t(key, sibling: sibling.name, kind: I18n.t(sibling.class.model_name.name.downcase)), right: right)
    end

    def right
      false
    end

    def merge_confirmation_classes(navigable, base_classes)
      if navigable.is_a? Reading
        base_classes.merge class: "btn-confirmation #{base_classes[:class]}",
                           'data-confirmation-url': exercise_confirmations_path(navigable)
      else
        base_classes
      end
      .merge role: "button"
    end

    def method_missing(name, *args, &block)
      @template.send(name, *args, &block)
    end
  end
end

Version data entries

172 entries across 172 versions & 1 rubygems

Version Path
mumuki-laboratory-9.23.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.22.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.21.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.20.1 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.20.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.19.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.18.1 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.18.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.17.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.16.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.15.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.14.1 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.14.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.13.2 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.13.1 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.13.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.12.1 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.12.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.11.0 app/helpers/concerns/with_student_path_navigation/navigation.rb
mumuki-laboratory-9.10.0 app/helpers/concerns/with_student_path_navigation/navigation.rb