Verified Commit 7205fea4 authored by Markus Koller's avatar Markus Koller 🦊
Browse files

Only show selected group offer categories on volunteers#show

parent e2cac8cc
Pipeline #16889 passed with stage
in 48 minutes and 45 seconds
......@@ -29,6 +29,8 @@ class VolunteersController < ApplicationController
def show
@volunteer_events = @volunteer.events.past
@group_offer_categories = @volunteer.group_offer_categories.active.without_house_moving
@group_offer_categories_house_moving = @volunteer.group_offer_categories.active.house_moving
end
def new
......
......@@ -8,9 +8,9 @@ class GroupOfferCategory < ApplicationRecord
default_scope { order(:category_name) }
scope :house_moving, -> { where('category_name LIKE ?', '%Zürich%') }
scope :active, -> { where(category_state: :active) }
scope :active_without_house_moving, -> { active.where.not('category_name LIKE ?', '%Zürich%') }
scope :house_moving, -> { where('category_name LIKE ?', '%Zürich%') }
scope :without_house_moving, -> { where.not('category_name LIKE ?', '%Zürich%') }
scope :in_group_offer, (-> { joins(:group_offers) })
def self.available_categories(exclude_ids)
......
......@@ -337,18 +337,6 @@ class Volunteer < ApplicationRecord
end
end
def group_accompaniments_active_without_house_moving
GroupOfferCategory.active_without_house_moving.map do |group|
{ title: group.category_name, value: group_offer_categories.include?(group) }
end
end
def group_accompaniments_house_moving
GroupOfferCategory.house_moving.map do |group|
{ title: group.category_name, value: group_offer_categories.include?(group) }
end
end
def to_s
contact.full_name
end
......
......@@ -87,7 +87,7 @@ fieldset
legend= t_attr(:group_accompaniment, Volunteer)
.row
.col-xs-12
= f.association :group_offer_categories, as: :check_boxes, label: false, collection: GroupOfferCategory.active_without_house_moving
= f.association :group_offer_categories, as: :check_boxes, label: false, collection: GroupOfferCategory.active.without_house_moving
.row
.col-xs-12
= f.input :other_offer_desc
......
......@@ -148,26 +148,19 @@ h3= t_attr(:group_accompaniment)
h4.label-list
.row
.col-xs-12
- @volunteer.group_accompaniments_active_without_house_moving.each do |group|
- if group[:value]
- if @group_offer_categories.present?
- @group_offer_categories.each do |category|
span.label.label-success>
=> navigation_glyph(:yes)
= t_attr(group[:title])
- else
span.label.label-danger>
=> navigation_glyph(:no)
= t_attr(group[:title])
= t_attr(category.category_name)
- else
em Keine Kategorien Ausgewählt
.row
.col-xs-12
- @volunteer.group_accompaniments_house_moving.each do |group|
- if group[:value]
span.label.label-success>
=> navigation_glyph(:yes)
= t_attr(group[:title])
- else
span.label.label-danger>
=> navigation_glyph(:no)
= t_attr(group[:title])
- @group_offer_categories_house_moving.each do |category|
span.label.label-success>
=> navigation_glyph(:yes)
= t_attr(category.category_name)
.row
.col-xs-12
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment