From 23b7bc710e70ad0d2a3a381484cb4abece681b13 Mon Sep 17 00:00:00 2001 From: Coraline Date: Mon, 9 Dec 2024 18:46:19 -0600 Subject: [PATCH 1/3] Fix issue with forward/backward nav controls --- app/controllers/cases_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/cases_controller.rb b/app/controllers/cases_controller.rb index c8fd28f..16627fe 100644 --- a/app/controllers/cases_controller.rb +++ b/app/controllers/cases_controller.rb @@ -6,9 +6,9 @@ def index def show @kase = Case.find(params[:id]) - @previous_response = Case.where("created_at < ?", @kase.created_at).order("created_at DESC").limit(1).first - @next_response = Case.where("created_at > ?", @kase.created_at).order("created_at ASC").limit(1).first - + @previous_case = Case.where("created_at < ?", @kase.created_at).order("created_at DESC").limit(1).first + @next_case = Case.where("created_at > ?", @kase.created_at).order("created_at ASC").limit(1).first + persona = Persona.find_or_initialize_by(case_id: @kase.id) @categories = persona.categories.sort{ |a,b| "#{a.context}.#{a.name}" <=> "#{b.context}.#{b.name}" } @keywords = persona.keywords.order_by(:name) From 1b38ee7c24cb2201f7ff90d980aee94e35f648f2 Mon Sep 17 00:00:00 2001 From: Coraline Date: Mon, 9 Dec 2024 18:48:48 -0600 Subject: [PATCH 2/3] Standardize on 'explore' in top-level page headers --- app/views/cases/index.html.erb | 6 +++--- app/views/cases/new.html.erb | 18 +++++++++++------- app/views/cases/show.html.erb | 4 ++-- app/views/categories/_form.html.erb | 2 +- app/views/codebooks/index.html.erb | 2 +- app/views/contexts/index.html.erb | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/views/cases/index.html.erb b/app/views/cases/index.html.erb index 31a2e25..89ac175 100644 --- a/app/views/cases/index.html.erb +++ b/app/views/cases/index.html.erb @@ -1,13 +1,13 @@ <%- title "Cases" %>

- <%= pluralize @cases.size, "Case" %>. + Explore <%= pluralize @cases.size, "Case" %>.

<% if @cases.any? %> -

You can also <%= link_to "upload more cases", new_case_path %>.

+

Add more cases by <%= link_to "uploading a data file", new_case_path %>.

<% else %> -

To get started, <%= link_to "upload your cases", new_case_path %>.

+

To get started, <%= link_to "upload your data file", new_case_path %>.

