mominsamir / smDateTimeRangePicker

Angular Material Date Picker, DateTime Picker, Date Range Picker, Date Time range picker
http://mominsamir.github.io/smDateTimeRangePicker/
MIT License
130 stars 50 forks source link

Custom Range, calendar widget allowing start date as future date and current date as end date #133

Closed kvkv closed 7 years ago

kvkv commented 7 years ago

Sm date picker is working fine. In custom range when select the start date, it disabled the previous arrow icon and also disabled the previous dates. But middle month& year button is not disabled. We can select the button and go to the previous years and months. In the previous year and months dates are disabled. But when we click on the "ok" button, start date and end date values are not coming correctly. If disabled the previous year and months also it is fine or give the validation message for start date end date , it is fine.

Please provide the solution.

mominsamir commented 7 years ago

I have fixed min year problem but working on max year will take some time. i am pushing fix to this issue please check

oscar09 commented 7 years ago

@mominsamir let me know if you need help with this issue or any other reported bug and I can take a look.

kvkv commented 7 years ago

Hi oscar09,

Thanks for your reply.

I give the demo link. I tried with "Close on Select Date-Time Range Picker". http://mominsamir.github.io/smDateTimeRangePicker/#!/range-picker-demo

The issue is in CUSTOM RANGE selection. Once select the start date, it does not allow to select previous date as end date, but it allow to go to previous years through middle month&year button , it is after start date end date headings. We can go to previous years , but can not select dates. It is fine and all the previous dates are disabled. But at the scenario if we select OK button of the end date calendar, the selection date which are start and end dates are not related to selection. Some times different dates placed in the text box i.e.

in picker.js line number 1687 I changed the code. I added the code below if(!startDate && !endDate) { _ng_model_value = ''; } else if(Date.parse(startDate) > Date.parse(endDate)) {
_ng_model_value = '';
} else { startDate = startDate || 'Any'; endDate = endDate || 'Any'; _ng_model_value = startDate + ' ' + divider + ' ' + endDate; }

Need validation If user select future date as start date and previous date as start date. Just look at the above solution. need to change the above code and give the validation for the scenarion.

oscar09 commented 7 years ago

Got it. I will try to fix it.

oscar09 commented 7 years ago

I believe it is fixed now. Please give it a try when you have a chance. Basically, instead of displaying an error, I am disabling the past dates.

Also, I commented out lines 65 to 72 from calender-date.js. An extra day was being subtracted from the min date, which allowed you to input past dates on the date range. The code was added by Pablo, but I didn't delete it because I still need to find out which bug was intended to be fixed with that code.