Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2300 tagging strategy or moment from category page #2337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/assets/stylesheets/dashboard/dashboard_section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
margin: $size-10 $size-0 $size-0 $size-0;
padding-left: $size-0;
width: 100%;

display: flex;
flex-direction: column;
align-items: center;
gap: $size-10;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def index
def show
setup_stories
redirect_to_path(categories_path) if @category.user_id != current_user.id
@page_new_buttons = [
{ text: t('moments.new'), path: new_moment_path(category: @category.slug) },
{ text: t('strategies.new'), path: new_strategy_path(category: @category.slug) }
]
end

# GET /categories/new
Expand Down
7 changes: 6 additions & 1 deletion app/helpers/moments_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ def checkboxes_for(data)
def data_for(item)
case item.class.name
when 'Category'
@moment.categories.pluck(:id)
ids = @moment.categories.pluck(:id)
if params[:category].present? && ids.empty?
category = Category.friendly.find_by(slug: params[:category])
ids << category.id if category
end
ids
LucasKay64 marked this conversation as resolved.
Show resolved Hide resolved
when 'Mood'
@moment.moods.pluck(:id)
when 'Strategy'
Expand Down
8 changes: 7 additions & 1 deletion app/helpers/strategies_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ def build_switch_input(value, checked, unchecked_value)
def category_checkboxes
checkboxes = []
@categories.each do |item|
checked = @strategy.categories.include?(item)

if params[:category].present? && @strategy.new_record? && !checked
checked = item.slug == params[:category]
LucasKay64 marked this conversation as resolved.
Show resolved Hide resolved
end

checkboxes.push(
id: item.slug,
label: item.name,
value: item.id,
checked: @strategy.categories.include?(item)
checked: checked
)
end
checkboxes
Expand Down
9 changes: 9 additions & 0 deletions app/views/shared/_page_title.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
<div class="pageTitleRight">
<%= link_to @page_new, yield(:page_new), class: 'buttonM' %>
</div>
<% elsif @page_new_buttons.present? %>
<div>
<%= yield(:title) %>
</div>
<div class="pageTitleRight">
<% @page_new_buttons.each_with_index do |button, index| %>
<%= link_to button[:text], button[:path], class: "buttonM" %>
<% end %>
</div>
<% elsif @page_author.present? %>
<div>
<%= yield(:title) %>
Expand Down