Bruce Gust
asked on
How Can I Track This Down?
I've been tasked with fixing a bug on the app that we have. When you attempt to cancel an appointment, you get an error.
Using Google Dev Tools, I get this when click on the button:
I'm trying to figure out what PHP function is being triggered by this button so I can then troubleshoot that functionality directly. I'm thinking I would look for a file called jquery.min.js, but I can't find it.
Then again, maybe this is just referring to some JQuery functionality.
This is all coming from a Symfony dynamic.
How can sniff out the query that's being used?
Ideas?
Using Google Dev Tools, I get this when click on the button:
I'm trying to figure out what PHP function is being triggered by this button so I can then troubleshoot that functionality directly. I'm thinking I would look for a file called jquery.min.js, but I can't find it.
Then again, maybe this is just referring to some JQuery functionality.
This is all coming from a Symfony dynamic.
How can sniff out the query that's being used?
Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the error that you have in console?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alright, guys, here's what I've been able to deduce. Tell me if what I'm smelling is, in fact, what's on the stove.
First off, the button itself. Here's a screenshot:
Now, by using Ransack, I do a search and I also look to see what pages are showing up under the Network tab of Google Chrome. One page that looks especially relevant is the coaching.js page. I've got that below:
The line that looks important is line 283.
I will confess at this point, I don't know HOW to connect the dots. I'm assuming that this class would show up some where else in the code as a function. For example, I might trigger a JQuery function using a link where the <a id="myFunction"..." would trigger something like "$('#myFunction').click( function(event){", but I don't see that here.
Still, I'm following my nose, and I see this in the routing_member.yml file:
member_event_cancel:
path: /events/{evID}/cancel
defaults: { _controller: AppBundle:Member\Widget\Ev ents:cance l}
...when I go to the AppBundle/Controller/Membe r/Widget directory, I see an "EventsController.php" page, which looks as though it might ne a Smyfony dynamic that has the functionality I'm looking for.
The only function I see is this one:
public function cancelAction(Request $request, $evID){
$evrID = $request->get('evrID');
$result = $this->get('member.widget. events')-> cancel($th is->user, $evID, $evrID);
return JsonResponse::success([
'result' => $result
]);
}
The fact that it says, "cancelAction" seems problematic in that according to the Google Chrome tools, I'm looking for a "cancelAppointment" command.
Julian, I did want to say that when I hover over the "cancelAppointment" command in the Google Chrome tools screen, I get a URL that reads as "widgets / undefined / cancelAppointment."
I'm rambling boys, but it all seems relevant somehow.
What do you see, what do you hear, what do you smell?
I'm listening...
Thanks again for your time!
First off, the button itself. Here's a screenshot:
Now, by using Ransack, I do a search and I also look to see what pages are showing up under the Network tab of Google Chrome. One page that looks especially relevant is the coaching.js page. I've got that below:
/**
* Created by nhill on 9/15/2016.
*/
;( function( $, window, document, undefined ) {
"use strict";
// Create the defaults once
var pluginName = "widgetCoaching";
var defaults = {};
// The actual plugin constructor
function Plugin ( element, options ) {
var plugin = this;
plugin.element = element;
plugin.$element = $(element);
plugin.settings = $.extend( {}, defaults, options );
plugin._defaults = defaults;
plugin._name = pluginName;
if(plugin.settings.alertTriggered == true){
plugin.sessionRegisterPopupAlert($('#coachingEventRegisterPopup'));
}else{
plugin.init();
}
}
// Avoid Plugin.prototype conflicts
$.extend( Plugin.prototype, {
init: function(){
var plugin = this;
var rawID = plugin.$element.attr('id');
plugin.ppwID = rawID.split('-')[1];
plugin.magnificPopupBind();
// bind the sort links
plugin.$element.find('a.sort').unbind('click').click(function(){
plugin.sessionsLoad($(this));
});
plugin.$element.find('button.schedule-session').click(function(){
//plugin.sessionSchedulePopup();
plugin.sessionRegisterPopup($(this));
});
$(document).on('change', '#scheduleCoachingSession-'+plugin.ppwID+' select.selectedAppt', function(){
$(this).parent().find('.session-reschedule').data('aid', $(this).val());
$(this).parent().find('.session-cancel').data('aid', $(this).val());
});
$(document).on('click', '#scheduleCoachingSession-'+plugin.ppwID+' button.session-register', function(){
plugin.sessionRegisterPopup($(this));
});
$(document).on('click', '#scheduleCoachingSession-'+plugin.ppwID+' button.session-reschedule', function(){
plugin.sessionRegisterPopup($(this), true);
});
$(document).on('click', '#scheduleCoachingSession-'+plugin.ppwID+' button.session-cancel', function(){
plugin.sessionRegisterPopup($(this), false, true);
});
$(document).on('click', '.btn-messaging', function(e){
e.preventDefault();
$.get($(this).attr('href'), {}, function(resp){
$.magnificPopup.close();
$.magnificPopup.open({
'items': {
'type': 'inline',
'src': resp
},
'callbacks': {
'open': function(){
$('div.clinician-messaging').coachingMessaging();
}
}
});
});
});
},
sessionSchedulePopup: function(){
var plugin = this;
$.get('/widgets/'+plugin.ppwID+'/getCoachingAppointments', {'ppwID': plugin.ppwID}, function(resp){
if(resp.error){
Materialize.toast(resp.msg, toastTime, 'error');
return false;
}
$.magnificPopup.open({
'items': {
'type': 'inline',
'src': resp.data.content
}
});
});
},
sessionRegisterPopup: function($elem, isReschedule, toggleCancel){
var plugin = this;
plugin.currentAID = (isReschedule || toggleCancel)?$elem.data('aid'):null;
plugin.isReschedule = isReschedule;
plugin.toggleCancel = toggleCancel;
$.get('/widgets/'+plugin.ppwID+'/getCoachingRegistrationPopup', {'id': $elem.data('id'), 'aID': plugin.currentAID, 'isReschedule': isReschedule}, function(resp){
if(resp.error){
Materialize.toast(resp.msg, toastTime, 'error');
return false;
}
plugin.event = resp.data.event;
plugin.evID = plugin.event.evID;
$.magnificPopup.close();
$.magnificPopup.open({
'items': {
'type': 'inline',
'src': resp.data.content
},
callbacks: {
open: function () {
plugin.$popup = $('#coachingEventRegisterPopup');
plugin.$popup.find('ul.tabs').tabs();
plugin.initRegistrationList();
//Determine if there are any days available
if(plugin.event.schedule!== undefined){
plugin.initRegistrationCalendar();
plugin.initRegistrationButtons();
plugin.$popup.find('.custom-survey-form').validate({
errorPlacement: function(error,element) {
return true;
},
highlight: function(element, errorClass) {
$(element).removeClass(errorClass);
}
});
}else if(plugin.event.maxDaysExceeded){
plugin.showScheduleText(Translation.translate('COACHING_MAX_DAYS_ERROR'));
}else{
plugin.showScheduleText(Translation.translate('COACHING_NO_TIMES_ERROR'));
}
if(plugin.event.evEnableSelfReportPartic){
plugin.initParticipation();
}
}
}
});
});
},
sessionRegisterPopupAlert: function($elem){
var plugin = this;
$.get('/widgets/handler/Coaching/getCoachingRegistrationPopup', {'id': $elem.data('id')}, function(resp){
if(resp.error){
Materialize.toast(resp.msg, toastTime, 'error');
return false;
}
plugin.event = resp.data.event;
plugin.evID = plugin.event.evID;
plugin.activeAID = $elem.data('highlight-aid');
plugin.$popup = $('#coachingEventRegisterPopup');
plugin.$popup.find('ul.tabs').tabs();
plugin.initRegistrationList();
//Determine if there are any days available
if(plugin.event.schedule!== undefined){
plugin.initRegistrationCalendar();
plugin.initRegistrationButtons();
plugin.$popup.find('.custom-survey-form').validate({
errorPlacement: function(error,element) {
return true;
},
highlight: function(element, errorClass) {
$(element).removeClass(errorClass);
}
});
}else if(plugin.event.maxDaysExceeded){
plugin.showScheduleText(Translation.translate('COACHING_MAX_DAYS_ERROR'));
}else{
plugin.showScheduleText(Translation.translate('COACHING_NO_TIMES_ERROR'));
}
if(plugin.event.evEnableSelfReportPartic){
plugin.initParticipation();
}
});
},
/** --------------------------------------------------------------
*
*
* Registration Popup methods
*
* ---------------------------------------------------------------
*/
initRegistrationList: function(){
var plugin = this;
var $list = plugin.$popup.find('.registration-list');
var registrationHTML = '';
$.each(plugin.event.evrApptArray , function(index, registration){
var momentDate = moment(registration.aDate);
var momentTz = moment.tz(momentDate.format("M/DD/YYYY h:mm A"), "M/DD/YYYY h:mm A", plugin.event.timezone);
var localDate = momentTz.local();
if(plugin.event.inPast){
registrationHTML = registrationHTML + '<a class="collection-item registration-item registration-in-past">'+localDate.format("M/DD/YYYY h:mm A")+'</a>';
}else{
//plugin.currentAID = registration.aID;
//plugin.showScheduleText("You already have an appointment. If necessary, you may cancel or reschedule your appointment to the right.");
registrationHTML = registrationHTML + '<a href="#!" class="collection-item registration-item" data-aid="'+registration.aID+'">'+localDate.format("M/DD/YYYY h:mm A")+'</a>';
}
});
$list.html(registrationHTML);
plugin.$popup.find('.registration-item').click(function(){
if(!$(this).hasClass('registration-in-past')){
plugin.$popup.find('.registration-item').removeClass('active');
$(this).addClass('active');
plugin.$popup.find('.registration-reschedule-button').prop("disabled", false);
plugin.$popup.find('.registration-cancel-button').prop("disabled", false);
}
});
plugin.initReschedule();
plugin.initCancelRegistration();
if(plugin.isReschedule){
plugin.$popup.find('.registration-item[data-aid="'+plugin.currentAID+'"]').trigger('click');
plugin.$popup.find('.registration-reschedule-button').trigger('click');
}else if(plugin.toggleCancel){
plugin.$popup.find('.registration-item[data-aid="'+plugin.currentAID+'"]').trigger('click');
plugin.$popup.find('.registration-cancel-button').trigger('click');
}else if(plugin.activeAID){
plugin.$popup.find('.registration-item[data-aid="'+plugin.activeAID+'"]').trigger('click');
}
},
initReschedule: function(){
var plugin = this;
plugin.$popup.find('.registration-reschedule-button').click(function(){
plugin.$popup.find('.event-schedule-text').hide();
plugin.$popup.find('.event-time-picker-container').hide();
plugin.$popup.find('.event-register-calendar-container').show();
var $selectedItem = plugin.$popup.find('.registration-item.active');
plugin.currentAID = ($selectedItem.data('aid'))?$selectedItem.data('aid'):null;
plugin.$popup.find('.reschedule-display').text(Translation.translate('COACHING_RESCHEDULING_FOR_SESSION')+': '+plugin.$popup.find('.registration-item.active').text()).show();
});
},
initRegisterCalendarButton :function(){
var plugin = this;
plugin.$popup.find('.register-calendar-btn').click(function(){
plugin.showRegisterCalendar();
});
},
initCancelRegistration: function(){
var plugin = this;
plugin.$popup.find('.registration-cancel-button').click(function(){
plugin.hideRegisterCalendarAndList();
plugin.$popup.find('.registration-cancel-confirm').show();
plugin.$popup.find('.cancel-time').html(plugin.$popup.find('.registration-item.active').html());
plugin.$popup.find('.reschedule-display').hide();
});
plugin.$popup.find('.registration-cancel-confirm-button').click(function(){
$.post('/widgets/' + plugin.ppwID + '/cancelAppointment', {
evID: plugin.evID,
aID: plugin.currentAID
},function(res){
if(res.error){
Materialize.toast(Translation.translate('COACHING_CANCELLED_ERROR'), toastTime, 'error');
}else{
plugin.$popup.find('.event-popup-content').html('<div class="center"><h4>'+Translation.translate('COACHING_CANCELLED')+'</h4><h5>'+Translation.translate('COACHING_CANCELLED_MESSAGE')+'</h5></div>');
}
}).error(function(error){
Materialize.toast(Translation.translate('COACHING_CANCELLED_ERROR'), toastTime, 'error');
});
});
plugin.$popup.find('.registration-cancel-cancel-button').click(function(){
plugin.showRegisterCalendarAndList();
plugin.$popup.find('.registration-cancel-confirm').hide();
});
},
initRegistrationButtons: function(){
var plugin = this;
plugin.$popup.find(".registration-form-register-button").click(function(){
var surveyValid = false;
var surveyAnswers = [];
if(plugin.$popup.find('.custom-survey-form').length){
if(plugin.$popup.find('.custom-survey-form').valid()){
plugin.$popup.find('.survey-error').hide();
surveyValid = true;
var customSurvey = plugin.$popup.find('.custom-survey-form').serializeObject();
$.each(customSurvey, function(question, answer){
var qID = question.split('_')[2];
if($.isArray(answer)){
for(var i= 0; i < answer.length; i++){
var ansObj = {};
ansObj[qID] = answer[i];
surveyAnswers.push(ansObj);
}
}else{
var ansObj = {};
ansObj[qID] = answer;
surveyAnswers.push(ansObj);
}
});
}else{
plugin.$popup.find('.survey-error').show();
}
}else{
surveyValid = true;
}
if(surveyValid){
var data = {};
//Take the raw time selected in the user's timezone and adjust to the timezone of the event
var selectedTimeRaw = plugin.$popup.find('.register-timeslot.active').attr('data-apt-time');
var selectedMomentUserTZ = moment(selectedTimeRaw, 'MM/DD/YYYY hh:mm A');
var selectedMomentEventTZ = moment(selectedTimeRaw, 'MM/DD/YYYY hh:mm A');
selectedMomentEventTZ.tz(plugin.event.timezone);
data['evrApptTime'] = selectedMomentEventTZ.format('MM/DD/YYYY hh:mm A');
if(surveyAnswers.length){
data['evrSurvey'] = surveyAnswers;
}else{
data['evrSurvey'] = null;
}
if(plugin.$popup.find('.evr-comments').val().length){
data['evrComments'] = plugin.$popup.find('.evr-comments').val();
}else{
data['evrComments'] = null;
}
data['evID'] = plugin.evID;
if(plugin.currentAID){
data['aID'] = plugin.currentAID;
}
$.post('/widgets/' + plugin.ppwID + '/registerAppointment', data, function(res){
if(res.error){
Materialize.toast(res.message, toastTime, 'error');
}else{
var readableTime = selectedMomentUserTZ.format("M/DD/YYYY h:mm A");
plugin.$popup.find('.event-popup-content').html('<div class="center"><h4>'+Translation.translate('COACHING_REGISTERED')+'</h4><h5>'+Translation.translate('COACHING_REGISTERED_MESSAGE')+' ' + readableTime + '!</h5></div>');
}
}).error(function(error){
Materialize.toast(Translation.translate('COACHING_APPOINTMENT_ERROR'), toastTime, 'error');
});
}
});
plugin.$popup.find(".registration-form-cancel-button").click(function(){
plugin.hideRegisterForm();
});
},
showRegisterForm: function(){
var plugin = this;
plugin.$popup.find('.registration-comments-survey-column').show();
plugin.hideRegisterCalendarAndList();
},
showScheduleText: function(text){
var plugin = this;
plugin.$popup.find('.event-schedule-text-container').show();
plugin.$popup.find('.event-schedule-text').html(text);
plugin.$popup.find('.event-time-picker-container').hide();
plugin.$popup.find('.event-register-calendar-container').hide();
plugin.$popup.find('.event-register-reschedule-text').show();
},
hideRegisterForm: function(){
var plugin = this;
plugin.$popup.find('.registration-comments-survey-column').hide();
plugin.$popup.find('.registration-list-column').show();
plugin.showRegisterCalendar();
},
showRegisterCalendar: function(){
var plugin = this;
plugin.$popup.find('.register-calendar-column').show();
/*
if(plugin.currentAID){
plugin.$popup.find('.event-register-calendar-container').hide();
plugin.$popup.find('.event-register-reschedule-text').show();
}else{
plugin.$popup.find('.event-register-reschedule-text').hide();
plugin.$popup.find('.event-register-calendar-container').show();
}
*/
plugin.currentAID = null;
plugin.$popup.find('.registration-item.active').removeClass('active');
plugin.$popup.find('.reschedule-display').hide();
plugin.$popup.find('.event-register-reschedule-text').hide();
plugin.$popup.find('.event-register-calendar-container').show();
plugin.$popup.find('.event-time-picker-container').hide();
plugin.$popup.find('.ui-state-active').removeClass('ui-state-active');
},
hideRegisterCalendarAndList: function(){
var plugin = this;
plugin.$popup.find('.registration-list-column').hide();
plugin.$popup.find('.register-calendar-column').hide();
},
showRegisterCalendarAndList: function(){
var plugin = this;
plugin.$popup.find('.registration-list-column').show();
plugin.showRegisterCalendar();
},
initRegistrationCalendar: function(){
var plugin = this;
plugin.initRegisterCalendarButton();
plugin.initSelectTimeButton();
var earliestMonth;
//I don't trust IE to keep object keys in order
//This is to set the month to the first month an available slot
for(var month in plugin.event.schedule){
if(earliestMonth === undefined || month < earliestMonth){
earliestMonth = month;
}
}
plugin.$popup.find('.event-register-calendar').datepicker(
{
beforeShowDay: function(date){
var toReturn = plugin.initRegisterDay(date);
return toReturn;
},
onSelect: function(dateText, datepickerInstance){
var timeslots = plugin.getDayTimeslots(new Date(dateText));
plugin.displayTimeslots(timeslots, dateText);
}
}
);
//defaultDate: new Date(earliestMonth * 1000),
//Unselect the selected day that occurs as a result of defaultDay
plugin.$popup.find('.ui-state-active').removeClass('ui-state-active');
},
initRegisterDay: function(date){
var plugin = this;
var dateMoment = moment(date);
//Break into month and year so we can line up with month timestamps in the timeslots array
var monthMoment = moment.tz((dateMoment.month() + 1) + '-' + dateMoment.year(), 'MM-YYYY', plugin.event.timezone);
//Determine if we have slots in the month
var monthTs = monthMoment.unix();
if( monthTs in plugin.event.schedule){
//Determine if we have slots in the day
var dayMoment = moment.tz((dateMoment.month() + 1) + '-' + dateMoment.date() + '-' + dateMoment.year(), 'MM-DD-YYYY', plugin.event.timezone);
var dayTs = dayMoment.unix();
if(dayTs in plugin.event.schedule[monthTs].days){
//Determine if all the slots in the day are taken if there are slots in the day
if(plugin.event.schedule[monthTs].days[dayTs].available || plugin.event.schedule[monthTs].days[dayTs].aID == plugin.currentAID){
return [true, 'calendar-available-day'];
}else{
return [false, 'day-booked'];
}
}
}
return [false, ''];
},
displayTimeslots: function(timeslots, dateText){
var plugin = this;
plugin.$popup.find('.event-register-calendar-container').hide();
plugin.$popup.find('.event-time-picker-container').show();
plugin.$popup.find('.timeslots-date').html(dateText);
var timeslotsHtml = '';
$.each(timeslots, function(index, timeslot){
var startMoment = moment.unix(timeslot.startTime);
var endMoment = moment.unix(timeslot.endTime);
var registered = false;
for(var i in plugin.event.evrApptArray){
if(plugin.event.evrApptArray[i].aID == timeslot.aID){
registered = true;
break;
}
}
if(registered == true){
timeslotsHtml = timeslotsHtml + '<a class="collection-item register-timeslot timeslot-booked">'+ startMoment.format("h:mm A") + ' - '+ endMoment.format("h:mm A") + ' - '+Translation.translate('COACHING_REGISTERED')+'</a>';
}else if(timeslot.available || timeslot.aID == plugin.currentAID){
timeslotsHtml = timeslotsHtml + '<a href="#!" data-apt-time="' + startMoment.format("MM/DD/YYYY hh:mm A") + '" class="collection-item register-timeslot">'+ startMoment.format("h:mm A") + ' - '+ endMoment.format("h:mm A") + '</a>';
}else{
timeslotsHtml = timeslotsHtml + '<a class="collection-item register-timeslot timeslot-booked">'+ startMoment.format("h:mm A") + ' - '+ endMoment.format("h:mm A") + ' - '+Translation.translate('COACHING_FULL')+'</a>';
}
});
plugin.$popup.find('.event-timeslots-container').html(timeslotsHtml);
plugin.$popup.find('.register-select-time-btn').hide();
plugin.$popup.find('.timeslots-date').html(dateText);
plugin.$popup.find('.register-timeslot').click(function(){
if(!$(this).hasClass('timeslot-booked')){
plugin.$popup.find('.register-timeslot').removeClass('active');
$(this).addClass('active');
plugin.$popup.find('.register-select-time-btn').show();
}
});
},
getDayTimeslots: function(date){
var plugin = this;
var dateMoment = moment(date);
//Get month and day ts
var monthMoment = moment.tz((dateMoment.month() + 1) + '-' + dateMoment.year(), 'MM-YYYY', plugin.event.timezone);
var dayMoment = moment.tz((dateMoment.month() + 1) + '-' + dateMoment.date() + '-' + dateMoment.year(), 'MM-DD-YYYY', plugin.event.timezone);
//get timestamps so we can select the day out of the schedule
var monthTs = monthMoment.unix();
var dayTs = dayMoment.unix();
return plugin.event.schedule[monthTs].days[dayTs].timeslots;
},
initSelectTimeButton: function(){
var plugin = this;
plugin.$popup.find('.register-select-time-btn').click(function(){
if(plugin.$popup.find('.register-timeslot.active').length){
plugin.showRegisterForm();
}
});
},
initParticipation: function(){
var plugin = this;
plugin.$popup.find('.event-participation-calendar').datepicker(
{
onSelect: function(dateText, datepickerInstance){
plugin.selectParticipationDate(new Date(dateText));
},
beforeShowDay: function (date){
//can only participate once a day
if(plugin.event.participations){
var hasParticipated = false;
var dateToCheck = moment(date);
$.each(plugin.event.participations, function(index, date){
var particDate = moment(date.evpDate, "YYYY-MM-DD mm:hh:ss");
if(dateToCheck.format("MM/DD/YYYY") == particDate.format("MM/DD/YYYY")){
hasParticipated = true;
}
});
if(hasParticipated){
return [false, 'day-booked'];
}
}
//The highlight state is added outside of an event and occurs
//after this event, this is the only way to ensure it's removed
setTimeout(function(){
plugin.$popup.find('.event-participation-calendar').find('.ui-state-highlight').removeClass('ui-state-highlight');
}, 10);
return [true, 'calendar-available-day'];
},
maxDate: new Date()
}
);
plugin.initParticipationCancelButton();
plugin.initConfirmParticipationButton();
plugin.initParticipationDeleteButtons();
plugin.initParticipationSelect();
},
initParticipationSelect: function(){
var plugin = this;
plugin.$popup.find('.participation-item').click(function(){
plugin.$popup.find('.participation-item').removeClass('active');
$(this).addClass('active');
plugin.$popup.find('.partic-delete-button').prop("disabled", false);
});
},
selectParticipationDate: function(date){
var plugin = this;
var dateMoment = moment(date);
plugin.clearParticipationError();
plugin.$popup.find('.event-participation-calendar-container').hide();
plugin.$popup.find('.event-participation-form').show();
plugin.$popup.find('.participation-date').html(dateMoment.format('M/DD/YYYY'));
},
initParticipationCancelButton: function(){
var plugin = this;
plugin.$popup.find('.partic-cancel-button').click(function(){
plugin.$popup.find('.event-participation-calendar-container').show();
plugin.$popup.find('.event-participation-form').hide();
});
},
clearParticipationError: function(){
var plugin = this;
plugin.$popup.find('.partic-code').removeClass('invalid');
plugin.$popup.find('.participation-error').hide();
},
initConfirmParticipationButton:function(){
var plugin = this;
plugin.$popup.find('.partic-confirm-button').click(function(){
plugin.clearParticipationError();
if(
!plugin.$popup.find('.partic-code').length ||
(plugin.$popup.find('.partic-code').length && plugin.$popup.find('.partic-code').val().length)
){
var data = {};
var rawDate = moment(plugin.$popup.find('.participation-date').html(), 'M/DD/YYYY');
data['event'] = plugin.evID;
if(plugin.$popup.find('.partic-code').length){
data['evSelfReportParticCode'] = plugin.$popup.find('.partic-code').val();
}
data['evpComments'] = plugin.$popup.find('.evp-comments').val();
data['evpDate'] = rawDate.format('MM/DD/YYYY');
data['evID'] = plugin.evID;
$.post('/widgets/' + plugin.ppwID + '/participateAppointment', data ,function(res){
if(res.error){
if(res.data.cause == 'evSelfReportParticCode'){
plugin.$popup.find('.partic-code').addClass('invalid');
plugin.$popup.find('.participation-error').show().html(res.message);
}else{
Materialize.toast(Translation.translate('COACHING_PARTICIPATION_RECORDED_ERROR'), toastTime, 'error');
}
}else{
plugin.$popup.find('.event-popup-content').html('<div class="center"><h4>'+Translation.translate('COACHING_PARTICIPATION_RECORDED')+'</h4><h5>'+Translation.translate('EVENTS_PARTICIPATION_RECORDED', [rawDate.format('M/DD/YYYY')])+'</h5></div>');
}
}).error(function(error){
Materialize.toast(Translation.translate('COACHING_PARTICIPATION_RECORDED_ERROR'), toastTime, 'error');
});
}else{
plugin.$popup.find('.partic-code').addClass('invalid');
plugin.$popup.find('.participation-error').show().html(Translation.translate('COACHING_PARTICIPATION_CODE_ERROR'));
}
});
},
initParticipationDeleteButtons: function(){
var plugin = this;
plugin.$popup.find('.partic-delete-button').click(function(){
plugin.$popup.find('.partic-list-col').hide();
plugin.$popup.find('.partic-calendar-col').hide();
plugin.$popup.find('.participation-delete-confirm').show();
plugin.$popup.find('.cancel-partic-time').html(plugin.$popup.find('.participation-item.active').html());
});
plugin.$popup.find('.participation-delete-confirm-button').click(function(){
var selectedEvp = plugin.$popup.find('.participation-item.active').data('evp');
$.post('/events/' + plugin.ppwID + '/deleteAppointmentParticipation', {
evID: plugin.evID,
evpID: selectedEvp
},function(res){
if(res.error){
Materialize.toast(Translation.translate('COACHING_PARTICIPATION_DELETE_ERROR'), toastTime, 'error');
}else{
plugin.$popup.find('.event-popup-content').html('<div class="center"><h4>'+Translation.translate('COACHING_DELETED')+'</h4><h5>'+Translation.translate('COACHING_DELETED_MESSAGE')+'</h5></div>');
}
}).error(function(error){
Materialize.toast(Translation.translate('COACHING_PARTICIPATION_DELETE_ERROR'), toastTime, 'error');
});
});
plugin.$popup.find('.participation-delete-cancel-button').click(function(){
plugin.$popup.find('.partic-list-col').show();
plugin.$popup.find('.partic-calendar-col').show();
plugin.$popup.find('.participation-delete-confirm').hide();
});
},
sessionsLoad: function($sortElem){
var plugin = this;
var $sessionsContainer = plugin.$element.find('.sessions-history');
var $tbody = $sessionsContainer.find('tbody');
var sortVal = '';
var sortDir = '';
if($sortElem.length > 0){
sortVal = $sortElem.data('field');
if($sortElem.data('sort-dir') && $sortElem.data('sort-dir') == 'desc'){
plugin.toggleSortIcon('sort-asc', $sortElem)
sortDir = 'asc';
}else{
plugin.toggleSortIcon('sort-desc', $sortElem)
sortDir = 'desc';
}
$sortElem.data('sort-dir', sortDir);
}else{
plugin.toggleSortIcon('sort');
}
$tbody.empty().append('<tr class="loading"><td colspan="3">'+Translation.translate('COACHING_LOADING')+'</td></tr>');
$.get('/widgets/'+plugin.ppwID+'/getCoachingSessionList', {ppwID: plugin.ppwID, sort: sortVal, 'sortDir': sortDir}, function(resp){
if(resp.error){
Materialize.toast(resp.msg, toastTime, 'error');
return false;
}
$tbody.empty().append(resp.data.content);
plugin.magnificPopupBind();
});
},
toggleSortIcon: function(iconClass, $sortElem){
var plugin = this;
var $sessionsContainer = plugin.$element.find('.sessions-history');
$sessionsContainer.find('.sort-icon').removeClass('fa-sort-asc fa-sort-desc fa-sort').addClass('fa-sort');
if(!$sortElem){
$sortElem = $sessionsContainer;
}
$sortElem.find('.sort-icon').addClass('fa-'+iconClass);
},
uploaderCreate: function($elem){
var plugin = this;
var $ui = $elem.find('div.uploader');
var uploadError = false;
var uploader = new plupload.Uploader({
runtimes : 'html5,flash,silverlight,html4',
browse_button : $ui.find('button.upload')[0],
container: $ui[0],
url : '/widgets/'+plugin.ppwID+'/uploadFile',
filters : {
max_file_size : '10mb'
},
flash_swf_url : '/assets/js/plupload/Moxie.swf',
silverlight_xap_url : '/assets/js/plupload/Moxie.xap',
init: {
PostInit: function() {
$ui.find('ul.list').empty();
},
FilesAdded: function(up, files) {
plupload.each(files, function(file) {
$ui.find('ul.luw-upload-list').append('<li id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></li>');
});
uploader.start();
},
UploadProgress: function(up, file) {
$('#'+file.id+' > b').html('<span>' + file.percent + '%</span>');
},
FileUploaded: function(up, file, resp) {
// parse the result json
resp.response = JSON.parse(resp.response);
// check for an error
if (resp.response.error == true) {
$('#'+file.id+' > b').html('<span>ERROR: ' + resp.response.message + '</span>');
uploadError = true;
return false;
}
// add it to the list of uploaded files
files.push(resp.response.result);
},
UploadComplete: function(up, upFiles) {
// stop here if error uploading
if (uploadError) {
return false;
}
//$.magnificPopup.close();
},
Error: function(up, err) {
// remove the upload marker
$ui.find('div[data-id="'+err.file.id+'"]').remove();
// show the msg
Materialize.toast(err.message, 5000, 'error');
}
}
});
uploader.init();
return $elem[0];
},
magnificPopupBind: function(){
var plugin = this;
plugin.$element.find('a.trigger-popup').magnificPopup({'type': 'inline'});
plugin.$element.find('.trigger-popup-ajax').magnificPopup({
'type': 'ajax',
'ajax': {
'settings': {'cache': false}
},
'callbacks': {
parseAjax: function (response) {
var magnificPopup = $.magnificPopup.instance,
originalElem = magnificPopup.st.el;
if(originalElem.data('callback')){
response.data = plugin[originalElem.data('callback')]($(response.data));
}
}
}
});
}
} );
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function(options,additionaloptions) {
return this.each(function() {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
}
else if (Plugin.prototype[options]) {
$.data(this, 'plugin_' + pluginName)[options](additionaloptions);
}
});
}
} )( jQuery, window, document );
$(function(){
$('.w-Coaching').widgetCoaching();
$('#coachingEventRegisterPopup').widgetCoaching({'alertTriggered': true});
if(window.preview){
$('.w-Coaching').find('*').off();
$('.w-Coaching').find('a').attr('href', '#');
}
});
The line that looks important is line 283.
I will confess at this point, I don't know HOW to connect the dots. I'm assuming that this class would show up some where else in the code as a function. For example, I might trigger a JQuery function using a link where the <a id="myFunction"..." would trigger something like "$('#myFunction').click( function(event){", but I don't see that here.
Still, I'm following my nose, and I see this in the routing_member.yml file:
member_event_cancel:
path: /events/{evID}/cancel
defaults: { _controller: AppBundle:Member\Widget\Ev
...when I go to the AppBundle/Controller/Membe
The only function I see is this one:
public function cancelAction(Request $request, $evID){
$evrID = $request->get('evrID');
$result = $this->get('member.widget.
return JsonResponse::success([
'result' => $result
]);
}
The fact that it says, "cancelAction" seems problematic in that according to the Google Chrome tools, I'm looking for a "cancelAppointment" command.
Julian, I did want to say that when I hover over the "cancelAppointment" command in the Google Chrome tools screen, I get a URL that reads as "widgets / undefined / cancelAppointment."
I'm rambling boys, but it all seems relevant somehow.
What do you see, what do you hear, what do you smell?
I'm listening...
Thanks again for your time!
ASKER
Was able to sit down with the guy that actually wrote the script and we were able to find out some things.
First, the Request URL as is indicated under the "Headers" tab is: http://bmcjax.portal.personalhealthsurvey.net/widgets/undefined/cancelAppointment
That "undefined" element would be a dealbreaker, yes?
Looking at line 284 in the script that I've got in the previous post, you have this: plugin.ppwID
"What is that?" I ask myself.
Line 33: var rawID = plugin.$element.attr('id') ;
plugin.ppwID = rawID.split('-')[1];
What is that script? What does it mean and is that a problem?
First, the Request URL as is indicated under the "Headers" tab is: http://bmcjax.portal.personalhealthsurvey.net/widgets/undefined/cancelAppointment
That "undefined" element would be a dealbreaker, yes?
Looking at line 284 in the script that I've got in the previous post, you have this: plugin.ppwID
"What is that?" I ask myself.
Line 33: var rawID = plugin.$element.attr('id')
plugin.ppwID = rawID.split('-')[1];
What is that script? What does it mean and is that a problem?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gentlemen!
You were flying blind as was I, but I was able to get some additional feedback and the problem is solved.
The "undefined" variable was a result of a glitch in the code that assumed a ppwID was present to the point where an error wasn't generated if it wasn't there. Hence the need to pop the hood and trace down the "undefined" id and figure out where it was supposed to be determined and what to do to ensure that particular piece of the code was addressed so as to avoid things breaking down.
The remedy looked like this:
"ppwID" was getting left behind as a result of an "IF" statement on line #20 of coaching.js. To remedy that we put together an "IF" statement within the "cancelRegistration" code that looked like this:
plugin.$popup.find('.regis tration-ca ncel-confi rm-button' ).click(fu nction(){
var url='';
if(!plugin.ppwID) //ppwID isn't there
{
//alert("problem");
url='/widgets/handler/Coac hing/cance lAppointme nt';
}
else
{
url='/widgets/' + plugin.ppwID + '/cancelAppointment';
}
The "handler" is a function that another developer on the team built to grab the needed variable in case the normal syntax failed to yield the correct ID.
I wasn't aware of that functionality, but thanks to your insight and the assistance of some other guys on the team, I was able to identify where the problem was happening so I put some points on the board and I've got a little more understanding of the app overall.
This stuff can wear you out, sometimes...
You were flying blind as was I, but I was able to get some additional feedback and the problem is solved.
The "undefined" variable was a result of a glitch in the code that assumed a ppwID was present to the point where an error wasn't generated if it wasn't there. Hence the need to pop the hood and trace down the "undefined" id and figure out where it was supposed to be determined and what to do to ensure that particular piece of the code was addressed so as to avoid things breaking down.
The remedy looked like this:
"ppwID" was getting left behind as a result of an "IF" statement on line #20 of coaching.js. To remedy that we put together an "IF" statement within the "cancelRegistration" code that looked like this:
plugin.$popup.find('.regis
var url='';
if(!plugin.ppwID) //ppwID isn't there
{
//alert("problem");
url='/widgets/handler/Coac
}
else
{
url='/widgets/' + plugin.ppwID + '/cancelAppointment';
}
The "handler" is a function that another developer on the team built to grab the needed variable in case the normal syntax failed to yield the correct ID.
I wasn't aware of that functionality, but thanks to your insight and the assistance of some other guys on the team, I was able to identify where the problem was happening so I put some points on the board and I've got a little more understanding of the app overall.
This stuff can wear you out, sometimes...
It would be better to look at the specific code that provides this functionality i.e. the onClick event.