phase2 / openair-reborn

A Chrome extension to improve (fix) the OpenAir time entry grid interface
11 stars 18 forks source link

Does not work for timesheet weeks that start on Sunday, rather than Monday #30

Open twohue opened 9 years ago

twohue commented 9 years ago

I love this freaking extension, really, truly, honestly, I do, but I am going to kick babies if this thing screws up my entries again.

Just for kicks, I checked out what day 7/14/2014 was (from the extension screenshot) and sure enough, it was Monday.

I can't get my company to change the way the weeks are in OA, and try as I might, I cannot figure out how to fix it in the code. I've looked at every last file, poured over every last detail, and it still eludes me.

PLEASE fix this so that it's flexible about the week starting day. I will buy you beer, I will bring you hookers and blackjack. Just help me.

crittermike commented 9 years ago

That was such a passionate plea, how can I say no? Can you please send me a screenshot of an empty timesheet that starts with Sunday as well as a copy and paste of the html (view source), so that I have something to work with? I can't get my company to make my week start on Sunday for me to work on this.

On Wed, Jan 21, 2015, 7:23 PM Alex notifications@github.com wrote:

I love this freaking extension, really, truly, honestly, I do, but I am going to kick babies if this thing screws up my entries again.

Just for kicks, I checked out what day 7/14/2014 was (from the extension screenshot) and sure enough, it was Monday.

I can't get my company to change the way the weeks are in OA, and try as I might, I cannot figure out how to fix it in the code. I've looked at every last file, poured over every last detail, and it still eludes me.

PLEASE fix this so that it's flexible about the week starting day. I will buy you beer, I will bring you hookers and blackjack. Just help me.

— Reply to this email directly or view it on GitHub https://github.com/phase2/openair-reborn/issues/30.

twohue commented 9 years ago

Thank you SOOOOO MUCH, you have no idea what this will mean to me, and everyone else that has to deal with OA at my company. Total lifesaver.

I've e-mailed you directly with the requested resources. Please let me know if you need anything else.

Eternally grateful,

-Alex

crittermike commented 9 years ago

Hey Alex, haven't gotten it yet, did you send to mikecrittenden@gmail.com ?

On Mon Jan 26 2015 at 10:31:34 AM Alex notifications@github.com wrote:

Thank you SOOOOO MUCH, you have no idea what this will mean to me, and everyone else that has to deal with OA at my company. Total lifesaver.

I've e-mailed you directly with the requested resources. Please let me know if you need anything else.

Eternally grateful,

-Alex

— Reply to this email directly or view it on GitHub https://github.com/phase2/openair-reborn/issues/30#issuecomment-71478414 .

twohue commented 9 years ago

Zip hosted and link e-mailed. Thanks.

crittermike commented 9 years ago

Got it!

On Mon Jan 26 2015 at 10:55:45 AM Alex notifications@github.com wrote:

Zip hosted and link e-mailed. Thanks.

— Reply to this email directly or view it on GitHub https://github.com/phase2/openair-reborn/issues/30#issuecomment-71482849 .

twohue commented 9 years ago

Hey buddy, checking in on this - I'm desperate. Can I place a bounty on this feature?

Shall we start the bribing at, say - $25.00?

crittermike commented 9 years ago

Wow, I really screwed the pooch on this one.

I spent some time with it tonight, and it's proving to be near impossible for me to fix this in a way that I can be sure that it's fixed without being able to set it up so that Sunday is the first day on my end. I tried dropping in the markup that you sent and that didn't do it because OpenAir does a lot of wild stuff on page load before I can get to it.

That said, it seems like some combination of altering the following is the fix:

  1. $scope.getDaysArray function in timeentry.js
  2. $scope.weekdays array in timeentry.js
  3. getDayNum function in openair.js

Sorry I couldn't be more helpful here. I'll leave this open in case anyone else wants to come along and help out.

mattdurf commented 6 years ago

I'm late to this party/discussion, but just came across this extension in trying to make my timekeeping life a little less hellish. I love this extension, but was having the same issue as other users here since our work week is configured to start on Saturdays, so all entries are two days off when saving.

I think I have found a simple fix for this, so wanted to make a suggestion. As mentioned above, in OpenAir.js, there is a function at line 391 - GetDayNum. I was able to get my situation to work flawlessly by simply modifying the order of the array defined in this function so that Saturday is index 0, Sunday index 1, and so on:

    /**
     * Helper function to convert two digit day code to integer.
     *
     * @TODO: Start using numbers instead of day codes. It'll remove a lot of dumb logic.
     *
     * @param {string} dayCode
     * @returns {int}
     */
    this.getDayNum = function(dayCode) {
        var  weekdays = [];
        weekdays.sa = 0;
        weekdays.su = 1;
        weekdays.mo = 2;
        weekdays.tu = 3;
        weekdays.we = 4;
        weekdays.th = 5;
        weekdays.fr = 6;
        return weekdays[dayCode];
    };

To make this universally configurable, it would be good to have a new setup item on the Options page to specify your OpenAir weekday order, or just starting day of the week. Then this function would properly order the array based on that input for a given OA schedule.

I'm a hack who is good at reading code and making small modifications, but not necessarily wholesale changes like this, so I am not going to branch this change myself, but wanted to make the suggestion for others who are more capable to implement.

pangolingo commented 6 years ago

If anyone is still using this extension, would you mind checking out PR #37 to see if this solves your problem?