Skip to content

Commit

Permalink
Completed merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dea committed Jul 24, 2024
2 parents e75bc92 + 6d7e894 commit f2ff5a9
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions app/static/js/createEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function calculateRecurringEventFrequency(){
//Requires that modal info updated before it can be saved, gives notifier if there are empty fields
let eventNameInputs = document.querySelectorAll('.multipleOfferingNameField');
let datePickerInputs = document.querySelectorAll('.multipleOfferingDatePicker');

let startTimeInputs = document.querySelectorAll('.multipleOfferingStartTime');
let endTimeInputs = document.querySelectorAll('.multipleOfferingEndTime');
let isEmpty = false;
let timeCheck = false;
eventNameInputs.forEach(eventNameInput => {
// Check if the input field is empty
if (eventNameInput.value.trim() === '') {
Expand All @@ -78,10 +80,27 @@ function calculateRecurringEventFrequency(){
// Check if the input field is empty
if (datePickerInput.value.trim() === '') {
isEmpty = true;
$(datePickerInput).addClass('border-red');
} else {
$(datePickerInput).removeClass('border-red');
}
});
});

for(let i = 0; i < startTimeInputs.length; i++){
if(startTimeInputs[i].value >= endTimeInputs[i].value){
console.log(startTimeInputs[i]);
console.log(endTimeInputs[i]);
timeCheck = true;
}
console.log(timeCheck);
}

for(let i = 0; i < startTimeInputs.length; i++)
{
if (startTimeInputs[i] >= endTimeInputs[i])
{timeCheck = true;}
}

if (isEmpty){
$('#textNotifierPadding').addClass('pt-5');
$('.invalidFeedback').text("Event name or date field is empty");
Expand All @@ -93,6 +112,17 @@ function calculateRecurringEventFrequency(){
isEmpty = false;
}

else if(timeCheck){
$('#textNotifierPadding').addClass('pt-5');
$('.invalidFeedback').text("End time must be after start time.");
$('.invalidFeedback').css('display', 'block');
$('.invalidFeedback').on('animationend', function() {
$('.invalidFeedback').css('display', 'none');
$('#textNotifierPadding').removeClass('pt-5')
});
timeCheck = false;
}

else {
storeMultipleOfferingEventAttributes();
pendingmultipleEvents = []
Expand All @@ -102,13 +132,12 @@ function calculateRecurringEventFrequency(){
$('#modalMultipleOffering').modal('hide');
msgFlash("Multiple time offering events saved!", "success");
}
});
});
//build multi-event table
function storeMultipleOfferingEventAttributes() {
let entries = [];
$(".extraSlots").children().each(function(index, element) {
let rowData = $.map($(element).find("input"), (el) => $(el).val());

entries.push({
eventName: rowData[0],
eventDate: rowData[1],
Expand Down Expand Up @@ -187,12 +216,8 @@ $(document).ready(function() {
$('#multipleOfferingTableDiv').addClass('d-none');
$(".endDatePicker").prop('required', true);
}
else{
//adds the display none button of bootstrap so that the end-date div disappears for recurring event
$(".endDateStyle, #recurringTableDiv").addClass('d-none');
$(".endDatePicker").prop('required', false);
}
if (multipleOfferingStatus == true) {

else if (multipleOfferingStatus == true) {
$(".startDatePicker").prop('required', false);
$("#multipleOfferingTableDiv").removeClass('d-none');
$("#checkIsRecurring").prop('checked', false);
Expand All @@ -201,7 +226,10 @@ $(document).ready(function() {
//hides the non multiple offering time and dates and replace
$('#nonMultipleOfferingTime, #nonMultipleOfferingDate').addClass('d-none');
}
else{
else {
//adds the display none button of bootstrap so that the end-date div disappears for recurring even
$(".endDateStyle, #recurringTableDiv").addClass('d-none');
$(".endDatePicker").prop('required', false);
//set page UI back to default
$("#multipleOfferingTableDiv").addClass('d-none');
$('#modalMultipleOffering').modal('hide');
Expand Down

0 comments on commit f2ff5a9

Please sign in to comment.