aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorXinhui2016-11-28 13:25:18 +0100
committerXinhui2016-11-28 13:25:18 +0100
commit850061c7f1d20bce0cf9163658327fc3557919bc (patch)
treee86cd9bf156312b4e3df5bb7b2ce7ac93d070258 /app
parent61653806b8d977eef4d565040cc7ea86cb9fa9c9 (diff)
downloadchouette-core-850061c7f1d20bce0cf9163658327fc3557919bc.tar.bz2
LineFootnotes#show
Diffstat (limited to 'app')
-rw-r--r--app/controllers/line_footnotes_controller.rb15
-rw-r--r--app/views/line_footnotes/show.html.slim15
-rw-r--r--app/views/referential_lines/show.html.slim9
3 files changed, 27 insertions, 12 deletions
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb
index 6e3c08653..305a8fac3 100644
--- a/app/controllers/line_footnotes_controller.rb
+++ b/app/controllers/line_footnotes_controller.rb
@@ -1,16 +1,23 @@
class LineFootnotesController < ChouetteController
- before_action :set_line
+ defaults :resource_class => Chouette::Line, :instance_name => 'line'
before_action :check_policy, :only => [:edit, :update]
+ belongs_to :referential
def show
+ show! do
+ build_breadcrumb :show
+ end
end
def edit
+ edit! do
+ build_breadcrumb :edit
+ end
end
def update
if @line.update(line_params)
- redirect_to referential_line_path(@referential, @line) , notice: t('notice.footnotes.updated')
+ redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated')
else
render :edit
end
@@ -18,10 +25,10 @@ class LineFootnotesController < ChouetteController
private
def check_policy
- authorize @line, :update_footnote?
+ authorize resource, :update_footnote?
end
- def set_line
+ def resource
@referential = Referential.find params[:referential_id]
@line = @referential.lines.find params[:line_id]
end
diff --git a/app/views/line_footnotes/show.html.slim b/app/views/line_footnotes/show.html.slim
new file mode 100644
index 000000000..e8d3c459f
--- /dev/null
+++ b/app/views/line_footnotes/show.html.slim
@@ -0,0 +1,15 @@
+h2
+ = t('lines.show.title', line: @line.name)
+.line_show
+ p
+ label = "#{@line.human_attribute_name('footnotes')} : "
+ ul
+ - @line.footnotes.each do |footnote|
+ li = "#{footnote.code} : #{footnote.label}"
+
+
+- content_for :sidebar do
+ ul.actions
+ - if policy(@line).update_footnote?
+ li
+ = link_to t('lines.actions.edit_footnotes'), edit_referential_line_footnotes_path(@referential, @line), class: 'edit'
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 1b27a22f8..9b754a5aa 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -108,11 +108,7 @@ h2
/ = ": #{@line.vehicle_journeys.count - (@line.vehicle_journeys.where('flexible_service = ?', true).count + @line.vehicle_journeys.where('flexible_service = ?', false).count)}"
/
p
- label = "#{@line.human_attribute_name('footnotes')} : "
- ul
- - @line.footnotes.each do |footnote|
- li = "#{footnote.code} : #{footnote.label}"
-
+ label = link_to @line.human_attribute_name('footnotes'), referential_line_footnotes_path(@referential, @line)
/ p
/ label = "#{@line.human_attribute_name('comment')} : "
/ = @line.comment
@@ -134,9 +130,6 @@ p.after_map
- if policy(@line).update?
li
= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'edit'
- - if policy(@line).update_footnote?
- li
- = link_to t('lines.actions.edit_footnotes'), edit_referential_line_footnotes_path(@referential, @line), class: 'edit'
- if policy(@line).destroy?
li
= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), method: :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, class: 'remove'