Add to_param to the Track model

And update the urls
This commit is contained in:
AEtherC0r3 2017-07-07 00:21:26 +03:00 committed by Stella Rouzi
parent 68fc750e9f
commit 9671696adf
10 changed files with 33 additions and 27 deletions

View file

@ -22,19 +22,20 @@
%td
= role.description
- if role.resource_type == 'Track'
- track = Track.find(role.resource_id)
= link_to track.name, admin_conference_program_track_path(@conference.short_title, track)
= link_to role.resource.name, admin_conference_program_track_path(@conference.short_title, role.resource)
%td
= role.users.pluck(:name).first(5).join ', '
- if role.users.count > 5
= link_to '...', admin_conference_role_path(@conference.short_title, role.name)
- if role.resource_type == 'Track'
= link_to '...', track_admin_conference_role_path(@conference.short_title, role.name, role.resource)
- else
= link_to '...', admin_conference_role_path(@conference.short_title, role.name)
%td
.btn-group
- if role.resource_type == 'Track'
- track_name = Track.find(role.resource_id).short_name
= link_to 'Users', track_admin_conference_role_path(@conference.short_title, role.name, track_name), class: 'btn btn-success'
= link_to 'Users', track_admin_conference_role_path(@conference.short_title, role.name, role.resource), class: 'btn btn-success'
- if can? :edit, role
= link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, role.name, track_name), class: 'btn btn-primary'
= link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, role.name, role.resource), class: 'btn btn-primary'
- else
= link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success'
- if can? :edit, role

View file

@ -7,7 +7,7 @@
= @role.name.titleize
- if can? :edit, @role
- if @track
= link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, @role.name, @track.short_name), class: 'btn btn-primary pull-right'
= link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, @role.name, @track), class: 'btn btn-primary pull-right'
- else
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right'
.text-muted

View file

@ -8,7 +8,7 @@
Track
.row
.col-md-12
= semantic_form_for(@track, url: (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track.short_name))) do |f|
= semantic_form_for(@track, url: (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track))) do |f|
= f.input :name
= f.input :short_name, hint: "A short and unique handle for the track, using only letters, numbers, underscores, and dashes. This will be used to identify the track in URLs etc. Example: 'my_awesome_track'", input_html: { required: 'required', pattern: '[a-zA-Z0-9_-]+', title: 'Only letters, numbers, underscores, and dashes.' }
= f.input :color, input_html: {size: 6, type: 'color'}, required: true

View file

@ -20,7 +20,7 @@
- @tracks.each do |track|
%tr
%td
= link_to(admin_conference_program_track_path(@conference.short_title, track.short_name)) do
= link_to(admin_conference_program_track_path(@conference.short_title, track)) do
= track.name
%td
= track.short_name
@ -54,11 +54,12 @@
%i.fa.fa-check
%td
.btn-group{role: "group"}
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.short_name),
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track),
method: :get, class: 'btn btn-primary'
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.short_name),
method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
- if can? :destroy, track
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track),
method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
.row
.col-md-12.text-right
= link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success'