Skip to content

Commit

Permalink
Merge pull request #203 from identity-research-lab/more-ui-work
Browse files Browse the repository at this point in the history
UI enhancements
  • Loading branch information
CoralineAda authored Dec 10, 2024
2 parents 575e389 + 43aa021 commit 9169ad9
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app/controllers/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/contexts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/themes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/views/cases/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%- title "Cases" %>

<h1>
<%= pluralize @cases.size, "Case" %>.
Explore <%= pluralize @cases.size, "Case" %>.
</h1>

<% if @cases.any? %>
<p>You can also <%= link_to "upload more cases", new_case_path %>.</p>
<p>Add more cases by <%= link_to "uploading a data file", new_case_path %>.</p>
<% else %>
<p>To get started, <%= link_to "upload your cases", new_case_path %>.</p>
<p>To get started, <%= link_to "upload your data file", new_case_path %>.</p>
<% end %>

<ol class="nodes">
Expand Down
18 changes: 11 additions & 7 deletions app/views/cases/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<%- title "Upload" %>

<h1>Upload survey data.</h1>
<h1>Upload a Data File.</h1>

<div class="two-column">

<div class="column">
<h2>Select a CSV file.</h2>
<p>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.</p>
<h2>Select a CSV data file.</h2>
<p>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.</p>

<%= form_with url: cases_path, method: :post do |f| %>
<%= f.file_field :csv, direct_upload: true %>
Expand All @@ -17,7 +17,7 @@
<div class="column">
<h2>Required fields.</h2>

<p>Your upload must include the following fields in the header row (in any order):</p>
<p>Your data file must include the following fields in the header row (in any order):</p>

<table>
<thead>
Expand All @@ -29,12 +29,16 @@
<tbody>
<tr>
<td><code>source_record_id</code></td>
<td>Record ID from the survey platform for cross-reference</td>
<td>Record ID from the data collection platform for cross-reference</td>
</tr>
<% row_index = 0 %>
<% Question.all.each do |question| %>
<tr>
<% row_index += 1 %>
<tr class="<%= row_index.odd? ? 'alt' : ''%>">
<td><code><%= question.key %></code></td>
<td><%= question.label.downcase %></td>
<td>
<%= question.label %>
</td>
</tr>
<% end %>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/cases/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%- title "Case #{@kase.identifier}" %>

<h1>Case <%= @kase.identifier %></h1>
<h1>Case <%= @kase.identifier %>.</h1>

<% if @previous_case %>
<%= link_to "<", case_path(@previous_case), class: "flip", id: "flip-left" %>
Expand All @@ -9,7 +9,7 @@
<%= link_to ">", case_path(@next_case), class: "flip", id: "flip-right" %>
<% end %>

<h2>Derived categories of experiences:</h2>
<h2>Associated derived categories of experiences:</h2>

<% if @categories.any? %>
<div class="tag-collection">
Expand All @@ -18,7 +18,7 @@
<% end %>
</div>
<% else %>
<p>No derived categories could be found. Have you generated them from the <%= link_to "codebook", codebooks_path %>?</p>
<p>No derived categories are associated with this case.</p>
<% end %>

<h2>Interactive persona:</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/categories/_form.html.erb
Original file line number Diff line number Diff line change
@@ -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" %>
<fieldset>
<%= label :name, "Name" %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/categories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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

<% 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 } %>

<p>When you're done, you can <%= link_to "explore more #{@context.display_name} categories", context_path(id: @context.id) %>.</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/codebooks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%- title "Codebook" %>

<h1>Browse Codebooks.</h1>
<h1>Explore Codebooks.</h1>

<ul class="list">
<% @questions.each do |question| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/contexts/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%- title "Categories" %>

<h1>Browse Categories.</h1>
<h1>Explore Categories.</h1>

<ul class="list">
<% @contexts.each do |context| %>
Expand Down
9 changes: 8 additions & 1 deletion app/views/contexts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<%- title "#{@context.display_name} Categories" %>

<h1><%= @context.display_name %> categories.</h1>
<h1>"<%= @context.display_name %>" Categories.</h1>

<% 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 %>
<p>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 %>.</p>
Expand Down
9 changes: 8 additions & 1 deletion app/views/themes/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<%- title "Themes" %>

<h1>Theme: "<%= @theme.name %>"</h1>
<h1>"<%= @theme.name %>" Theme.</h1>
<p><%= link_to "More themes.", themes_path %></p>

<% 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 } %>

<h2>Categories</h2>
Expand Down

0 comments on commit 9169ad9

Please sign in to comment.