Sha256: 9348820721223be2cb1b1d61ce64a8b8477039f66049317a5fc72eb420c40d25

Contents?: true

Size: 1.93 KB

Versions: 53

Compression:

Stored size: 1.93 KB

Contents

module ContentProviders
  # Provides a list of a Participant's unhelpful Thoughts.
  class UnhelpfulThoughtsListProvider < BitCore::ContentProvider
    def data_class_name
      "Thought"
    end

    def render_current(options)
      @thoughts = options.participant.thoughts.unreflected
      @view = options.view_context
      @view.render(
        template: "think_feel_do_engine/thoughts/index",
        locals: {
          title: provider_title,
          thoughts: @thoughts.last(3),
          postscript: provider_postscript,
          show_nav_link: (@thoughts.count > 0)
        }
      )
    end

    def show_nav_link?
      false
    end

    private

    def provider_title
      if @thoughts.count > 0
        "You said you had the following unhelpful thoughts:"
      else
        "You don't have any harmful thoughts that you've logged and " \
        "haven't challenged."
      end
    end

    def provider_postscript
      if @thoughts.count > 0
        "We're going to ask you to challenge each thought:"
      else
        title_1, title_2 = "#1 Identifying", "Add a New Harmful Thought"
        module_1 = BitCore::ContentModule.find_by_title(title_1)
        module_2 = BitCore::ContentModule.find_by_title(title_2)

        if module_1 && module_2
          "You can log more thoughts in " \
          "#{ @view.link_to(
            title_1,
            @view.navigator_location_path(module_id: module_1.id),
            style: 'font-size: larger;') } or use " \
          "#{ @view.link_to(
            title_2,
            @view.navigator_location_path(module_id: module_2.id),
            style: 'font-size: larger;') } to do multiple steps at once."
        else
          if defined? Raven
            event = Raven::Event.new(message: "one of the thought modules " \
                                              "couldn't be found via title")
            Raven.send(event)
          end

          nil
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
think_feel_do_engine-3.19.7 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.6 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.5 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.4 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.3 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.2 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.1 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.19.0 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.18.0 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.17.2 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.17.1 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.17.0 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.16.3 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.16.2 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.16.1 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.15.7 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.16.0 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.15.6 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.15.5 app/models/content_providers/unhelpful_thoughts_list_provider.rb
think_feel_do_engine-3.15.4 app/models/content_providers/unhelpful_thoughts_list_provider.rb