aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/referential_companies_controller.rb3
-rw-r--r--app/decorators/line_decorator.rb3
-rw-r--r--app/helpers/table_builder_helper.rb9
-rw-r--r--app/javascript/vehicle_journeys/components/Tools.js4
-rw-r--r--app/views/lines/_form.html.slim3
-rw-r--r--app/views/lines/index.html.slim2
-rw-r--r--app/views/lines/show.html.slim2
-rw-r--r--app/views/referentials/show.html.slim2
8 files changed, 15 insertions, 13 deletions
diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb
index ca1ff67db..7e65a72cf 100644
--- a/app/controllers/referential_companies_controller.rb
+++ b/app/controllers/referential_companies_controller.rb
@@ -35,7 +35,8 @@ class ReferentialCompaniesController < ChouetteController
def collection
scope = referential.line_referential.companies
if params[:line_id]
- scope = referential.line_referential.lines.find(params[:line_id]).companies
+ line_scope = referential.line_referential.lines.find(params[:line_id]).companies
+ scope = line_scope if line_scope.exists?
end
@q = scope.search(params[:q])
diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb
index fe0750b05..9c0cf7292 100644
--- a/app/decorators/line_decorator.rb
+++ b/app/decorators/line_decorator.rb
@@ -18,7 +18,8 @@ class LineDecorator < Draper::Decorator
links << Link.new(
content: h.t('lines.actions.show_company'),
- href: [context[:line_referential], object.company]
+ href: [context[:line_referential], object.company],
+ disabled: object.company.nil?
)
if h.policy(Chouette::Line).create? &&
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 96b2889da..560537eeb 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -368,10 +368,11 @@ module TableBuilderHelper
end
def gear_menu_link(link)
- klass = [link.extra_class]
+ klass = []
+ klass << link.extra_class if link.extra_class
klass << 'delete-action' if link.method == :delete
- klass = klass.compact.join(' ')
- klass = nil unless klass.present?
+ klass << 'disabled' if link.disabled
+
content_tag(
:li,
link_to(
@@ -381,7 +382,7 @@ module TableBuilderHelper
) do
link.content
end,
- class: klass
+ class: klass.join(' ')
)
end
diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js
index 7621dfc10..1ef576529 100644
--- a/app/javascript/vehicle_journeys/components/Tools.js
+++ b/app/javascript/vehicle_journeys/components/Tools.js
@@ -17,7 +17,7 @@ export default class Tools extends Component {
hasPolicy(key) {
// Check if the user has the policy to disable or not the action
- return this.props.filters.policy[`vehicle_journeys.${key}`]
+ return this.props.filters.policy[`vehicle_journeys.${key}`]
}
render() {
@@ -45,4 +45,4 @@ Tools.propTypes = {
vehicleJourneys : PropTypes.array.isRequired,
onCancelSelection: PropTypes.func.isRequired,
filters: PropTypes.object.isRequired
-} \ No newline at end of file
+}
diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim
index de0308289..909d6512e 100644
--- a/app/views/lines/_form.html.slim
+++ b/app/views/lines/_form.html.slim
@@ -3,7 +3,7 @@
.col-lg-12
= f.input :name
= f.input :network_id, as: :select, :collection => @line_referential.networks, include_blank: false
- = f.input :company_id, as: :select, :collection => @line_referential.companies, include_blank: false
+ = f.input :company_id, as: :select, :collection => @line_referential.companies, include_blank: true
= f.input :secondary_company_ids, :collection => @line_referential.companies, include_blank: false, input_html: { multiple: true, 'data-select2ed': true }, label: t('activerecord.attributes.line.secondary_company')
= f.input :published_name
= f.input :registration_number
@@ -20,4 +20,3 @@
.separator
= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'lines_form'
-
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index 8b035b477..e94837ed5 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -41,7 +41,7 @@
), \
TableBuilderHelper::Column.new( \
key: 'companies.name', \
- attribute: Proc.new { |n| n.try(:company).try(:name) } \
+ attribute: Proc.new { |n| n&.company&.name || "-" } \
), \
TableBuilderHelper::Column.new( \
key: :transport_mode, \
diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim
index d62fe30d6..83244f739 100644
--- a/app/views/lines/show.html.slim
+++ b/app/views/lines/show.html.slim
@@ -6,7 +6,7 @@
= link_to link.href,
method: link.method,
data: link.data,
- class: 'btn btn-primary' do
+ class: "btn btn-primary #{link.disabled ? "disabled" : ""}" do
= link.content
- page_header_content_for @line
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 9852fb0a3..96755359c 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -68,7 +68,7 @@
), \
TableBuilderHelper::Column.new( \
key: 'companies.name', \
- attribute: Proc.new { |n| n.try(:company).try(:name) } \
+ attribute: Proc.new { |n| n&.company&.name || "-" } \
) \
],
links: [:show],