Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
7205fea4
Verified
Commit
7205fea4
authored
Mar 27, 2018
by
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
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/volunteers_controller.rb
View file @
7205fea4
...
...
@@ -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
...
...
app/models/group_offer_category.rb
View file @
7205fea4
...
...
@@ -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
)
...
...
app/models/volunteer.rb
View file @
7205fea4
...
...
@@ -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
...
...
app/views/volunteers/_form.html.slim
View file @
7205fea4
...
...
@@ -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
...
...
app/views/volunteers/show.html.slim
View file @
7205fea4
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment