Is there a way to "Allow whole day reservation" but to Default it to selected?

Peter F
Tera Contributor

As the title implies, I want to be able to "Allow whole day reservation" for certain reservable modules, but for the default value to be selected instead of empty. I do not want to "Require all day reservations" because I want to allow the end users to adjust their scheduled times if they so desire. If the "Require all day reservations" is checked, then the end user will be forced to make the reservation for a time that might not be correct.

 

By allowing the default to be checked, it will help the 90% of users who work during the standard hours. And still gives the flexibility to the other 10% of users. This will help with the users who do not manually adjust the reservation times and end up reserving the workstation for only an hour instead of the business day like they intend.

 

But the default should be to have it checked with the standard business hours but allow the end user to adjust if needed. 

9 REPLIES 9

@cmaleblanc We have not gotten anything to work on the "whole day reservation" to be the default selection yet. Since this original post, we have found several other areas in MyRes, where there is an option to make something optional or mandatory, but no way to adjust the default optional to be the other half of the binary. 

jdesouz_
Tera Contributor

Hello - 

 

I have a solution for this but it requires customizing an OOB script, so use at your own discretion. This can be accomplished by navigating to the following Widget Angular Provider - wsdSearchFilter

(/sp_angular_provider.do?sys_id=44eeb432c3a5101074848aedea40dd87&sysparm_view=&sysparm_domain=null&sysparm_domain_scope=null)

 

  • Navigate to the following line: 104

 

 

// all day setting
scope.enableAllDayOption = false;
scope.isAllDay = false;

 

 

 

  • Adjust the false to true
  • Navigate to the following line: 875

 

if (scope.isAllDay) {
// When all day mode is selected and the start time is not equal to work day start it will deactivate all day reservation.
var startDate = _getStartOrEndOfDayMmt(start, 'dayStart');
if (!start.isSame(startDate, 'hour') || !start.isSame(startDate, 'minute')){
scope.isAllDay = false;
}
}
​

 

  • Update it to this

 

if (scope.isAllDay) {
					// When all day mode is selected and the start time is not equal to work day start it will deactivate all day reservation.
					var startDate = _getStartOrEndOfDayMmt(start, 'dayStart');
					if (!start.isSame(startDate, 'hour') || !start.isSame(startDate, 'minute')){
						//scope.isAllDay = false;
						var startMmt = _getStartOrEndOfDayMmt(moment(scope.start.value, dateTimeFormat), 'dayStart');
					var endMmt = _getStartOrEndOfDayMmt(startMmt, 'dayEnd');

					scope.start = { value: moment(startMmt).format(dateTimeFormat) };
					scope.end = { value: moment(endMmt).format(dateTimeFormat) };
					}
				}
​

 

 

Enjoy 🙂

Hi!

 

So I took this and amended it for the latest version of the script. They have separated the validation for start date and end dates in later versions of the store app.

Lines 827-829

            // all day setting
            scope.enableAllDayOption = true; //Allday option to be true so that the user is defaulting to selecting an all day desk instead of an hour slot
            scope.isAllDay = true; //Allday option to be true so that the user is defaulting to selecting an all day desk instead of an hour slot

 

Lines 2813 - 2823 are part of the _startTimeValidation Function

                if (scope.isAllDay) {
                    // REMOVED: When all day mode is selected and the start time is not equal to work day start it will deactivate all day reservation.
					
					//Instead of setting the isAllDay to false when the time is not equal, we are now forcing the time to be the Start of the day when isAllDay is true, assuming that the user is choosing a new day (the start time will default to the current timeslot if you are booking half way through the day)
                    var startDate = _getStartOrEndOfDayMmt(start, 'dayStart');
                    if (!start.isSame(startDate, 'hour') || !start.isSame(startDate, 'minute')) {
                        //scope.isAllDay = false;
						var startMmt = _getStartOrEndOfDayMmt(moment(scope.start.value, dateTimeFormat), 'dayStart');
						scope.start = { value: moment(startMmt).format(dateTimeFormat) };						
                    }
                }

 

Lines 2925 - 2937 are part of the _endTimeValidation Function

                if (scope.isAllDay) {
                    // REMOVED: When all day mode is selected and the end time is not equal to work day end it will deactivate all day reservation.
					
					// Instead of setting the isAllDay to false when the time is not equal, we are now forcing the time to be the End of the day when isAllDay is true.
                    var endDate = _getStartOrEndOfDayMmt(end, 'dayEnd');
                    if (!end.isSame(endDate, 'hour') || !end.isSame(endDate, 'minute')) {
                        //scope.isAllDay = false;  
						var endMmt = _getStartOrEndOfDayMmt(moment(scope.end.value, dateTimeFormat), 'dayEnd');
						scope.end = { value: moment(endMmt).format(dateTimeFormat) };
						spUtil.addInfoMessage("${Start and end times can't be changed for all-day reservations, if you would like to choose specific times, please uncheck the All Day option}");
                    }
                }

 

I added a little message in there to tell the user they need to uncheck the all day option, which does show on load as well as when they try to change the timeslot, but it'll do!

 

Thanks for your code, you definitely pointed us in the right direction!

You're welcome and thanks for the update version, I'll have to take a look at this shortly when we move to Tokyo later this month. 

Thank you for this, Additional to this I want to add another functionality this Default All day should apply  only for "Space", if Room is selected in reservable module I wanted the OOB functionality. Please help me to achieve this