Closed enricodente closed 3 years ago
Uncaught TypeError: Cannot read property 'val' of undefined
at s (backend_calendar_table_view.min.js?824HX:1)
at Object.<anonymous> (backend_calendar_table_view.min.js?824HX:1)
at c (jquery.min.js?824HX:2)
at Object.fireWith [as resolveWith] (jquery.min.js?824HX:2)
at l (jquery.min.js?824HX:2)
at XMLHttpRequest.<anonymous> (jquery.min.js?824HX:2)
In /easyappointments/assets/js/backend_calendar_table_view.min.js?824HX:1
This error pops out when switching from calendar view to table view from a the provider account. I tracked the error in the file, un-minified it, and here it is (error is in the end two lines, looks like "d" is an undefined variable?):
(window.BackendCalendarTableView = window.BackendCalendarTableView || {}),
(function () {
"use strict";
var d, o, l;
function r(t, n) {
$("#calendar .calendar-header .btn").addClass("disabled").prop("disabled", !0);
var r = {};
$(".provider-column").each(function (e, a) {
var t = $(a),
n = t.data("provider").id;
r[n] = t.find(".calendar-wrapper").fullCalendar("getView").name;
}),
$("#calendar .calendar-view").remove(),
Backend.placeFooterToBottom();
var e = $("<div/>", { class: "calendar-view" }).appendTo("#calendar");
e.data({ startDate: t.toString("yyyy-MM-dd"), endDate: n.toString("yyyy-MM-dd") });
var i = $("<div/>").appendTo(e);
D(t, n)
.done(function (e) {
for (var a = t; a <= n; ) s(i, a, e), a.add({ days: 1 });
E(),
Backend.placeFooterToBottom(),
$("#calendar .calendar-header .btn").removeClass("disabled").prop("disabled", !1),
$(".provider-column").each(function (e, a) {
var t = $(a),
n = t.data("provider").id;
t.find(".calendar-wrapper").fullCalendar("changeView", r[n] || "agendaDay");
});
})
.fail(GeneralFunctions.ajaxFailureHandler);
}
function s(e, a, t) {
var n = $("<div/>", { class: "date-column" }).appendTo(e);
n.data("date", a.getTime()), $("<h5/>", { class: "date-column-title", text: GeneralFunctions.formatDate(a, GlobalVariables.dateFormat) }).appendTo(n);
var r = d.val(), // <--- THE ERROR IS HERE
i = o.val(),
Hello!
Please enable the debug mode in the root config.php file and let us know where the error is in there (the app will use the non minified files).
Alex Tselegidis, Easy!Appointments Creator Need a customization? Contact me in person! |
Hello Alex.
I enabled debug mode, the issue appears to be at line 565 of the non-minified file.
Uncaught TypeError: $filterProvider is undefined
createDateColumn https://slidetrick.com/easyappointments/assets/js/backend_calendar_table_view.js:565
createView https://slidetrick.com/easyappointments/assets/js/backend_calendar_table_view.js:519
jQuery 6
getCalendarEvents https://slidetrick.com/easyappointments/assets/js/backend_calendar_table_view.js:1720
createView https://slidetrick.com/easyappointments/assets/js/backend_calendar_table_view.js:514
initialize https://slidetrick.com/easyappointments/assets/js/backend_calendar_table_view.js:1742
initialize https://slidetrick.com/easyappointments/assets/js/backend_calendar.js:121
<anonymous> https://slidetrick.com/easyappointments/index.php/backend?view=table:141
jQuery 13
The variable I was referring to in the previous posts is $filterProvider, the errors happen when looking for .val(), the variable does not seem to be defined if the user role is "provider". The same user passed to admin role works fine in Table View.
// Create providers and service filters.
if (GlobalVariables.user.role_slug !== Backend.DB_SLUG_PROVIDER) {
$('<label/>', {
'text': EALang.provider
})
.appendTo($calendarHeader);
$filterProvider = $('<select/>', {
'id': 'filter-provider',
'multiple': 'multiple',
'on': {
'change': function () {
var startDate = new Date($('.calendar-view .date-column:first').data('date'));
var endDate = new Date(startDate.getTime()).add({days: parseInt($('#select-date').val()) - 1});
createView(startDate, endDate);
}
}
})
.appendTo($calendarHeader);
providers.forEach(function (provider) {
$filterProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
});
$filterProvider.select2();
}
May the issue be here? If I understand correctly this code sets a value to $filterProvider only if user role is different from Backend.DB_SLUG_PROVIDER, that I assume being the provider user role.
I confirm that by removing that "if" condition at line 416, table view works perfectly for Provider too.
It would be interesting to know what that condition stood for, so that we can implement a better fix.
You are right, I could reproduce this.
The fix is committed on develop.
Alex Tselegidis, Easy!Appointments Creator Need a customization? Contact me in person! |
As per title, the table view is empty for the standard user, who is the owner of the only service I offer. Also it is not possible to switch between days, the arrows are greyed out. The calendar view (Default) is ok and I can see all the appointments.
With Admin logged in instead, everything is fine both in Calendar (Default) view and in table view.