aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/application.js6
-rw-r--r--app/decorators/route_decorator.rb3
-rw-r--r--app/helpers/table_builder_helper.rb7
-rw-r--r--app/models/user.rb2
4 files changed, 13 insertions, 5 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 6a79f7e8e..3eaade37f 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -25,3 +25,9 @@
//= require "i18n"
//= require "i18n/extended"
//= require "i18n/translations"
+
+$(document).ready(function() {
+ $('a[disabled=disabled]').click(function(event){
+ event.preventDefault(); // Prevent link from following its href
+ });
+});
diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb
index 4a173cbb9..646bc1620 100644
--- a/app/decorators/route_decorator.rb
+++ b/app/decorators/route_decorator.rb
@@ -74,10 +74,11 @@ class RouteDecorator < AF83::Decorator
instance_decorator.action_link(
secondary: :show,
policy: :create_opposite,
- if: ->{h.has_feature?(:create_opposite_routes) && object.opposite_route.nil?}
+ if: ->{h.has_feature?(:create_opposite_routes)}
) do |l|
l.content h.t('routes.create_opposite.title')
l.method :post
+ l.disabled { object.opposite_route.present? }
l.href do
h.duplicate_referential_line_route_path(
context[:referential],
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 63125b161..e2aa2e9ea 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -402,9 +402,10 @@ module TableBuilderHelper
content_tag(
:li,
link_to(
- link.href,
- method: link.method,
- data: link.data
+ link.disabled ? '#' : link.href,
+ method: link.disabled ? nil : link.method,
+ data: link.data,
+ disabled: link.disabled
) do
link.content
end,
diff --git a/app/models/user.rb b/app/models/user.rb
index 29148d9e9..ba166b06f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -9,7 +9,7 @@ class User < ApplicationModel
:recoverable, :rememberable, :trackable, :async, authentication_type
# FIXME https://github.com/nbudin/devise_cas_authenticatable/issues/53
- # Work around :validatable, when database_authenticatable is diabled.
+ # Work around :validatable, when database_authenticatable is disabled.
attr_accessor :password unless authentication_type == :database_authenticatable
# Setup accessible (or protected) attributes for your model