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

No grouping of project entries #10

Closed floeschie closed 12 years ago

floeschie commented 12 years ago

I just installed your plugin and so far it's working really well. However, there's one thing I do not understand...

All projects and sub projects in Mite are grouped, for example:

customer A

In Redmine they do not appear grouped, but sorted alphabetically by subprojects (!), for example:

bar A.2 (customer A) bor B.2 (customer B) faa B.1 (customer B) foo A.1 (customer A)

This is very confusing and makes it hard to match Redmine projects with Mite projects... Is there a way how to use the same grouped sorting as in Mite?

Cheers,

Florian

thomasklein commented 12 years ago

Hey Florian! First of all, thanks for your comment on the previous installation-related issue! Now to your question: grouping the projects like you suggested is currently not implemented. I would however, consider this in a next version. Right now I'm out of time to make improvements on the code, but I'll come back to it soon.

Best, Thomas

floeschie commented 12 years ago

I'm trying to change the plugin, but it seems my changes don't do anything. I edited the lib/mite/project.rb and changed method name_with_customer to this:

def name_with_customer
   respond_to?(:customer_name) && !customer_name.blank? ? "#{customer_name} - #{name}" : name
end

I restarted Apache/Passenger, cleared Redmine's cache (rake tmp:cache:clear && rake tmp:sessions:clear) and disconnected Redmine from Mite.

Then I reconnected Redmine and Mite and synced again, but still the Mite projects appear as "Project (Customer)" instead of "Customer - Project"...

Any hints? Maybe some caching thing I'm not aware of?

thomasklein commented 12 years ago

Hey!

Everything under lib/mite/ is part of the mite.api (https://github.com/yolk/mite-rb) and an therefore an embedded project. Please don't change anything there, as the main project might change in the future. Rather checkout the code at app/views/mite/index.rhtml which embeds the partial app/views/mite/_user_bindings_projects.rhtml to create the select lists.

floeschie commented 12 years ago

Yeah I know it's not the best idea to edit the project.rb file. But unfortunately mite-rb does not follow the MVC rules as it saves the project and customer names as a concatenated string instead into the database. So I cannot change the way within the view (except doing some weird string splitting)... That's why I decided to change the mite-rb code directly and I'm aware of the concequences.

However, the question is still the same: Why do my changes not take effect?

thomasklein commented 12 years ago

Check out the method save_account_data in app/controllers/mite_controller.rb as the database entries for the plugin are created at this point. So you did nothing wrong in terms of resetting the plugin, but just changed the wrong code. Didn't dive into my own code since a while, so sorry for pointing you at the wrong location in the first place!

floeschie commented 12 years ago

Hey Thomas!

Got it, thanks alot! For the record: Here's the git diff output:

--- a/plugins/redmine2mite/app/controllers/mite_controller.rb
+++ b/plugins/redmine2mite/app/controllers/mite_controller.rb
@@ -92,8 +92,7 @@ class MiteController < ApplicationController

           # UPDATE project in Redmine
           #####################
-            rsrc_name = projectM.name
-            rsrc_name += " (" + projectM.customer_name + ")" if projectM.respond_to?("customer_name")
+            rsrc_name = projectM.respond_to?("customer_name") ? "#{projectM.customer_name} - #{projectM.name}" : projectM.name^M

             existingProjectR.update_attributes(:mite_rsrc_name => rsrc_name,
                                                :mite_rsrc_updated_at => projectM.updated_at.localtime)
@@ -102,8 +101,7 @@ class MiteController < ApplicationController
         #####################
           else
             newProjectR = MiteProject.new do |p|
-              p.mite_rsrc_name = projectM.name
-              p.mite_rsrc_name += " (" + projectM.customer_name + ")" if projectM.respond_to?("customer_name")
+              p.mite_rsrc_name = projectM.respond_to?("customer_name") ? "#{projectM.customer_name} - #{projectM.name}" : projectM.name^M
               p.mite_rsrc_id = projectM.id
               p.mite_rsrc_updated_at = projectM.updated_at
               p.user_id = User.current.id