thomasklein / redmine2mite

Redmine2mite connects your Redmine account with your mite.account. Track your time easily on issues within Redmine and get them automatically send to mite.
http://mite.yo.lk/
MIT License
13 stars 6 forks source link

Code Snippet: Connect Activities between mite and Redmine #27

Closed netshops closed 11 years ago

netshops commented 11 years ago

Hi Thomas,

i created a little Extension of your Plugin. It disturbed me a little that i have to pick the mite.activity by every timeentry.
(There was no way to connect the activities between mite and redmine like you have it by Projects). So i've writtten a little JS-Function that pick the mite.activity if u picked the redmine.activity and the activitynames match.

Screenshot: http://grab.by/jfJ8

Here's the code:

window.onload = function(e){
  $('#time_entry_activity_id').bind('change', function() {
        var redmine_id = document.getElementById('time_entry_activity_id');
        var mite_id = document.getElementById('time_entry_mite_service_id');
        var redmine_activity = redmine_id.options[redmine_id.selectedIndex].text;

        for (var i = 0; i < mite_id.options.length; i++) {
            if (mite_id.options[i].text == redmine_activity) {
                mite_id.selectedIndex = i;
                mite_id.style.background = "#85E085";
                break;
            }
            if (i == mite_id.options.length -1) {
                mite_id.selectedIndex = 0;
                mite_id.style.background = "#FFFFFF";
            }
        }
    });
}

If u like it, just add the lines at the end of plugins/redmine2mite/assets/javascripts/mite_time_entry_fields.js

Thanks

thomasklein commented 11 years ago

Thanks netshops! I am going to include an option in the preferences for this functionality in the next version. Greetings!

thomasklein commented 11 years ago

Now included in the latest version 2.1. of the plugin! Thanks again for the idea!