2014-07-28 12:34:18 +03:00
|
|
|
module ApplicationHelper
|
2015-08-15 04:33:02 +03:00
|
|
|
def locale_collection
|
|
|
|
I18n.available_locales.map do |locale|
|
|
|
|
[t("locales.#{locale}"), locale]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-15 19:06:41 +03:00
|
|
|
def proposition_status_class(status)
|
|
|
|
{
|
|
|
|
"undecided" => "default",
|
|
|
|
"approved" => "info",
|
|
|
|
"rejected" => "danger",
|
2019-04-28 21:10:54 +03:00
|
|
|
"backup" => "warning",
|
2015-10-15 19:06:41 +03:00
|
|
|
}.with_indifferent_access[status]
|
|
|
|
end
|
|
|
|
|
|
|
|
def proposition_status_glyph(status)
|
|
|
|
{
|
|
|
|
"undecided" => "question",
|
|
|
|
"approved" => "thumbs-up",
|
|
|
|
"rejected" => "thumbs-down",
|
2019-04-28 21:10:54 +03:00
|
|
|
"backup" => "refresh",
|
2015-10-15 19:06:41 +03:00
|
|
|
}.with_indifferent_access[status]
|
|
|
|
end
|
|
|
|
|
|
|
|
def proposition_status_icon(status)
|
|
|
|
icon(proposition_status_glyph(status))
|
|
|
|
end
|
|
|
|
|
2015-07-19 11:44:44 +03:00
|
|
|
def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy])
|
2015-07-14 21:00:02 +03:00
|
|
|
klass = record.class
|
2019-04-28 21:10:54 +03:00
|
|
|
output = ""
|
2015-07-14 21:00:02 +03:00
|
|
|
|
|
|
|
if actions.include? :index
|
2015-07-19 11:44:44 +03:00
|
|
|
output += link_to(icon(:list), [:management, conference, klass], {
|
2019-04-28 21:10:54 +03:00
|
|
|
title: t("actions.index.button", models: klass.model_name.human(count: 2)),
|
|
|
|
class: "btn btn-info",
|
2015-07-14 21:00:02 +03:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
if actions.include? :show
|
2015-07-19 11:44:44 +03:00
|
|
|
output += link_to(icon(:eye), [:management, conference, record], {
|
2019-04-28 21:10:54 +03:00
|
|
|
title: t("actions.view.button", model: klass.model_name.human),
|
|
|
|
class: "btn btn-info",
|
2015-07-14 21:00:02 +03:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
if actions.include? :edit
|
2019-04-28 21:10:54 +03:00
|
|
|
output += link_to(icon(:edit), [:edit, :management, conference, record], {
|
|
|
|
title: t("actions.edit.button", model: klass.model_name.human),
|
|
|
|
class: "btn btn-warning",
|
|
|
|
})
|
2015-07-14 21:00:02 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if actions.include? :destroy
|
2019-04-28 21:10:54 +03:00
|
|
|
output += link_to(icon(:trash), [:management, conference, record], {
|
|
|
|
method: :delete,
|
|
|
|
data: {confirm: t("actions.are_you_sure")},
|
|
|
|
title: t("actions.destroy.button", model: klass.model_name.human),
|
|
|
|
class: "btn btn-danger",
|
|
|
|
})
|
2015-07-14 21:00:02 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
output.html_safe
|
|
|
|
end
|
2014-07-28 12:34:18 +03:00
|
|
|
end
|