Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timepicker issue #1288

Open
wants to merge 13 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 39 additions & 30 deletions app/static/js/createEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let pendingmultipleEvents = []
// updates max and min dates of the datepickers as the other datepicker changes
// No need for / for Firefox compatiblity
function updateDate(obj) {
var selectedDate = $(obj).datepicker("getDate");
var selectedDate = $(obj).datepicker("getDate"); // No need for / for Firefox compatibility

var newMonth = selectedDate.getMonth();
var newYear = selectedDate.getFullYear();
var newDay = selectedDate.getDate();
Expand Down Expand Up @@ -88,16 +89,13 @@ function calculateRecurringEventFrequency(){

for(let i = 0; i < startTimeInputs.length; i++){
if(startTimeInputs[i].value >= endTimeInputs[i].value){
console.log(startTimeInputs[i]);
console.log(endTimeInputs[i]);
$(startTimeInputs[i]).addClass('border-red');
$(endTimeInputs[i]).addClass('border-red');
timeCheck = true;
}else{
$(startTimeInputs[i]).removeClass('border-red');
$(endTimeInputs[i]).removeClass('border-red');
}
console.log(timeCheck);
}
if (isEmpty){
$('#textNotifierPadding').addClass('pt-5');
Expand Down Expand Up @@ -136,7 +134,23 @@ function storeMultipleOfferingEventAttributes() {
let entries = [];
$(".extraSlots").children().each(function(index, element) {
let rowData = $.map($(element).find("input"), (el) => $(el).val());
// Initialize timepicker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation on this timepicker block of code is weird and the .extraSlots function does not close, causing some errors on my end.

$('.timepicker').timepicker({
timeFormat: 'h:mm p',
interval: 15,
minTime: '12:00am',
maxTime: '11:45pm',
defaultTime: '11:00am',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am now hitting errors, but before I was I saw that the time for both time pickers was 11:00 am. We want to by default have the times an hour apart. For instance start time is noon and end time is 1pm.

startTime: '8:00am',
dynamic: false,
dropdown: true,
scrollbar: true
});


// Update datepicker min and max dates on change
$(".startDatePicker, .endDatePicker").change(function () {
updateDate(this);
entries.push({
eventName: rowData[0],
eventDate: rowData[1],
Expand Down Expand Up @@ -327,32 +341,6 @@ $(".startDatePicker, .endDatePicker").change(function () {
$("#startDatePicker-main").datepicker("option", "minDate", minDate)
})

// everything except Chrome
if (navigator.userAgent.indexOf("Chrome") == -1) {
$('input.timepicker').timepicker({
timeFormat: 'hh:mm p',
scrollbar: true,
dropdown: true,
dynamic: true,
minTime: "08:00am",
maxTime: "10:00pm"
});
$(".timepicker").prop("type", "text");
$(".timeIcons").prop("hidden", false);

var formattedStartTime = format24to12HourTime($(".startTime").prop("defaultValue"));
var formattedEndTime = format24to12HourTime($(".endTime").prop("defaultValue"));
$(".startTime").val(formattedStartTime);
$(".endTime").val(formattedEndTime);
} else {
$(".timepicker").prop("type", "time");
$(".timeIcons").prop("hidden", true);
}

if ($(".datePicker").is("readonly")) {
$(".datePicker").datepicker("option", "disabled", true);
}

$(".readonly").on('keydown paste', function (e) {
if (e.keyCode != 9) // ignore tab
e.preventDefault();
Expand All @@ -370,6 +358,27 @@ $(".startDatePicker, .endDatePicker").change(function () {
if ($(this).val() && $("#endDatePicker-" + $(this).data("page-location")).val()) {
calculateRecurringEventFrequency();
}
})
// Time picker click events
$(".timeIcons").on("click", function(e) {
e.stopPropagation()


if ($(this).siblings(".timepicker").timepicker("closed")) {
$(this).siblings(".timepicker").timepicker("open");
}

else {
$(this).siblings(".timepicker").timepicker("close");
}
})

$("#checkRSVP").click(function () {
if ($("input[name='isRsvpRequired']:checked").val() == 'on') {
$("#checkFood").prop('checked', true);
} else {
$("#checkFood").prop('disabled', false);
}
});

var facilitatorArray = []
Expand Down
4 changes: 2 additions & 2 deletions app/templates/admin/createEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
{% set eventPast = event.isPastEnd if not isNewEvent else False %}
{% set tabName = 'edit' %}


{% block scripts %}
{{super()}}
<script type="module" src="/static/js/createEvents.js"></script>
Expand Down Expand Up @@ -452,6 +451,7 @@ <h5 class="modal-title" id="renewModel">Renew Event</h5>
</div>
</div>
</form>
{% endblock %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endblock is messing up styling on the page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was initially just styling but now it is breaking completely for me

<!--multiple offering event modal-->
<div class="modal modalMultipleOfferingEvent fade float-start col" data-bs-backdrop='static' id="modalMultipleOffering">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
Expand Down Expand Up @@ -541,4 +541,4 @@ <h5 class="modal-title">This is an event with multiple time offerings.</h5>
</div>
</div>

{% endblock %}
{% endblock %}
Loading