Commit 8c05bfd8 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

generic helper that creates all maijor form navigation link buttons

parent 842eed35
...@@ -28,4 +28,17 @@ module ApplicationHelper ...@@ -28,4 +28,17 @@ module ApplicationHelper
html_options[:partial] = "#{association}/fields" html_options[:partial] = "#{association}/fields"
link_to_add_association(name, f, association, html_options) link_to_add_association(name, f, association, html_options)
end end
def form_navigation_btn(action)
text = action == :back ? t('back') : t_title(action)
action = :index if action == :back
target = { controller: controller_name, action: action }
button_type = action == :new ? 'success' : 'default'
target[:id] = params[:id] unless action == :index
content_tag :div, class: 'row' do
content_tag :div, class: 'col-xs-12' do
link_to text, target, class: "btn btn-#{button_type}"
end
end
end
end end
...@@ -4,6 +4,5 @@ ...@@ -4,6 +4,5 @@
== render 'form' == render 'form'
.row = form_navigation_btn :show
.col-xs-12 = form_navigation_btn :back
= link_to t('back'), clients_path, class: 'btn btn-default'
...@@ -19,6 +19,5 @@ ...@@ -19,6 +19,5 @@
tbody tbody
= render @clients = render @clients
.row
.col-xs-12 = form_navigation_btn :new
= link_to t('create_client'), new_client_path, class: 'btn btn-success'
...@@ -6,6 +6,4 @@ ...@@ -6,6 +6,4 @@
.col-xs-12 .col-xs-12
p= render 'form' p= render 'form'
.row = form_navigation_btn :back
.col-xs-12
= link_to t('back'), clients_path, class: 'btn btn-default'
...@@ -66,10 +66,5 @@ ...@@ -66,10 +66,5 @@
= render 'schedules/show', participant: @client = render 'schedules/show', participant: @client
.row = form_navigation_btn :edit
.col-xs-12 = form_navigation_btn :back
= link_to t_action(:edit), edit_client_path(@client), class: 'btn btn-default'
.row
.col-xs-12
= link_to t('back'), clients_path, class: 'btn btn-default'
...@@ -4,6 +4,5 @@ ...@@ -4,6 +4,5 @@
== render 'form' == render 'form'
.row = form_navigation_btn :show
.col-xs-12 = form_navigation_btn :back
= link_to t(:back), departments_path, class: 'btn btn-default'
\ No newline at end of file
...@@ -22,6 +22,4 @@ ...@@ -22,6 +22,4 @@
td= link_to t_action(:edit), edit_department_path(d) td= link_to t_action(:edit), edit_department_path(d)
td= link_to t_action(:destroy), d, data: { confirm: t_confirm_delete(d) }, method: :delete td= link_to t_action(:destroy), d, data: { confirm: t_confirm_delete(d) }, method: :delete
.row = form_navigation_btn :new
.col-xs-12
= link_to t_title(:new), new_department_path, class: 'btn btn-success'
...@@ -4,6 +4,4 @@ ...@@ -4,6 +4,4 @@
== render 'form' == render 'form'
.row = form_navigation_btn :back
.col-xs-12
= link_to t(:back), departments_path, class: 'btn btn-default'
...@@ -19,9 +19,5 @@ ...@@ -19,9 +19,5 @@
- @department.user.each do |user| - @department.user.each do |user|
li= user.to_s li= user.to_s
.row = form_navigation_btn :edit
.col-xs-12 = form_navigation_btn :back
= link_to t_action(:edit), edit_department_path(@department), class: 'btn btn-default'
.row
.col-xs-12
= link_to t(:back), departments_path, class: 'btn btn-default'
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
== render 'form' == render 'form'
= link_to t('back'), profile_path, class: 'btn btn-default' = form_navigation_btn :back
\ No newline at end of file
...@@ -34,10 +34,8 @@ ...@@ -34,10 +34,8 @@
- else - else
i.glyphicon.glyphicon-remove.text-danger i.glyphicon.glyphicon-remove.text-danger
span.sr-only Doesn't work on #{day.to_s}s span.sr-only Doesn't work on #{day.to_s}s
.row
.col-xs-12
= link_to t('edit_profile'), edit_profile_path(@profile), class: 'btn btn-default'
= form_navigation_btn :edit
.row .row
.col-xs-12 .col-xs-12
= link_to t('edit_login'), edit_user_path(current_user.id), class: 'btn btn-default' = link_to t('edit_login'), edit_user_path(current_user.id), class: 'btn btn-default'
...@@ -13,6 +13,4 @@ ...@@ -13,6 +13,4 @@
tbody tbody
= render @users = render @users
.row = form_navigation_btn :new
.col-xs-12
= link_to t('create_user'), new_user_path, class: 'btn btn-success'
...@@ -8,6 +8,4 @@ ...@@ -8,6 +8,4 @@
strong= t_attr(:role) strong= t_attr(:role)
.col-md-8 = t("role.#{@user.role}") .col-md-8 = t("role.#{@user.role}")
.row = form_navigation_btn :back
.col-xs-12
= link_to t('back'), users_path, class: 'btn btn-default'
...@@ -4,6 +4,5 @@ h1= t_title(:edit) ...@@ -4,6 +4,5 @@ h1= t_title(:edit)
= render 'volunteers/form', f: f, volunteer: @volunteer = render 'volunteers/form', f: f, volunteer: @volunteer
= f.button :submit, class: 'btn btn-success' = f.button :submit, class: 'btn btn-success'
.row = form_navigation_btn :show
.col-xs-12 = form_navigation_btn :back
= link_to t('back'), volunteers_path, class: 'btn btn-default'
...@@ -19,6 +19,4 @@ ...@@ -19,6 +19,4 @@
tbody tbody
= render @volunteers = render @volunteers
.row = form_navigation_btn :new
.col-xs-12
= link_to t_title(:create), new_volunteer_path, class: 'btn btn-success'
...@@ -4,6 +4,4 @@ h1= t_title(:new) ...@@ -4,6 +4,4 @@ h1= t_title(:new)
= render 'volunteers/form', f: f = render 'volunteers/form', f: f
= f.button :submit, class: 'btn btn-success' = f.button :submit, class: 'btn btn-success'
.row = form_navigation_btn :back
.col-xs-12
= link_to t('back'), volunteers_path, class: 'btn btn-default'
...@@ -104,10 +104,5 @@ h3= t_attr(:group_accompaniment) ...@@ -104,10 +104,5 @@ h3= t_attr(:group_accompaniment)
= render 'schedules/show', participant: @volunteer = render 'schedules/show', participant: @volunteer
.row = form_navigation_btn :edit
.col-xs-12 = form_navigation_btn :back
= link_to t_action(:edit), edit_volunteer_path(@volunteer), class: 'btn btn-default'
.row
.col-xs-12
= link_to t('back'), volunteers_path, class: 'btn btn-default'
\ No newline at end of file
Supports Markdown
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