aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2016-11-18 16:38:15 +0100
committerjpl2016-11-18 16:38:15 +0100
commit11163e32ecd718d2e338deda8e3c11d7954f1ece (patch)
tree729d8f74c71a1ca06ac889b3559b2a5e3768ee34
parent37e2519ca0e0131a5b7ea7c3c7bf16833b15703f (diff)
downloadchouette-core-11163e32ecd718d2e338deda8e3c11d7954f1ece.tar.bz2
Refs #1989: adding paginate to workbench refs + add_new link
-rw-r--r--app/controllers/referentials_controller.rb9
-rw-r--r--app/controllers/workbenches_controller.rb2
-rw-r--r--app/helpers/breadcrumb_helper.rb4
-rw-r--r--app/views/referentials/_form.html.slim1
-rw-r--r--app/views/workbenches/show.html.slim13
5 files changed, 25 insertions, 4 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 003c85d3a..ab494ac2e 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -8,11 +8,18 @@ class ReferentialsController < BreadcrumbController
def new
@referential = Referential.new_from(Referential.find(params[:from])) if params[:from]
+
new! do
@referential.data_format = current_organisation.data_format
+ @referential.workbench_id = params[:workbench_id] if params[:workbench_id]
end
end
+ def create
+
+ create!
+ end
+
def show
resource.switch
show! do |format|
@@ -24,7 +31,6 @@ class ReferentialsController < BreadcrumbController
:referential_id => resource.id}
}
format.html { build_breadcrumb :show}
-
end
end
@@ -76,6 +82,7 @@ class ReferentialsController < BreadcrumbController
:data_format,
:archived_at,
:created_from_id,
+ :workbench_id,
referential_metadata_attributes: [:referential_source_id, :line_ids => []]
)
end
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 1d67db3ab..b23e9202e 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -4,6 +4,8 @@ class WorkbenchesController < BreadcrumbController
respond_to :html, :only => [:show]
def show
+ @wbench_refs = Workbench.find(params[:id]).referentials.paginate(page: params[:page], per_page: 2)
+
show! do
build_breadcrumb :show
end
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 683036032..9d503fe2e 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -237,6 +237,10 @@ module BreadcrumbHelper
def referential_breadcrumb (action = :edit)
organisation_breadcrumb
if @referential
+ if workbench = @referential.workbench
+ add_breadcrumb breadcrumb_label(workbench), workbench_path(workbench), :title => breadcrumb_tooltip(workbench)
+ end
+
add_breadcrumb breadcrumb_label(@referential), referential_path(@referential),:title => breadcrumb_tooltip(@referential) if action == :edit || action == :show || action == :update
end
end
diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim
index 1a0d5f105..4ac5d1121 100644
--- a/app/views/referentials/_form.html.slim
+++ b/app/views/referentials/_form.html.slim
@@ -23,6 +23,7 @@
= form.input :upper_corner, input_html: { title: t("formtastic.titles.referential.upper_corner") }
= form.input :lower_corner, input_html: { title: t("formtastic.titles.referential.lower_corner") }
= form.input :data_format, label: true, include_blank: false
+ = form.input :workbench_id, as: :hidden
= form.actions do
= form.action :submit, as: :button
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 801714bc7..cb83b028c 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -3,8 +3,6 @@
.referentials.paginated_content
h4 Liste des jeux de données
- / = paginated_content @workbench.referentials
-
table.table.table-bordered.table-hover
thead
tr
@@ -18,7 +16,7 @@
th = "Actions"
tbody
- - @workbench.referentials.each do |referential|
+ - @wbench_refs.each do |referential|
tr
td = referential.name
td = l referential.updated_at, format: :long
@@ -62,3 +60,12 @@
= link_to referential_path(referential), method: :delete, :data => {:confirm => t('referentials.actions.destroy_confirm')}, class: 'btn btn-danger' do
span.fa.fa-trash-o
+
+ .text-center
+ = will_paginate @wbench_refs, container: false, renderer: RemoteBootstrapPaginationLinkRenderer
+
+- content_for :sidebar do
+ ul.actions
+ li = link_to t('referentials.actions.new'), new_referential_path(workbench_id: @workbench), class: 'add'
+
+