openproject icon indicating copy to clipboard operation
openproject copied to clipboard

Add ability to log hours in HH:MM format

Open shapkarin opened this issue 3 years ago • 15 comments

Hello. When I log time with Open Project there is always a problem to convert in mind HH:MM format to the hours in floating point format. I suggest to change the interface and allow users to use additional field Time in HH:MM at the "Log time" popup. At the database it will be still stored as hours in float number format and for any kind of calculation used the same format as well.

What do you think about such improvement? Should I continue to implement that and have a change to be merged next? It's only the UI change, hours will be still in float values at the database.

Have a look at screenshots with prototype:

Screenshot 2021-07-10 at 16 17 10 Screenshot 2021-07-10 at 16 39 46

shapkarin avatar Jul 10 '21 13:07 shapkarin

Hi @shapkarin , thanks for expressing your interest in this topic. There is already a ticket for this with some discussion at https://community.openproject.org/work_packages/33231

So in general, we would favor the possibility to have HH::MM inputs into time fields. It would be nice to paste decimal values and have that converted? What do you think?

oliverguenther avatar Jul 10 '21 19:07 oliverguenther

Hello, @oliverguenther. Can you please explain what you mean about:

It would be nice to paste decimal values and have that converted? What do you think?

shapkarin avatar Jul 10 '21 19:07 shapkarin

@oliverguenther I think to use both values for the UI. When user change HH:MM input there is Hours updates and opposite – change Hours and HH:MM calculates automatically.

shapkarin avatar Jul 11 '21 07:07 shapkarin

not sure completely about math, here is the playground https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012

shapkarin avatar Jul 11 '21 17:07 shapkarin

+1 !

nikita-fuchs avatar Jul 14 '21 13:07 nikita-fuchs

@oliverguenther fixed math! added other commit.

Here is how it works https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012 hope all is current, we don't need any mistakes in log hours.

Will try to deal with Angular (that I never used before) to add the UI

UPD: there is still some mistake...

console.log(hoursToTime(1.12)) // outputs "01:07"
console.log(timeToHours('01:06')) // wrong: outputs 1.1 not 1.11

shapkarin avatar Jul 16 '21 17:07 shapkarin

Currently I create some check at https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012

[...Array(60)].forEach((_, i) => {
  const value = `01:${padNum(i)}`;
  const hours = timeToHours(value);
  const time = hoursToTime(hours);
  console.log(`input: ${value}, hours: ${hours}, time: ${time}`);
});

and there is no any problem when you convert time to hours, but there is some issue when you convert hours that are not in sync with HH:MM values, like 1.03 and 1.04 is the same value at HH:MM 01:02

Here is some logs

"input: 01:00, hours: 1.00, time: 01:00"
"input: 01:01, hours: 1.02, time: 01:01"
"input: 01:02, hours: 1.03, time: 01:02"
"input: 01:03, hours: 1.05, time: 01:03"
"input: 01:04, hours: 1.07, time: 01:04"
"input: 01:05, hours: 1.08, time: 01:05"
"input: 01:06, hours: 1.10, time: 01:06"
"input: 01:07, hours: 1.12, time: 01:07"
"input: 01:08, hours: 1.13, time: 01:08"
"input: 01:09, hours: 1.15, time: 01:09"
"input: 01:10, hours: 1.17, time: 01:10"
"input: 01:11, hours: 1.18, time: 01:11"
"input: 01:12, hours: 1.20, time: 01:12"
"input: 01:13, hours: 1.22, time: 01:13"
"input: 01:14, hours: 1.23, time: 01:14"
"input: 01:15, hours: 1.25, time: 01:15"
"input: 01:16, hours: 1.27, time: 01:16"
"input: 01:17, hours: 1.28, time: 01:17"
"input: 01:18, hours: 1.30, time: 01:18"

shapkarin avatar Jul 17 '21 00:07 shapkarin

To use hours values like 1.04, 1.05 and other, I should add seconds to the HH:MMHH:MM:SS

shapkarin avatar Jul 17 '21 13:07 shapkarin

Hi @shapkarin , there's also the DurationEditField that handles editing of work package values here that would need the same formatting. We could extract your functionality into a service and then use that in the respective components.

https://github.com/opf/openproject/blob/dev/frontend/src/app/shared/components/fields/edit/field-types/duration-edit-field.component.ts

oliverguenther avatar Jul 26 '21 13:07 oliverguenther

@oliverguenther thanks, it's definitely should be a service. Will try to create it this weekend but not sure that I can create the UI.

shapkarin avatar Jul 27 '21 16:07 shapkarin

@shapkarin hi, do you have any progress? I look forward to this function.

tuxmartin avatar Oct 07 '21 20:10 tuxmartin

@tuxmartin hello, thanks to notice. I can add service at the next weekend... not early. Next someone should add the UI

shapkarin avatar Oct 08 '21 18:10 shapkarin

@tuxmartin can you help with UI integration? I can deal with service, but not with the Angular components...

shapkarin avatar Oct 08 '21 18:10 shapkarin

@shapkarin No. I'm sorry. I know only Java and Python.

tuxmartin avatar Oct 10 '21 18:10 tuxmartin

any news?

ammd1313 avatar Jul 24 '22 07:07 ammd1313

Closing old PRs. Please reopen if work is still being conducted on this.

ulferts avatar Oct 05 '22 14:10 ulferts

@shapkarin hello, any news? It will be great feature.

tuxmartin avatar Oct 05 '22 16:10 tuxmartin