diff options
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 15 | ||||
| -rw-r--r-- | app/javascript/referential_overview/index.coffee | 13 | ||||
| -rw-r--r-- | app/models/calendar.rb | 2 | ||||
| -rw-r--r-- | app/policies/workbench_policy.rb | 11 | ||||
| -rw-r--r-- | app/views/referentials/_overview.html.slim | 3 | ||||
| -rw-r--r-- | app/views/workbenches/_form.html.slim | 9 | ||||
| -rw-r--r-- | app/views/workbenches/edit.html.slim | 8 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 2 | ||||
| -rw-r--r-- | config/deploy.rb | 4 | ||||
| -rw-r--r-- | config/locales/workbenches.en.yml | 15 | ||||
| -rw-r--r-- | config/locales/workbenches.fr.yml | 15 | ||||
| -rw-r--r-- | config/routes.rb | 2 | ||||
| -rw-r--r-- | db/migrate/20180208174834_add_attributes_to_workbench.rb | 9 | ||||
| -rw-r--r-- | db/schema.rb | 16 | ||||
| -rw-r--r-- | spec/models/chouette/time_table_spec.rb | 1 |
15 files changed, 109 insertions, 16 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 2a71fe811..a7786bc8b 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -3,7 +3,10 @@ class WorkbenchesController < ChouetteController include RansackDateFilter before_action only: [:show] { set_date_time_params("validity_period", Date) } defaults resource_class: Workbench - respond_to :html, only: [:show, :index] + + include PolicyChecker + + respond_to :html def index redirect_to dashboard_path @@ -24,7 +27,10 @@ class WorkbenchesController < ChouetteController current_workbench_id: params[:id] } ) - show! + end + + def edit + edit! end def delete_referentials @@ -38,6 +44,11 @@ class WorkbenchesController < ChouetteController end private + + def workbench_params + params.require(:workbench).permit(:import_compliance_control_set_id, :merge_compliance_control_set_id) + end + def resource @workbench = current_organisation.workbenches.find params[:id] end diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee index 0e6541421..7ab8b1904 100644 --- a/app/javascript/referential_overview/index.coffee +++ b/app/javascript/referential_overview/index.coffee @@ -110,4 +110,17 @@ class window.ReferentialOverview + + documentScroll: (e)-> + if @sticky + if e.pageY < @top() || e.pageY > @bottom() + @container.removeClass "sticky" + @sticky = false + else + if e.pageY > @top() && e.pageY < @bottom() + @sticky = true + @container.addClass "sticky" + + + export default ReferentialOverview diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 84b569ab4..a7ad516af 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -21,6 +21,8 @@ class Calendar < ActiveRecord::Base after_initialize :set_defaults + after_initialize :set_defaults + def self.ransackable_scopes(auth_object = nil) [:contains_date] end diff --git a/app/policies/workbench_policy.rb b/app/policies/workbench_policy.rb new file mode 100644 index 000000000..7b925e91a --- /dev/null +++ b/app/policies/workbench_policy.rb @@ -0,0 +1,11 @@ +class WorkbenchPolicy < ApplicationPolicy + class Scope < Scope + def resolve + scope + end + end + + def update? + true + end +end diff --git a/app/views/referentials/_overview.html.slim b/app/views/referentials/_overview.html.slim index 143784800..f79b1cf49 100644 --- a/app/views/referentials/_overview.html.slim +++ b/app/views/referentials/_overview.html.slim @@ -69,7 +69,6 @@ javascript: overview_id = "#{overview.pagination_param_name}"; - coffee: $ => - new ReferentialOverview("##{overview_id}") + new ReferentialOverview("##{overview_id}")
\ No newline at end of file diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim new file mode 100644 index 000000000..5ee17dc17 --- /dev/null +++ b/app/views/workbenches/_form.html.slim @@ -0,0 +1,9 @@ += simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form do |f| + .row + .col-lg-12 + = f.input :import_compliance_control_set_id, as: :select, collection: ComplianceControlSet.where(organisation: current_organisation), value_method: lambda {|t| t.id} + = f.input :merge_compliance_control_set_id, as: :select, collection: ComplianceControlSet.where(organisation: current_organisation), value_method: lambda {|t| t.id} + + .separator + + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workbench_form' diff --git a/app/views/workbenches/edit.html.slim b/app/views/workbenches/edit.html.slim new file mode 100644 index 000000000..893024490 --- /dev/null +++ b/app/views/workbenches/edit.html.slim @@ -0,0 +1,8 @@ +- breadcrumb @workbench +- page_header_content_for @workbench + +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index aae34c51b..8ea942178 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -3,6 +3,8 @@ - content_for :page_header_content do .row.mb-sm .col-lg-12.text-right + - if policy(Workbench).update? + = link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary' - if policy(Referential).create? = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary' = link_to t('actions.add'), new_referential_path(workbench_id: @workbench), class: 'btn btn-primary' diff --git a/config/deploy.rb b/config/deploy.rb index 136c60196..833ecfbbe 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -16,6 +16,10 @@ set :default_environment, { 'PATH' => "/var/lib/gems/#{ruby_version}/bin:$PATH" } +set :default_environment, { + 'PATH' => "/var/lib/gems/#{ruby_version}/bin:$PATH" +} + set :keep_releases, -> { fetch(:kept_releases, 5) } after "deploy:restart", "deploy:cleanup" diff --git a/config/locales/workbenches.en.yml b/config/locales/workbenches.en.yml index 7f21f47a0..6e4c9b567 100644 --- a/config/locales/workbenches.en.yml +++ b/config/locales/workbenches.en.yml @@ -2,6 +2,14 @@ en: workbenches: show: title: "%{name}" + edit: + title: "Configure the workbench" + update: + title: "Configure the workbench" + referential_count: + zero: "There is no referential in your workbench" + one: "There is one referential in your workbench" + other: "There are #{count} referentials in your workbench" index: title: "%{organisation} dashboard" offers: @@ -12,10 +20,9 @@ en: calendars: "Calendars" see: "See the list" no_content: "No content yet." - referential_count: - zero: "There is no referential in your workbench" - one: "There is one referential in your workbench" - other: "There are #{count} referentials in your workbench" + actions: + show_output: "Merge offer" + affect_ccset: "Configure" activerecord: models: workbench: diff --git a/config/locales/workbenches.fr.yml b/config/locales/workbenches.fr.yml index e7a392e66..0728fbf4e 100644 --- a/config/locales/workbenches.fr.yml +++ b/config/locales/workbenches.fr.yml @@ -2,12 +2,27 @@ fr: workbenches: show: title: "%{name}" + edit: + title: "Configurer l'espace de travail" + update: + title: "Configurer l'espace de travail" referential_count: zero: "Aucun jeu de données dans cet espace de travail" one: "1 jeu de données dans cet espace de travail" other: "#{count} jeux de données dans cet espace de travail" + index: + title: "%{organisation} dashboard" + offers: + title: "Transport offers" + organisation: "Organisation offers" + idf: "IDF offers" + referentials: "Referentials" + calendars: "Calendars" + see: "See the list" + no_content: "No content yet." actions: show_output: "Finaliser l'Offre" + configure: "Configurer" activerecord: models: workbench: diff --git a/config/routes.rb b/config/routes.rb index 0b657b028..b01bba18d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ require 'sidekiq/web' ChouetteIhm::Application.routes.draw do resource :dashboard - resources :workbenches, only: [:show, :index] do + resources :workbenches, except: [:destroy] do delete :referentials, on: :member, action: :delete_referentials resources :imports do get :download, on: :member diff --git a/db/migrate/20180208174834_add_attributes_to_workbench.rb b/db/migrate/20180208174834_add_attributes_to_workbench.rb new file mode 100644 index 000000000..02002a772 --- /dev/null +++ b/db/migrate/20180208174834_add_attributes_to_workbench.rb @@ -0,0 +1,9 @@ +class AddAttributesToWorkbench < ActiveRecord::Migration + def change + add_column :workbenches, :import_compliance_control_set_id, :integer, limit: 8 + add_column :workbenches, :merge_compliance_control_set_id, :integer, limit: 8 + + add_index :workbenches, :import_compliance_control_set_id + add_index :workbenches, :merge_compliance_control_set_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 596682ce8..4bd8e3eca 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180202170009) do +ActiveRecord::Schema.define(version: 20180208174834) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -999,17 +999,21 @@ ActiveRecord::Schema.define(version: 20180202170009) do create_table "workbenches", id: :bigserial, force: :cascade do |t| t.string "name" - t.integer "organisation_id", limit: 8 + t.integer "organisation_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" - t.integer "line_referential_id", limit: 8 - t.integer "stop_area_referential_id", limit: 8 - t.integer "output_id", limit: 8 + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.integer "output_id", limit: 8 t.string "objectid_format" - t.integer "workgroup_id", limit: 8 + t.integer "workgroup_id", limit: 8 + t.integer "import_compliance_control_set_id", limit: 8 + t.integer "merge_compliance_control_set_id", limit: 8 end + add_index "workbenches", ["import_compliance_control_set_id"], name: "index_workbenches_on_import_compliance_control_set_id", using: :btree add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree + add_index "workbenches", ["merge_compliance_control_set_id"], name: "index_workbenches_on_merge_compliance_control_set_id", using: :btree add_index "workbenches", ["organisation_id"], name: "index_workbenches_on_organisation_id", using: :btree add_index "workbenches", ["stop_area_referential_id"], name: "index_workbenches_on_stop_area_referential_id", using: :btree add_index "workbenches", ["workgroup_id"], name: "index_workbenches_on_workgroup_id", using: :btree diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb index bb88877b9..fe4bd3cfa 100644 --- a/spec/models/chouette/time_table_spec.rb +++ b/spec/models/chouette/time_table_spec.rb @@ -926,7 +926,6 @@ end end end end - describe "#validity_out_between?" do let(:empty_tm) {build(:time_table)} it "should be false if empty calendar" do |