<% end %>
    diff --git a/app/views/cases/new.html.erb b/app/views/cases/new.html.erb index 185ae2f..4a16a52 100644 --- a/app/views/cases/new.html.erb +++ b/app/views/cases/new.html.erb @@ -1,12 +1,12 @@ <%- title "Upload" %> -

    Upload survey data.

    +

    Upload a Data File.

    -

    Select a CSV file.

    -

    Note that this will merge new responses from the file you select with existing cases. In other words, you will not overwrite or duplicate data by uploading a file.

    +

    Select a CSV data file.

    +

    Note that this will merge new responses from the file you select with existing cases. In other words, you will not overwrite or duplicate data by uploading a data file more than once.

    <%= form_with url: cases_path, method: :post do |f| %> <%= f.file_field :csv, direct_upload: true %> @@ -17,7 +17,7 @@

    Required fields.

    -

    Your upload must include the following fields in the header row (in any order):

    +

    Your data file must include the following fields in the header row (in any order):

    @@ -29,12 +29,16 @@ - + + <% row_index = 0 %> <% Question.all.each do |question| %> - + <% row_index += 1 %> + - + <% end %> diff --git a/app/views/cases/show.html.erb b/app/views/cases/show.html.erb index 3c3820c..f324ef8 100644 --- a/app/views/cases/show.html.erb +++ b/app/views/cases/show.html.erb @@ -9,7 +9,7 @@ <%= link_to ">", case_path(@next_case), class: "flip", id: "flip-right" %> <% end %> -

    Derived categories of experiences:

    +

    Associated derived categories of experiences:

    <% if @categories.any? %>
    @@ -18,7 +18,7 @@ <% end %>
    <% else %> -

    No derived categories could be found. Have you generated them from the <%= link_to "codebook", codebooks_path %>?

    +

    No derived categories are associated with this case.

    <% end %>

    Interactive persona:

    diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb index 3dc71f4..2108e42 100644 --- a/app/views/categories/_form.html.erb +++ b/app/views/categories/_form.html.erb @@ -1,5 +1,5 @@ <%= turbo_frame_tag "frame-category" do %> - <%= form_with model: category, id: "form-category", url: context_category_path(context_id: context.id, id: category.id), class: "", data: { turbo_frame: "category" } do |f| %> + <%= form_with model: category, id: "form-category", url: context_category_path(context, category ), class: "", data: { turbo_frame: "category" } do |f| %> <% css_class = success ? "form-success" : "form-error" %>
    <%= label :name, "Name" %> diff --git a/app/views/codebooks/index.html.erb b/app/views/codebooks/index.html.erb index a6b4b65..9e757c9 100644 --- a/app/views/codebooks/index.html.erb +++ b/app/views/codebooks/index.html.erb @@ -1,6 +1,6 @@ <%- title "Codebook" %> -

    Browse Codebooks.

    +

    Explore Codebooks.

      <% @questions.each do |question| %> diff --git a/app/views/contexts/index.html.erb b/app/views/contexts/index.html.erb index 52eb9fd..4cbcfe5 100644 --- a/app/views/contexts/index.html.erb +++ b/app/views/contexts/index.html.erb @@ -1,6 +1,6 @@ <%- title "Categories" %> -

      Browse Categories.

      +

      Explore Categories.

        <% @contexts.each do |context| %> From 43aa021356a748c486fb6ca3daafa07569f71ffb Mon Sep 17 00:00:00 2001 From: Coraline Date: Mon, 9 Dec 2024 19:10:26 -0600 Subject: [PATCH 3/3] Prev/next nav for themes, categories, and contexts --- app/controllers/categories_controller.rb | 8 ++++++++ app/controllers/contexts_controller.rb | 7 +++++++ app/controllers/themes_controller.rb | 7 +++++++ app/views/cases/show.html.erb | 2 +- app/views/categories/show.html.erb | 7 +++++++ app/views/contexts/show.html.erb | 9 ++++++++- app/views/themes/show.html.erb | 9 ++++++++- 7 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 48f90cf..311a415 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -5,6 +5,14 @@ class CategoriesController < ApplicationController def show @category = Category.find(params[:id]) @codes = Code.where(context: @category.context).order(:name) + @context = Context.find_by(name: @category.context) + + category_ids = Category.where(context: @category.context).pluck(:id) + previous_index = (category_ids.index(@category.id) - 1) + next_index = (category_ids.index(@category.id) + 1) % category_ids.length + @previous_category_id = category_ids[previous_index] + @next_category_id = category_ids[next_index] + end def new diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index 3bafbd7..b92d886 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -11,6 +11,13 @@ def show @codes = @context.codes @enqueued_at = params[:enqueued_at].present? ? Time.at(params[:enqueued_at].to_i).strftime("%T %Z") : nil @isEditMode = params[:is_edit_mode] == "true" + + context_ids = Context.all.order(:display_name).pluck(:id) + previous_index = (context_ids.index(@context.id) - 1) + next_index = (context_ids.index(@context.id) + 1) % context_ids.length + @previous_context_id = context_ids[previous_index] + @next_context_id = context_ids[next_index] + end private diff --git a/app/controllers/themes_controller.rb b/app/controllers/themes_controller.rb index ce59a0a..27bcada 100644 --- a/app/controllers/themes_controller.rb +++ b/app/controllers/themes_controller.rb @@ -12,6 +12,13 @@ def show @contexts = Context.all.order(:name) @theme = Theme.find(params[:id]) @categories = Category.all + + theme_ids = Theme.all.order(:name).pluck(:id) + previous_index = (theme_ids.index(@theme.id) - 1) + next_index = (theme_ids.index(@theme.id) + 1) % theme_ids.length + @previous_theme_id = theme_ids[previous_index] + @next_theme_id = theme_ids[next_index] + end def create diff --git a/app/views/cases/show.html.erb b/app/views/cases/show.html.erb index f324ef8..5a2d2b9 100644 --- a/app/views/cases/show.html.erb +++ b/app/views/cases/show.html.erb @@ -1,6 +1,6 @@ <%- title "Case #{@kase.identifier}" %> -

        Case <%= @kase.identifier %>

        +

        Case <%= @kase.identifier %>.

        <% if @previous_case %> <%= link_to "<", case_path(@previous_case), class: "flip", id: "flip-left" %> diff --git a/app/views/categories/show.html.erb b/app/views/categories/show.html.erb index 14c5c41..5bf1616 100644 --- a/app/views/categories/show.html.erb +++ b/app/views/categories/show.html.erb @@ -2,6 +2,13 @@

        Category: "<%= @category.name %>"

        +<% if @previous_category_id %> + <%= link_to "<", context_category_path(context_id: @context.id, id: @previous_category_id), class: "flip", id: "flip-left" %> +<% end %> +<% if @next_category_id %> + <%= link_to ">", context_category_path(context_id: @context. id, id: @next_category_id), class: "flip", id: "flip-right" %> +<% end %> + <%= render partial: "form", locals: { category: @category, context: @context, success: nil, update_kind: nil } %>

        When you're done, you can <%= link_to "explore more #{@context.display_name} categories", context_path(id: @context.id) %>.

        diff --git a/app/views/contexts/show.html.erb b/app/views/contexts/show.html.erb index ac01acc..cfe8dea 100644 --- a/app/views/contexts/show.html.erb +++ b/app/views/contexts/show.html.erb @@ -1,6 +1,13 @@ <%- title "#{@context.display_name} Categories" %> -

        <%= @context.display_name %> categories.

        +

        "<%= @context.display_name %>" Categories.

        + +<% if @previous_context_id %> + <%= link_to "<", context_path(id: @previous_context_id), class: "flip", id: "flip-left" %> +<% end %> +<% if @next_context_id %> + <%= link_to ">", context_path(id: @next_context_id), class: "flip", id: "flip-right" %> +<% end %> <% if @isEditMode %>

        When you're done, you can <%= link_to "go back to categories and codes", context_path(id: @context.id) %> or <%= link_to "move on to themes", themes_path %>.

        diff --git a/app/views/themes/show.html.erb b/app/views/themes/show.html.erb index 8ceb50b..095ecf2 100644 --- a/app/views/themes/show.html.erb +++ b/app/views/themes/show.html.erb @@ -1,8 +1,15 @@ <%- title "Themes" %> -

        Theme: "<%= @theme.name %>"

        +

        "<%= @theme.name %>" Theme.

        <%= link_to "More themes.", themes_path %>

        +<% if @previous_theme_id %> + <%= link_to "<", theme_path(id: @previous_theme_id), class: "flip", id: "flip-left" %> +<% end %> +<% if @next_theme_id %> + <%= link_to ">", theme_path(id: @next_theme_id), class: "flip", id: "flip-right" %> +<% end %> + <%= render partial: "form", locals: { theme: @theme, success: nil, update_kind: nil } %>

        Categories

    source_record_idRecord ID from the survey platform for cross-referenceRecord ID from the data collection platform for cross-reference
    <%= question.key %><%= question.label.downcase %> + <%= question.label %> +