Skip to content

Commit

Permalink
Ability to delete a theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
CoralineAda committed Oct 21, 2024
1 parent 578b96b commit 71d38f6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 16 deletions.
3 changes: 2 additions & 1 deletion app/assets/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ input[type="email"] {
}

.tag.active {
background-color: var(--color-green);
background-color: var(--color-medium-black);
border: 3px solid var(--color-medium-black);
}

Expand Down Expand Up @@ -835,6 +835,7 @@ input[type="email"] {
float: left;
min-width: 2rem;
margin: 0 1rem 1rem 0;
border: 3px solid var(--color-red);
float: right;
}

Expand Down
14 changes: 12 additions & 2 deletions app/controllers/themes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def index
@themes = Theme.all.order(&:name)
end

def new
@theme = Theme.new
end

def show
@contexts = Theme::CONTEXTS
@theme = Theme.find(params[:id])
Expand All @@ -16,16 +20,22 @@ def create
redirect_to @theme
end

def destroy
@theme = Theme.find(params[:id])
@theme.destroy
redirect_to themes_path
end

def update
@theme = Theme.find(params[:id])
new_category_ids = theme_params[:categories].split(/[\,\s]/)
new_category_ids = theme_params[:categories].split(/[\,\s]/)
update_kind = @theme.categories.length == new_category_ids.length ? "metadata" : "category"

if theme_params[:categories]
categories = Category.where(id: new_category_ids)
@theme.categories = categories
end

@theme.name = theme_params[:name]
@theme.description = theme_params[:description]
@theme.notes = theme_params[:notes]
Expand Down
6 changes: 3 additions & 3 deletions app/views/shared/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<a href="/"><img class="logo" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI3LjcuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuM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jktMi45VjUybDcuNS03LjVoLTE4LjhsMy40LDMuNGgtNC4ybC00LjktNC45bDQuOS00LjloNC4ybC0zLjQsMy40aDE4LjdsLTcuNC03LjR2NC45bC0yLjktMi45di02LjloNi45bDIuOSwyLjloLTQuOQoJbDcuNCw3LjRWMjAuOWwtMy40LDMuNHYtNC4xbDQuOS00LjlsNC45LDQuOXY0LjFsLTMuNC0zLjR2MTguOGw3LjUtNy41SDE0NGwyLjktMi45aDYuOXY2LjlsLTIuOSwyLjl2LTQuOWwtNy40LDcuNGgxOC42bC0zLjQtMy40CgloNC4xbDQuOSw0LjlsLTQuOSw0LjlMMTU4LjcsNDhMMTU4LjcsNDh6Ii8+Cjwvc3ZnPgo=" alt="The tmi-web logo, which featyres the words 'tmi' and 'web' separated by an eight-pointed arrow/star shape inside a circle." /></a>
<nav>
<ul>
<li><a href="/survey_responses">Responses</a></li>
<li><a href="/codebooks">Codebook</a></li>
<li><a href="/themes">Themes</a></li>
<li><a href="/survey_responses/new">Upload</a></li>
<li><a href="/codebooks">Codebooks</a></li>
<li><a href="/survey_responses">Responses</a></li>
<li><a href="/stats">Statistics</a></li>
<li><a href="/survey_responses/new">Upload</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
Expand Down
10 changes: 3 additions & 7 deletions app/views/themes/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<%- title "Themes" %>

<h1>Explore Themes.</h1>

<h2>Themes</h2>
<div class="tag-collection">
<% @themes.each do |theme| %>
<%= link_to theme_path(theme.id) do %>
<div class="tag zoom-link-light"><%= theme.name %></div>
<% end %>
<% end %>
<%= link_to new_theme_path do %>
<div class="tag-button">New Theme</div>
<% end %>
</div>

<h2>Create a New Theme</h2>
<%= form_with model: Theme.new, data: { turbo_frame: "tag-collection" } do |f| %>
<%= f.text_field :name %>
<%= f.submit "Add Theme" %>
<% end %>
19 changes: 19 additions & 0 deletions app/views/themes/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%- title "New Theme" %>

<h1>Add a Theme</h1>

<%= form_with model: @theme do |f| %>
<fieldset>
<%= label :name, "Name" %>
<%= f.text_field :name %>
</fieldset>
<fieldset>
<%= label :description, "Description" %>
<%= f.text_area :description %>
</fieldset>
<fieldset>
<%= label :notes, "Notes" %>
<%= f.text_area :notes %>
</fieldset>
<%= f.submit "Create" %>
<% end %>
10 changes: 7 additions & 3 deletions app/views/themes/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<%- title "Themes" %>

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

<%= render partial: "form", locals: { theme: @theme, success: nil, update_kind: nil } %>

<h2>Categories</h2>
<p>Categories related to this theme are are highlighted in black below. Click to add or remove a category from this theme. Changes are saved automatically.</p>

<% @contexts.each do |context| %>
<% contextual_categories = @categories.select{ |c| c.context == context[0] } %>
<% if contextual_categories.any? %>
<h2><%= context[1] %> Categories</h2>
<p>Associated categories are highlighted in black. Click to add or remove a category from this theme. Changes are saved automatically.</p>
<h3><%= context[1] %></h3>
<div class="tag-collection">
<% contextual_categories.sort_by(&:name).each do |category| %>
<% is_selected = @theme.categories.include? category %>
Expand All @@ -22,6 +24,8 @@
<% end %>
<% end %>

<%= button_to "Delete This Theme", theme_path(@theme), form: { data: { turbo_confirm: "Are you sure?" } }, method: :delete %>

<%= render partial: "/shared/filtering" %>

<script language="javascript">
Expand Down

0 comments on commit 71d38f6

Please sign in to comment.