diff options
| author | Vlatka Pavisic | 2017-01-30 14:28:53 +0100 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-01-30 14:29:07 +0100 |
| commit | 8ce5d4f67210990e22a716b82a7d3fb634d80fa9 (patch) | |
| tree | 7130fd33d5178d0c46e6a4b2d8487f118092b08e | |
| parent | d8c77d0c4cfe27747c4f6000fb8b4ef46d5b4be0 (diff) | |
| download | chouette-core-8ce5d4f67210990e22a716b82a7d3fb634d80fa9.tar.bz2 | |
Refs #2474 : Show all referentials in workbenches#show
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 6 | ||||
| -rw-r--r-- | app/models/workbench.rb | 10 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 8 | ||||
| -rw-r--r-- | config/locales/referentials.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/referentials.fr.yml | 2 | ||||
| -rw-r--r-- | spec/features/workbenches_spec.rb | 23 |
6 files changed, 44 insertions, 7 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 4d7bec1dc..7c04eea3d 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -4,7 +4,11 @@ class WorkbenchesController < BreadcrumbController respond_to :html, :only => [:show] def show - @wbench_refs = Workbench.find(params[:id]).referentials.ready.paginate(page: params[:page], per_page: 20) + @wbench_refs = if params[:show_all] + Workbench.find(params[:id]).all_referentials.paginate(page: params[:page], per_page: 20) + else + Workbench.find(params[:id]).referentials.ready.paginate(page: params[:page], per_page: 20) + end show! do build_breadcrumb :show diff --git a/app/models/workbench.rb b/app/models/workbench.rb index 419790edb..21c586873 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -14,4 +14,14 @@ class Workbench < ActiveRecord::Base has_many :referentials has_many :referential_metadatas, through: :referentials, source: :metadatas + + + def all_referentials + if line_ids.empty? + Referential.none + else + Referential.joins(:metadatas).where(['referential_metadata.line_ids && ARRAY[?]', line_ids]).ready + end + end + end diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index a6cef4904..ba36a94db 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -1,7 +1,13 @@ = title_tag "#{@workbench.name} - Tableau de bord" .referentials.paginated_content - h4 Liste des jeux de données + h4 = "Liste des jeux de données#{' (tous)' if params[:show_all]}" + + h5 + - if params[:show_all] + = link_to t('referentials.show.from_this_workbench'), workbench_path(@workbench.id), class: 'button', disabled: params[:archived] + - else + = link_to t('referentials.show.show_all_referentials'), workbench_path(@workbench.id, show_all: true), class: 'button' table.table.table-bordered.table-hover thead diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index 17d77e975..445fd7982 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -10,6 +10,8 @@ en: title: "Data space" clean_up: "Clean up" api_keys: "Authentification keys for an API REST access" + show_all_referentials: Show all referentials + from_this_workbench: Show referentials from this workbench counts: objects: "Data space elements" count: "count" diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index db03eae9f..2c2fb1d10 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -10,6 +10,8 @@ fr: title: "Espace de données" clean_up: "Purge des données obsolètes" api_keys: "Clés d'authentification pour un accès à l'API REST" + show_all_referentials: Voir tous les espaces de données + from_this_workbench: Vour les espaces de données de cet gestion de l'offre counts: objects: "Eléments" count: "Qté" diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb index 1ff39e1be..262991353 100644 --- a/spec/features/workbenches_spec.rb +++ b/spec/features/workbenches_spec.rb @@ -3,15 +3,28 @@ require 'spec_helper' describe 'Workbenches', type: :feature do login_user - let!(:workbench) { create :workbench } - let!(:ready_referential) { create(:referential, workbench: workbench, ready: true) } - let!(:unready_referential) { create(:referential, workbench: workbench) } + let!(:organisations) { Array.new(2) { create :organisation } } + let!(:referentials) { Array.new(2) { create :referential, ready: true } } + let!(:line_referential) { create :line_referential } + let!(:workbenches) { Array.new(2) { create :workbench, line_referential: line_referential } } + let!(:line) { create :line, line_referential: line_referential } + let!(:referential_metadatas) { Array.new(2) { |i| create :referential_metadata, lines: [line], referential: referentials[i] } } + + let!(:ready_referential) { create(:referential, workbench: workbenches.first, ready: true) } + let!(:unready_referential) { create(:referential, workbench: workbenches.first) } describe 'show' do - it 'shows ready referentials belonging to that workbench' do - visit workbench_path(workbench) + it 'shows ready referentials belonging to that workbench by default' do + visit workbench_path(workbenches.first) expect(page).to have_content(ready_referential.name) expect(page).not_to have_content(unready_referential.name) end + + it 'shows all ready referentials if that option is chosen' do + visit workbench_path(workbenches.first) + click_link I18n.t('referentials.show.show_all_referentials') + expect(page).to have_content(referentials.first.name) + expect(page).to have_content(referentials.last.name) + end end end |
