diff --git a/hyrax/app/assets/javascripts/rdms.js b/hyrax/app/assets/javascripts/rdms.js index d926971d4a09c6e9b394f7b7f4548b4635f4d076..cc65d96163b68fc86f1ffe26555334552466d5ec 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 6f7ca136c7316ccf5e6ac59cfc00cdd6dbe8dcf0..3f38f5de87a74e2012a5e9b9998dae5a136969d1 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 34ee69821d4413b6c513a0689a62c7865348c5a2..2bb508825aac6535db9f42085078b5de67a6af3d 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 2939fa7dd2ca90f19009723d39a888a266365ded..b3527ad79513b672947796da637f33dbf5bfd3b0 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 3b504ceab42f8a7219a711737fdba8d451a80c4e..40edb7d29beb2b5534cd2ff3b38a9837fb1e0399 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