material icon indicating copy to clipboard operation
material copied to clipboard

Don't want to show md-calendar-month on date picker

Open shruti0207 opened this issue 10 years ago • 45 comments

Is there an any option that user can only select year and month in datepicker, the date views should not shown to user. once the user select the year and month is close the calendar and it show the select date in MM/YYYY format that also in some specific field not in complete application.

Show only year and month view year-month-view

Hide date view date-views

regrading #9246

I try parseDate and formatDate methods on the $mdDateLocaleProvider but it format the date when date is selected from the calendar, if date enter using keyboard in number format (08052016) it not get formatted as (08/05/2016) and if make the change in mdDatelocalProvider than the date format change every where in application, just need to change the date format in some specific field only

shruti0207 avatar Aug 08 '16 06:08 shruti0207

It's not possible, but it seems like it could be useful. I'm not sure how it would work with the input field, though.

crisbeto avatar Aug 08 '16 07:08 crisbeto

+1

jagmindersingh avatar Aug 17 '16 10:08 jagmindersingh

Date is not getting format if user enter the date using keyboard in mm/dd/yyyy format and it also not get validate. Is there any way if user enter the date through keyboard it get format and same date select on calendar.

image

shruti0207 avatar Aug 24 '16 07:08 shruti0207

@crisbeto How'd see this option implemented? My suggestion is add md-select-month option to allow selecting months rather than dates. I didn't figure out how this option should work with md-current-view.

summerisgone avatar Sep 28 '16 07:09 summerisgone

+1 on this.

I need to implement this in a current project. It would be great if we could do md-select-month == true and have the year view loaded and close when the month is selected.

artharrison avatar Oct 01 '16 20:10 artharrison

Sorry, I was away last week. I'll try to get this sorted soon, although it also depends on https://github.com/angular/material/issues/9270 since it needs to be able to do different formatting.

crisbeto avatar Oct 01 '16 20:10 crisbeto

Thanks for doing tackling this. I've put together a Plunkr and I'm running into a couple of issues when I've tried it out.

  1. If I specify initial view of month and 'day' as the mode, I can't click the month to step out to change years.
  2. If I specify 'year' as the initial view, I can no longer pick a day, even if the mode is day. This would be useful if you were picking a birthdate, for example.

In the Plunkr the first date picker should let you pick a day, and start with the current month. The second date picker should start with the month/year view, but let you pick the day when you select a month. The third date picker behaves as expected - it should allow you to pick a year/month but not a date.

I hope this is helpful and that I'm not just making some silly mistake.

ryan-kimber avatar Oct 03 '16 02:10 ryan-kimber

Hold on - I may have had files from before you marked this as complete. I'll rebuild tomorrow and provide an update.

ryan-kimber avatar Oct 03 '16 03:10 ryan-kimber

Perhaps I misunderstood the use case @ryan-kimber, but I though the idea was to be able to limit the user to only selecting a certain type of date (e.g. only the day or only the month). In order for that to work, md-mode has to override md-current-view and disable navigation between views. Here's how each of your examples should be:

  1. This shouldn't use md-mode at all since it's just the standard calendar. If you give it md-mode="day", it will limit the user to only selecting a day.
  2. This also doesn't need md-mode, it just needs md-current-view="year".
  3. This one is as expected.

That being said, it doesn't seem like the mode takes in the falsy values properly at the moment. I'll look into that later.

crisbeto avatar Oct 03 '16 05:10 crisbeto

Ahh. I see. It would be pretty helpful then (at least for projects like ours) to have md-mode='default'.

We dynamically create a lot of elements, so being able to do 'md-mode={{::dateConfig.mode || 'default'}} would save us from having to do an ng-if and having two md-datepickers in our template. Anything we can do to keep code size and number of watches down, we try to do.

I've updated my plunkr to show two dates for each 'date-config' I'd created and you are correct, it works as you designed.

Would you consider my request to add an option for 'md-mode="default"'?

Thanks.

On Mon, Oct 3, 2016 at 1:32 AM, Kristiyan Kostadinov < [email protected]> wrote:

