g1eb / angular-datetime-range

📅 Angular directive for datetime range input
https://rawgit.com/g1eb/angular-datetime-range/master/
MIT License
25 stars 14 forks source link

Preset Issue: Pulling in current date/time unexpectedly #9

Closed mmccallum closed 7 years ago

mmccallum commented 7 years ago

Hi, Great little component. I'm liking it so far.

Seem to be having an issue where presets are picking up the wrong date. I would expect that when using a preset, to be able to set the start date and end date, but when setting the start using moment and adding an amount of time to the end, the component gets updated with the current date/time. Of course, I could be doing something wrong. I've created a fiddle example: https://jsfiddle.net/rtzmxLgL/6/

Please let me know if I am using something wrong, because that is entirely possible.

Thanks! M

g1eb commented 7 years ago

Thanks! I'm glad you like it :)

If I understand correctly you would like to keep current start/end datetime objects when using presets. That is to say, selecting a preset would update the time but not the date. Is that right?

If that is the case you just need to update your array of presets in your setDate method. See this fiddle for an example.

mmccallum commented 7 years ago

Close. What I would like to see is this: 1) Select a start date and time. 2) Open presets, select the length of time ( 15 minutes, 30 minutes, 1 hour, etc) The result should be that the start date stays the same and the end date has the preset applied to it to,

Does that make it clear? Your example fiddle still resets the start date.

-M

g1eb commented 7 years ago

Ahh, gotcha, you select start date and time manually (I was thrown off by "click on set date and then select preset" instruction in your fiddle).

I've updated the fiddle to match described behavior.

mmccallum commented 7 years ago

Getting closer. :) The set date was just to simulate getting an existing date from an external source.

Your example does seem to currently work if you use the set date button, but if you select a start date/time, click the close button at the bottom, the preset options disappear. A couple of times I could get them back but both dates would get clobbered if I could use them.

-M

g1eb commented 7 years ago

Haha, we are getting there :)

In any case, you have a well defined flow, users enter start date and time then proceed to select a preset range of time. All you need to do is update presets right?

(close button has a different callback, updated fiddle)

g1eb commented 7 years ago

Hi, how are you doing?

Just wanted to check in to see if you got this working or if you need my help :)

mmccallum commented 7 years ago

Thanks for checking in. I didn't get it to work as I wanted to. For now, I have moved past it and will come back to it. Could we keep this open a bit longer?

On Fri, Feb 3, 2017 at 7:54 AM, Gleb notifications@github.com wrote:

Hi, how are you doing?

Just wanted to check in to see if you got this working or if you need my help :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/g1eb/angular-datetime-range/issues/9#issuecomment-277240314, or mute the thread https://github.com/notifications/unsubscribe-auth/AGKixztZGipzQKF4dep5zNUwewBZBli9ks5rYyOhgaJpZM4Lt9jZ .

g1eb commented 7 years ago

Of course, take your time! Let me know if you need my help with it :)

g1eb commented 7 years ago

Closing due to prolonged period of inactivity