aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2017-02-20 16:56:23 +0100
committerjpl2017-02-20 16:56:23 +0100
commitbaaca138b1e72312c16c4e1a35ad3f0470eeb503 (patch)
tree3f364549738a4b94df88a0087e5749eea67b5bce
parente4be9d68121b873de13be494093a234dbfd5d49b (diff)
downloadchouette-core-baaca138b1e72312c16c4e1a35ad3f0470eeb503.tar.bz2
Refs #2626: updating line footnotes, first pass
-rw-r--r--app/assets/stylesheets/application.sass1
-rw-r--r--app/assets/stylesheets/components/_panels.sass27
-rw-r--r--app/assets/stylesheets/typography/_typography.sass4
-rw-r--r--app/controllers/lines_controller.rb26
-rw-r--r--app/views/line_footnotes/_footnote_fields.html.slim8
-rw-r--r--app/views/line_footnotes/edit.html.slim21
-rw-r--r--app/views/line_footnotes/show.html.slim36
-rw-r--r--app/views/referential_lines/show.html.slim4
8 files changed, 109 insertions, 18 deletions
diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass
index e3a875fe1..864fc4b66 100644
--- a/app/assets/stylesheets/application.sass
+++ b/app/assets/stylesheets/application.sass
@@ -18,6 +18,7 @@
@import 'components/forms'
@import 'components/tables'
@import 'components/lists'
+@import 'components/panels'
@import 'components/pagination'
@import 'components/main_nav'
@import 'components/page_header'
diff --git a/app/assets/stylesheets/components/_panels.sass b/app/assets/stylesheets/components/_panels.sass
new file mode 100644
index 000000000..675faf899
--- /dev/null
+++ b/app/assets/stylesheets/components/_panels.sass
@@ -0,0 +1,27 @@
+//----------//
+// Panels //
+//----------//
+
+.panel
+ &.panel-default
+ border-color: rgba($grey, 0.5)
+ border-radius: 0
+ box-shadow: none
+
+ .panel-heading
+ font-size: $h2-size
+ font-weight: 700
+ color: $darkgrey
+ background-color: transparent
+ border-radius: 0
+ border-bottom: 2px solid $darkgrey
+ padding: 5px 15px
+
+ > h3, > h4
+ margin: 0
+
+ .panel-footer
+ padding: 5px 15px
+ background-color: transparent
+ border-radius: 0
+ border: none
diff --git a/app/assets/stylesheets/typography/_typography.sass b/app/assets/stylesheets/typography/_typography.sass
index 649a8cf6e..b08840781 100644
--- a/app/assets/stylesheets/typography/_typography.sass
+++ b/app/assets/stylesheets/typography/_typography.sass
@@ -6,6 +6,10 @@ h2
font-size: $h2-size
font-weight: 700
+h3
+ font-size: $h2-size
+ font-weight: 700
+
p
&:last-child
margin-bottom: 0
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index a0bb4b3c2..cce01e334 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -102,7 +102,31 @@ class LinesController < BreadcrumbController
helper_method :current_referential
def line_params
- params.require(:line).permit( :transport_mode, :network_id, :company_id, :objectid, :object_version, :creator_id, :name, :number, :published_name, :transport_mode, :registration_number, :comment, :mobility_restricted_suitability, :int_user_needs, :flexible_service, :group_of_lines, :group_of_line_ids, :group_of_line_tokens, :url, :color, :text_color, :stable_id, { footnotes_attributes: [ :code, :label, :_destroy, :id ] } )
+ params.require(:line).permit(
+ :transport_mode,
+ :network_id,
+ :company_id,
+ :objectid,
+ :object_version,
+ :creator_id,
+ :name,
+ :number,
+ :published_name,
+ :transport_mode,
+ :registration_number,
+ :comment,
+ :mobility_restricted_suitability,
+ :int_user_needs,
+ :flexible_service,
+ :group_of_lines,
+ :group_of_line_ids,
+ :group_of_line_tokens,
+ :url,
+ :color,
+ :text_color,
+ :stable_id,
+ footnotes_attributes: [:code, :label, :_destroy, :id]
+ )
end
end
diff --git a/app/views/line_footnotes/_footnote_fields.html.slim b/app/views/line_footnotes/_footnote_fields.html.slim
new file mode 100644
index 000000000..27fddc44c
--- /dev/null
+++ b/app/views/line_footnotes/_footnote_fields.html.slim
@@ -0,0 +1,8 @@
+.nested-fields
+ .wrapper
+ div
+ = f.input :code
+ div
+ = f.input :label
+ div
+ = link_to_remove_association '', f, class: 'fa fa-trash', data: { confirm: 'Etes-vous sûr(e) ?' }, title: t('actions.delete')
diff --git a/app/views/line_footnotes/edit.html.slim b/app/views/line_footnotes/edit.html.slim
index f09d99e6d..4bbba8739 100644
--- a/app/views/line_footnotes/edit.html.slim
+++ b/app/views/line_footnotes/edit.html.slim
@@ -1,3 +1,20 @@
-= title_tag t('lines.edit.title', line: @line.name)
+/ PageHeader
+= pageheader 'map-marker',
+ "Notes sur la ligne #{@line.name}",
+ 'Lorem ipsum dolor sit amet',
+ t('last_update', time: l(@line.footnotes.last.updated_at, format: :short))
-= render 'form'
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-12
+ = simple_form_for [@referential, @line], url: referential_line_footnotes_path, html: {id: 'notes_form'} do |form|
+
+ = form.simple_fields_for :footnotes do |f|
+ = render 'footnote_fields', f: f
+
+ .links.nested-linker
+ = link_to_add_association t('footnotes.actions.add_footnote'), form, :footnotes, class: 'btn btn-outline-primary'
+
+ = form.button :submit, 'Enregistrer', class: 'btn btn-default formSubmitr', form: 'notes_form'
diff --git a/app/views/line_footnotes/show.html.slim b/app/views/line_footnotes/show.html.slim
index e8d3c459f..e32d97292 100644
--- a/app/views/line_footnotes/show.html.slim
+++ b/app/views/line_footnotes/show.html.slim
@@ -1,15 +1,25 @@
-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}"
+/ PageHeader
+= pageheader 'map-marker',
+ "Notes sur la ligne #{@line.name}",
+ 'Lorem ipsum dolor sit amet',
+ t('last_update', time: l(@line.footnotes.last.updated_at, format: :short)),
+ (policy(@line).update_footnote? ? link_to(t('actions.edit'), edit_referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary') : '')
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ - if @line.footnotes.any?
+ - @line.footnotes.each do |footnote|
+ .col-lg-4.col-md-4.col-sm-6.col-xs-12
+ .panel.panel-default
+ .panel-heading = footnote.code
+ .panel-body
+ p = footnote.label
+ .panel-footer.text-right
+ p.text-muted
+ em.small = "Dernière mise à jour le #{l(footnote.updated_at, format: :short)}"
-- 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'
+ - else
+ = replacement_msg 'Aucune note ne correspond à votre recherche'
+
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 6711e2361..87e44df93 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -10,7 +10,7 @@
= link_to t('lines.actions.show_network'), [@referential, @line.network], class: 'btn btn-primary'
= link_to t('lines.actions.show_company'), [@referential, @line.company], class: 'btn btn-primary'
- = link_to @line.human_attribute_name(:footnotes), referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary disabled'
+ = link_to @line.human_attribute_name(:footnotes), referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary'
= link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary disabled'
- if policy(Chouette::Line).create? && @referential.organisation == current_organisation
@@ -24,7 +24,7 @@
- if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2)
- if policy(Chouette::Route).create? && @referential.organisation == current_organisation
- = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'btn btn-primary'
+ = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'btn btn-primary disabled'
/ PageContent
.page_content