Perhaps I misunderstood the use case @ryan-kimber https://github.com/ryan-kimber, but I though the idea was to be able to limit the user to only selecting a certain type of date (e.g. only the day or only the month). In order for that to work, md-mode has to override md-current-view and disable navigation between views. Here's how each of your examples should be:

  1. This shouldn't use md-mode at all since it's just the standard calendar. If you give it md-mode="day", it will limit the user to only selecting a day.
  2. Starting off with the year, but still selecting a date - This also doesn't need md-mode, it just needs md-current-view="year".
  3. This one is as expected.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/material/issues/9260#issuecomment-251029690, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-JTZJIB77EfXk5xSUx8Ejo-i-zoxMoks5qwJNwgaJpZM4Jevh1 .

ryan-kimber avatar Oct 03 '16 17:10 ryan-kimber

Sure, I'll re-check since it was supposed to also work if the md-mode was empty, but it doesn't seem like it is.

crisbeto avatar Oct 03 '16 17:10 crisbeto

You should be able to set default (or any other invalid value) now @ryan-kimber. Only the valid ones will prevent navigation.

crisbeto avatar Oct 03 '16 18:10 crisbeto

Excellent. Thank you.

On Monday, October 3, 2016, Kristiyan Kostadinov [email protected] wrote:

You should be able to set default (or any other invalid value) now @ryan-kimber https://github.com/ryan-kimber. Only the valid ones will prevent navigation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/material/issues/9260#issuecomment-251188615, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-JTTsg5CFgR5n1o3cMntuUGeVG-g6Qks5qwUu8gaJpZM4Jevh1 .

ryan-kimber avatar Oct 04 '16 02:10 ryan-kimber

@ryan-kimber I was checking your Plunker, but did not load? Seems like some links to files (angular css js) at https://static.formhero.io/formhero/ return a 403 error.

aaroncalderon avatar Oct 11 '16 21:10 aaroncalderon

Ahh. Yes. This issue was resolved and there have been updates to support custom date labels, so I removed the old custom-build angular-material files.

On Tue, Oct 11, 2016 at 6:00 PM, Aaron [email protected] wrote:

@ryan-kimber https://github.com/ryan-kimber I was checking your Plunker, but did not load? Seems like some links to files (angular css js) at https://static.formhero.io/formhero/ https://static.formhero.io/formhero/ return a 403 error.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/material/issues/9260#issuecomment-253059452, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-JTUBEJUOxjjuT8l_BLLRi5KlyMS1Uks5qzAbqgaJpZM4Jevh1 .

ryan-kimber avatar Oct 12 '16 15:10 ryan-kimber

@ryan-kimber mmm I am pretty much trying to acheive the same. Where you let the user selcet a year/month but no date (day) but have not figured out how.

~~Would you care to share how you configured the component?~~ Is the commit pending approval? (to answer my own question... yes).

aaroncalderon avatar Oct 12 '16 17:10 aaroncalderon

The Plunkr still isn't working yet. Could someone provide a snippet on how to achieve the month/year selector only without the need to select a date? md-current-view="year" will give the preferred view but clicking will still go to the day select view. Would be great to override this with a setting. Thanks!

volmerf avatar Oct 14 '16 14:10 volmerf

The changes needed haven't been merged yet @volmerf

crisbeto avatar Oct 14 '16 14:10 crisbeto

I've update the Plunkr so that it works.

As crisbeto noted though, this isn't yet merged into Angular-Material proper. If you want to use this you'll either have to copy the angular-material .js and .css from the plunkr, or clone the angular-material repository, make a branch, manually merge the two pull requests for this issue and the custom label for date fields issue and finally run 'npm install && gulp' to build your own custom distribution.

Working in the Plunkr at https://plnkr.co/edit/nJyHfu?p=preview

ryan-kimber avatar Oct 14 '16 15:10 ryan-kimber

@ryan-kimber Can we achieve only year select mode in md-datepicker , If yes then How can I achieve this functionality? Actually, this is needed when we select financial year or something like that.

Waiting for response.

chetan01b avatar Dec 22 '16 10:12 chetan01b