Friendly urls for tracks

Don't use tracks ids in urls
Add short_name to tracks and use that in urls as the identifier
This commit is contained in:
AEtherC0r3 2017-06-29 23:39:56 +03:00 committed by Antonios Eleftheriadis
parent 882a1d20c9
commit 95fbd10153
9 changed files with 61 additions and 8 deletions

View file

@ -8,8 +8,9 @@
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))) do |f|
= 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|
= 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
= f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, hint: markdown_hint
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -9,6 +9,7 @@
%table.table.table-hover#tracks
%thead
%th Name
%th Short name
%th Description
%th Color
%th Actions
@ -16,8 +17,10 @@
- @tracks.each do |track|
%tr
%td
= link_to(admin_conference_program_track_path(@conference.short_title, track)) do
= link_to(admin_conference_program_track_path(@conference.short_title, track.short_name)) do
= track.name
%td
= track.short_name
%td
%p
= truncate(track.description)
@ -26,9 +29,9 @@
= track.color
%td
.btn-group{role: "group"}
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.id),
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.short_name),
method: :get, class: 'btn btn-primary'
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.id),
= 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" }
.row

View file

@ -94,7 +94,7 @@
= 'track'
- track = current_or_last_object_state(version.item_type, version.item_id)
= link_if_alive version, track.name,
admin_conference_program_track_path(conference_id: Conference.find(version.conference_id).short_title, id: version.item_id)
admin_conference_program_track_path(conference_id: Conference.find(version.conference_id).short_title, id: track.try(:short_name))
- when 'EventType'
= 'event type'