From 7ba86f83164e142f30c3fbf94a75a338b411aa6a Mon Sep 17 00:00:00 2001 From: Gyan Gupta <gyan@cottagelabs.com> Date: Fri, 20 Dec 2024 13:50:59 +0530 Subject: [PATCH] fixes for accessibility of complex objects --- hyrax/app/assets/javascripts/rdms.js | 30 ++++++++++--------- .../complex_modalities_controller.rb | 8 ++--- .../complex_sessions_controller.rb | 8 ++--- .../complex_subjects_controller.rb | 6 +--- hyrax/app/helpers/complex_helper.rb | 11 +++++++ 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/hyrax/app/assets/javascripts/rdms.js b/hyrax/app/assets/javascripts/rdms.js index d926971d..cc65d961 100644 --- a/hyrax/app/assets/javascripts/rdms.js +++ b/hyrax/app/assets/javascripts/rdms.js @@ -2,21 +2,23 @@ $(document).on('ready', function() { if ($('#agreementModal').length > 0){ $('#agreementModal').modal('show'); } - + let scrollTimeout; $('#agreementModal .modal-body').on('scroll', function() { action_buttons = $('#agreementModal .modal-footer > a') - - if ($(this)[0].scrollTop + $(this)[0].clientHeight >= $(this)[0].scrollHeight) { - // Enable the buttons when user reaches the bottom - action_buttons.attr('disabled', false); - action_buttons.each(function(){ - $(this).attr('href', $(this).data('url')) - }) - - } - else{ - action_buttons.attr('disabled', 'disabled'); - action_buttons.attr('href', "javascript:void(0)") - } + clearTimeout(scrollTimeout); + scrollTimeout = setTimeout(() => { + if (($(this)[0].scrollTop + $(this)[0].clientHeight + 10) >= $(this)[0].scrollHeight) { + // Enable the buttons when user reaches the bottom + action_buttons.attr('disabled', false); + action_buttons.each(function(){ + $(this).attr('href', $(this).data('url')) + }) + + } + else{ + action_buttons.attr('disabled', 'disabled'); + action_buttons.attr('href', "javascript:void(0)") + } + }, 500); }); }); diff --git a/hyrax/app/controllers/hyrax/crc_datasets/complex_modalities_controller.rb b/hyrax/app/controllers/hyrax/crc_datasets/complex_modalities_controller.rb index 6f7ca136..3f38f5de 100644 --- a/hyrax/app/controllers/hyrax/crc_datasets/complex_modalities_controller.rb +++ b/hyrax/app/controllers/hyrax/crc_datasets/complex_modalities_controller.rb @@ -4,11 +4,11 @@ module Hyrax module CrcDatasets class ComplexModalitiesController < ApplicationController include ComplexHelper - before_action :set_crc_dataset, except: %i[validate_modality_title] + before_action :set_crc_dataset before_action :set_complex_session, only: %i[new create validate_modality_title] before_action :set_complex_modality, only: %i[show edit update] before_action :check_tombstone, except: %i[validate_modality_title] - before_action :authorize, only: [:new, :edit] + before_action :authorize with_themed_layout :decide_layout def new @@ -108,10 +108,6 @@ module Hyrax redirect_to main_app.polymorphic_path(@crc_dataset) end end - - def authorize - redirect_to main_app.polymorphic_path(@crc_dataset) unless current_user.can?(:edit, @crc_dataset) - end end end end diff --git a/hyrax/app/controllers/hyrax/crc_datasets/complex_sessions_controller.rb b/hyrax/app/controllers/hyrax/crc_datasets/complex_sessions_controller.rb index 34ee6982..2bb50882 100644 --- a/hyrax/app/controllers/hyrax/crc_datasets/complex_sessions_controller.rb +++ b/hyrax/app/controllers/hyrax/crc_datasets/complex_sessions_controller.rb @@ -5,11 +5,11 @@ module Hyrax class ComplexSessionsController < ApplicationController include HyraxHelper include ComplexHelper - before_action :set_crc_dataset, except: %i[validate_session_title] + before_action :set_crc_dataset before_action :set_complex_subject, only: %i[new create validate_session_title] before_action :set_complex_session, only: %i[show edit update] before_action :check_tombstone, except: %i[validate_session_title] - before_action :authorize, only: [:new, :edit] + before_action :authorize with_themed_layout :decide_layout def new @@ -110,10 +110,6 @@ module Hyrax redirect_to main_app.polymorphic_path(@crc_dataset) end end - - def authorize - redirect_to main_app.polymorphic_path(@crc_dataset) unless current_user.can?(:edit, @crc_dataset) - end end end end diff --git a/hyrax/app/controllers/hyrax/crc_datasets/complex_subjects_controller.rb b/hyrax/app/controllers/hyrax/crc_datasets/complex_subjects_controller.rb index 2939fa7d..b3527ad7 100644 --- a/hyrax/app/controllers/hyrax/crc_datasets/complex_subjects_controller.rb +++ b/hyrax/app/controllers/hyrax/crc_datasets/complex_subjects_controller.rb @@ -8,7 +8,7 @@ module Hyrax before_action :set_crc_dataset before_action :set_complex_subject, only: %i[show edit update] before_action :check_tombstone, except: %i[validate_subject_title] - before_action :authorize, only: [:new, :edit] + before_action :authorize with_themed_layout :decide_layout def new @@ -101,10 +101,6 @@ module Hyrax redirect_to main_app.polymorphic_path(@crc_dataset) end end - - def authorize - redirect_to main_app.polymorphic_path(@crc_dataset) unless current_user.can?(:edit, @crc_dataset) - end end end end diff --git a/hyrax/app/helpers/complex_helper.rb b/hyrax/app/helpers/complex_helper.rb index 3b504cea..40edb7d2 100644 --- a/hyrax/app/helpers/complex_helper.rb +++ b/hyrax/app/helpers/complex_helper.rb @@ -30,4 +30,15 @@ module ComplexHelper title.sub!(/-s3alias\z/i, '') title end + + private + + def authorize + case action_name + when 'show' + authorize! :show, @crc_dataset + else + authorize! :edit, @crc_dataset + end + end end \ No newline at end of file -- GitLab