Project

General

Profile

Adding Column to Time Log Table

Added by Marek Stepan about 5 years ago

Hello ,
so i was tasked with adding the Project description column to the Time Log Table in Redmine 4.0.2 , i have no idea where to start and my searched attempts brought no fruit .

I know of custom columns but there doesnt seem to be a option to merge a custom column with the data of a existing table /description/ .

Any pointers on how to accomplish this are greatly apreaciated .

Yours Friendly ,
Marek Stepan


Replies (6)

RE: Adding Column to Time Log Table - Added by Bernhard Rohloff about 5 years ago

Hi Marek,

look at source:trunk/app/models/time_entry_query.rb#L25.
I think adding the following line should do the trick.

QueryColumn.new(:project, :sortable => "#{Project.table_name}.description", :groupable => false),

Kind regards,

Bernhard

RE: Adding Column to Time Log Table - Added by Marek Stepan about 5 years ago

Hello Bernhard ,
Firstmost ,i thank you for your reply and help.

I did as you told , and added the line in the correct file in opt/bitnami/apps/redmine/htdocs/app/models/time_entry_query.rb

Restart all services with ./ctlscript.sh restart in opt/bitnami .

But unfortunately it didnt seem to do the trick .
Am i missing something ? Im sorry upfront if im missing something "newbie-like" but im completly new to redmine .

//EDIT: I then realized maybe i need to add it in the administrator section after these changes , when i saw two Project columns i was hopefull that that was it but , i could not add both of them to the "Selected columns " list , then i tried changing the codeline , which changed the name of the Object in the list and i was able to add it to "selected columns" but then redmine Timelog window crashed . (After each stepp i run ctlscript.sh restart )

"QueryColumn.new(:description, :sortable => "#{Project.table_name}.description", :groupable => false),"

Any Suggestions or help is apreciated .

Yours Friendly ,
Marek Stepan

code change.PNG (438 KB) code change.PNG initial code change
project columns.PNG (8.33 KB) project columns.PNG two project columns
description columnt.PNG (17.5 KB) description columnt.PNG after changing project to description
error.PNG (9.68 KB) error.PNG crashing on time log view

RE: Adding Column to Time Log Table - Added by Bernhard Rohloff about 5 years ago

Oh yes you're right!
It seems I was a bit too confident with my answer and haven't tested it beforehand. Sorry for that.
This line actually works in my dev-environment:

QueryAssociationColumn.new(:project, :description, :caption => :field_description, :sortable => "#{Project.table_name}.description"),

I haven't found a label for "project description" so for testing I have chosen the :field_description label.
As "Description" is a kind of vague name for that column I would recommend that you create a separate label for it.
But if you don't care about it this is all you have to change.

Greetings,

Bernhard

RE: Adding Column to Time Log Table - Added by Marek Stepan almost 5 years ago

For Some Reason i cant send the reply i written to you and get an Error Message .

//EDIT Message:

Thank you !
This worked like a charm ,

Intrigued by the usage of Querycolumn and QueryAssociationColumn to self educate i dove into the docs of rubydoc.info but i found only method and object specification not
really any deeper or practical explanation and i could wrap my hand around the usage/difference between them . Do you maybe at any chance know of better learning material for Ruby/Redmine development ?

In hopes it is not too much to ask more of your time and knowledge , do you have any pointers for me on the label creation/implementation part you spoke about ?
Altought the change you suggested is enought for meeting the needs , i would like to make the proper changes .

Lastly Thank you again for sharing with me your time and knowledge ,

P.S.
I completly understand if you dont have the time ,
or dont have the information at hand , which i asked for .

RE: Adding Column to Time Log Table - Added by Bernhard Rohloff almost 5 years ago

I'm glad to hear it works for you. Unfortunately there are no real sources of system documentation for Redmine. Sometimes it's quite hard to find the right parts to change. Most of my knowledge I've gathered from the code itself and from patches on the issue tracker. Studying the patches is a very good method because you get a feeling for what is actually needed to change things. Just like a small how-to guide. Of course a ruby or rails course is a good way to build fundamentals.
For plugin development I can recommend the book "Redmine Plugin Extension and Develoment" by Alex Bevilacqua and there is also a tutorial on how to write plugins in the wiki.

So for getting into Redmine the best thing you can do is setting up a development environment and start playing with it.
Don't be afraid to ask if you have any further questions. :-)

Greetings,

Bernhard

RE: Adding Column to Time Log Table - Added by Marek Stepan over 4 years ago

Hey Bernhard ,
im writing to you in hopes that you have some constructive feedback for another question i have as nobody really responded to my queries and im kinda really stuck.
If you would like please take a look at my newly created topic "https://www.redmine.org/boards/2/topics/57589" .

LG Marek Stepan

    (1-6/6)