Orkun Posted August 27, 2019 Share Posted August 27, 2019 Hi Guys I needed to add extended functionalities for the InputfieldDatetime Module (module is from processwire version 2.7.3) because of a Request of Customer. So I duplicated the module and placed it under /site/modules/. I have added 3 new Settings to the InputfieldDatetime Module. 1. Day Restriction - Restrict different days based on weekdays selection (e.g. saturday, sunday) - WORKING 2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING 3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY The Problem Time Slots and Day Restriction working fine so far. But the Time Range Rules per Weekday doesn't work right. What should happen is, that when you click on a date, it should update the minTime and maxTime of the Time Select. But the change on the select only happens if you select a date 2 times or when you select a date 1 time and then close the datepicker and reopen it again. The time select doesn't get change when you select a date 1 time and don't close the picker. Here is the whole extended InputfieldDatetime Module. The Files that I have changed: InputfieldDatetime.module InputfieldDatetime.js jquery-ui-timepicker-addon.js (https://trentrichardson.com/examples/timepicker/) - updated it to the newest version, because minTime and maxTime Option was only available in the new version Thats the Part of the JS that is not working correctly: if(datetimerules && datetimerules.length){ options.onSelect = function(date, inst) { var day = $(this).datetimepicker("getDate").getDay(); day = day.toString(); var mintime = $(this).attr('data-weekday'+day+'-mintime'); var maxtime = $(this).attr('data-weekday'+day+'-maxtime'); console.log("weekday: "+day); console.log("minTime: "+mintime); console.log("maxTime: "+maxtime); var optionsAll = $(this).datetimepicker( "option", "all" ); optionsAll.minTime = mintime; optionsAll.maxTime = maxtime; $(this).datetimepicker('destroy'); $(this).datetimepicker(optionsAll); $(this).datetimepicker('refresh'); //$.datepicker._selectDate($(this).attr("id"),date); //$.datepicker._base_getDateDatepicker(); // var inst = $.datepicker._getInst($(this)); // $.datepicker._updateDatepicker(inst); /*$(this).datetimepicker('destroy'); InputfieldDatetimeDatepicker($(this), mintime, maxtime); $(this).datetimepicker('refresh'); */ // $(this).datetimepicker('option', {minTime: mintime, maxTime: maxtime}); } } Can you have a look and find out what the Problem is? InputfieldDatetime.zip Kind Regards Orkun Link to comment Share on other sites More sharing options...
Orkun Posted August 28, 2019 Author Share Posted August 28, 2019 Can anyone help please? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now