ng-matero/extensions

[Datepicker] Action button

JonkiH opened this issue · 7 comments

Just wondering if there is an possibility to have some kind of overwrite so when we are using action button it would still send event when some date is chosen in the date picker,

This could open up the possibility to have custom functionality in action button area of the date picker.

insted of this check
image
and this
image

to have some kind of variable that is possible to overwrite. to open up this possibility, this work except when we chose date in the calendar because there is no event that happened anymore
image

Best regards
Jónki

@CnxAtanasIliev Do you have any good ideas?

@JonkiH Would you mind giving some example to what you want to achieve as I dont understand quite well what the desired functionality needs to be. In general you should be able to define your own buttons in the actions element and dont have to necessarily use the built-in ones. This is basically ported functionality from Angular Material itself. I dont mind expanding it more, but I dont understand the ask here.

As for the changed event in general it is tied to the buttons being there, because if they are not used it automatically closes the overlay and emits the event.

What we are trying to do is create today button but when we do we loose the normal functionality.

When you have no action button you can press day and then that day is chosen.
Then you add action button you cant to that, we have to add the apply button to be able to chose day.

We are trying to add bottoms that have custom functionality with out loose the normal functionality.

What we are trying to do is create today button but when we do we loose the normal functionality.

When you have no action button you can press day and then that day is chosen. Then you add action button you cant to that, we have to add the apply button to be able to chose day.

We are trying to add bottoms that have custom functionality with out loose the normal functionality.

I think you can get the methods from the datetimepicker instance

<mtx-datetimepicker #datetimepicker>
  <mtx-datetimepicker-actions>
    <button mat-button (click)="datetimepicker.close()">Close</button>
  </mtx-datetimepicker-actions>
</mtx-datetimepicker>

@nzbin @JonkiH One thing that comes to my mind that can be done is this:
Make the calendar dependent on a "SelectionMode" property with values 'auto' and 'manual'.
Make the property default to 'auto' if no actions are present and default to 'manual' if actions are present.
Expose the property as an Input for overriding purposes.

I kind of get what @JonkiH wants to do I think. Basically he wants to have a button 'Today', which focuses the current day (for example), but doesn't want to add an Apply button necessarily to handle the selection with a second action.

Thoughts?

@CnxYankoNikolov it exactly what I want!

If it is possibility to disable the the normal function (like it is to day, where if you have action buttons it disable the option to click day and it is chosen) with some input then also comes the possibility to create custom functionality.

For example someone want to create button that should chose always next Monday or day one week from now.

Today (Idag witch is custom functionality) works for us but we need also to have Apply (Verkställ) but we would like to skip him since the user now need to chose the day and then press Apply.
image

@nzbin If you are okay with the approach I think its fairly easy to do.