Jump to content

Extended InputfieldDatetime Module Settings doesn't work correctly


Orkun
 Share

Recommended Posts

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
2027229116_Bildschirmfoto2019-08-28um08_17_42.png.a55079643b9d56068bef2f3774d86497.png

 

2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING
1295759755_Bildschirmfoto2019-08-28um08_18_11.png.e15b5eef8988f5904e41d1e705140493.png

 

3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY
1076686440_Bildschirmfoto2019-08-28um08_20_06.png.0ab376d984ee82395a9bb653ac94d96c.png

 

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:

 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...