Skip to content

Commit

Permalink
Fixup the AdminUser#index page, some specs
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Mar 12, 2024
1 parent a7ea6e7 commit 7f33e50
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 62 deletions.
54 changes: 1 addition & 53 deletions app/assets/javascripts/osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function get_color() {
}

function word_count(text, divId, maxcount) {
if (!text) { return; }
var area = document.getElementById(text.id)

Countable.once(area, function(counter) {
Expand Down Expand Up @@ -162,59 +163,6 @@ function replace_defaut_submission_text(input_selector, new_text, valid_defaults
});
}

// TODO-SNAPCON: Verify what is on the proposals _from from upstream
/* Wait for the DOM to be ready before attaching events to the elements */
$( document ).ready(function() {
/* Set the minimum and maximum proposal abstract word length */
function updateEventTypeRequirements() {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
var min = $selected.data("min-words");

// We replace the default text only if the current field is empty,
// or is set to the default text of another event type.
replace_defaut_submission_text(
'#event_submission_text',
$selected.data("instructions"),
$("#event_event_type_id option").toArray().map(e => $(e).data('instructions'))
);

$("#abstract-maximum-word-count").text(max);
$("#submission-maximum-word-count").text(max);
$("#abstract-minimum-word-count").text(min);
$("#submission-minimum-word-count").text(min);
word_count($('#event_abstract').get(0), 'abstract-count', max);
}
$("#event_event_type_id").change(updateEventTypeRequirements);
updateEventTypeRequirements();

/* Count the proposal abstract length */
$("#event_abstract").on('input', function() {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'abstract-count', max);
} );

/* Count the submission text length */
$("#event_submission_text").bind('change keyup paste input', function() {
var $selected = $("event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'submission-count', max);
});

/* Listen for reset template button, wait for confirm, and reset. */
$('.js-resetSubmissionText').click((e) => {
let $selected = $("#event_event_type_id option:selected");
let $this = $(e.target);
let affirm = confirm($this.data('confirm'));
if (affirm) {
let sub_text = $('#event_submission_text');
sub_text.val($selected.data('instructions'));
sub_text.trigger('change');
}
});
});

/* Commodity function for modal windows */

window.build_dialog = function(selector, content) {
Expand Down
10 changes: 7 additions & 3 deletions app/views/admin/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
%tr
%th{ width: '0' } ID
%th{ width: '0' } Confirmed?
%th{ width: '0' } Email
%th{ width: '30%' } Name
%th{ width: '20%' } Conferences Attended
%th{ width: '0' } Name
%th{ width: '0' } EMail
%th{ width: '0' } Username
%th{ width: '15%' }
Conferences
%br
Attended
%th{ width: '50%' } Roles
%th{ width: '0' } Actions
%th{ style: 'display: none' } Confirmed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
Dear <%= @user.name %>,

Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>.

Please, find the ticket(s) pdf attached.

The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to [email protected].

Best wishes,
<%= @conference.title %> Team
<%= @conference.title %> Team
</span>
</div>
<%= render partial: "layouts/mailbot_footer" %>
<%= render partial: "layouts/mailbot_footer" %>
27 changes: 27 additions & 0 deletions app/views/proposals/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
var max = $selected.data("max-words");
var min = $selected.data("min-words");

// We replace the default text only if the current field is empty,
// or is set to the default text of another event type.
replace_defaut_submission_text(
'#event_submission_text',
$selected.data("instructions"),
$("#event_event_type_id option").toArray().map(e => $(e).data('instructions'))
);

$("#abstract-maximum-word-count").text(max);
$("#abstract-minimum-word-count").text(min);
word_count($('#event_abstract').get(0), 'abstract-count', max);
Expand All @@ -120,4 +128,23 @@
var max = $selected.data("max-words");
word_count(this, 'abstract-count', max);
} );

/* Count the submission text length */
$("#event_submission_text").bind('change keyup paste input', function() {
var $selected = $("event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'submission-count', max);
});

/* Listen for reset template button, wait for confirm, and reset. */
$('.js-resetSubmissionText').click((e) => {
let $selected = $("#event_event_type_id option:selected");
let $this = $(e.target);
let affirm = confirm($this.data('confirm'));
if (affirm) {
let sub_text = $('#event_submission_text');
sub_text.val($selected.data('instructions'));
sub_text.trigger('change');
}
});
});
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_02_26_175634) do

# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"
Expand Down
3 changes: 3 additions & 0 deletions spec/features/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
shared_examples 'admin ability' do
scenario 'edits a user', feature: true, js: true do
visit admin_users_path
wait_for_ajax
# sleep 3
debugger
within "tr#user_#{user.id}" do
click_on 'Edit'
end
Expand Down
16 changes: 16 additions & 0 deletions spec/support/wait_for_ajax..rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
puts '...waiting...'
loop until finished_all_ajax_requests?
end
end

def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
end

RSpec.configure do |config|
config.include WaitForAjax, type: :feature
end

0 comments on commit 7f33e50

Please sign in to comment.