Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Range - Show current and previous month #5386

Closed
ChaudhryAtif opened this issue Sep 11, 2019 · 13 comments · Fixed by #5513
Closed

Date Range - Show current and previous month #5386

ChaudhryAtif opened this issue Sep 11, 2019 · 13 comments · Fixed by #5513

Comments

@ChaudhryAtif
Copy link

Feature description or feature request:

Is it possible to show current and previous (instead of current and next) month in range picker if no range is selected?

Plunker/StackBlitz that reproduces the issue:

Here is a workaround found on SO, but I am wondering if there's a cleaner way to do it (or if it can be baked into the library), and also to only do this behavior when a range is not selected already.

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 5.1.1

Angular: 8.3.0

Bootstrap: 4.3.1

@ChaudhryAtif ChaudhryAtif changed the title Date Range - Show current and previous Date Range - Show current and previous month Sep 11, 2019
@daniloff200
Copy link
Contributor

@ChaudhryAtif hey!
It's possible to create functionality, that allows to show prev & current months, but, I want more info about the second part of your request

What do you mean by

also to only do this behavior when a range is not selected already.
?

As I understood, you want to keep the current and prev month only if no daterange was selected, but, if I did that, then, it should show current month and next? Or what?

@ChaudhryAtif
Copy link
Author

ChaudhryAtif commented Sep 17, 2019

@daniloff200 If it is already selected, then it should follow current functionality: It'll show the starting date of the range on left and next month on the right.

@daniloff200
Copy link
Contributor

@ChaudhryAtif okay, cool
gonna look at it, and what I can make here

@daniloff200
Copy link
Contributor

@ChaudhryAtif

Hello ! I'm now working with that, and wanna ask one question, that appeared during dev process

That's how it gonna work. For now it's October, but, you will see September too
Selection_036

But, when you choose daterange only in September (not touching October), when you open calendar again, you're still gonna see September & October, and not August & September
Selection_037

Does it correct for you?

If you choose range with October in it, after opening calendar again, you will see October and November, the next month, as it worked before.

Waiting for your answer!

@ChaudhryAtif
Copy link
Author

ChaudhryAtif commented Oct 18, 2019

@daniloff200 Thank you for working on this!

Edit/Update: I re-read your reply and I think I am saying the same thing below, so yes that is the desired behavior. Misunderstanding on my part!

===

Here's a rough example of expected outcome: https://stackblitz.com/edit/angular-mtluz4

Top picker is current behavior, bottom is desired feature (by a property, say showPreviousMonth="true")

If you open the top picker, it shows current (Oct) and next (Nov) month.
If you open the bottom picker, it shows previous (Sep) and current (Oct) month.

==

If you select a range on the top picker, the start date will become the month on the left, and it'll show next month on the right. For example: 8/10 - 8/14 (Aug on left, Sep on right). 11/10 - 12/10 (Nov on left, Dec on right).

If you select range on the bottom picker, it'll currently always show previous and current month (due to workaround/hack). What I meant by "also to only do this behavior when a range is not selected already." in my original post is that when the date range is selected, it should fall back to original functionality like the top picker.

I hope this helps. Again, thanks for working on this!

@daniloff200
Copy link
Contributor

@ChaudhryAtif thanks for details and good example! Looks like my feature, works exactly the same, as in your demo! Hope it will be merged this week

@ChaudhryAtif
Copy link
Author

Perfect! Thank you for the effort!

@ChaudhryAtif
Copy link
Author

@daniloff200, it's been a while. Any update on this?

@daniloff200
Copy link
Contributor

@ChaudhryAtif
Sorry for the delay
Should be available in latest version, I supposed it's 5.4.0

@bunmiedee
Copy link

@daniloff200 is there a way to avoid the current month moving to the left on date selection? I'd like to keep the previous month on the left at all times.

Current behaviour: Assuming current month is October, When I open the date picker I see September and October. This is okay. When I select a date in October the view changes to October and November.

Expected behaviour: I'd like to have an option to keep the initial months September and October after selecting a date in the current month

@daniloff200
Copy link
Contributor

daniloff200 commented Oct 27, 2020

@bunmiedee suppose you're talking about functionality described here : #5968
It's some new feature request from another user on stackoverflow, I hope to make it in the next versions, but, right now, it's not possible

@bunmiedee
Copy link

Ah yes! @daniloff200 this is exactly what I meant. Thanks for the update. Will keep an eye out for that

@kennylevi
Copy link

is it possible to remove the second calendar, from the date range picker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants