annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Place column comments at the end of the line (feature suggestion)

Open Adeynack opened this issue 1 year ago • 9 comments

Prelude

This feature was implemented by me in annotate_models in those PRs: #988 and #999. Since that other GEM does not seem to be maintained anymore, I am considering a switch to annotaterb but would love that feature to follow.

I volunteer for implementing it, but I prefer to first post this as an issue, in case there is resistance to the idea.

It would be anyways an opt-in and would not change the behavior otherwise. It would also open the door to further formats in the future.

Feature Suggestion

At the moment, when we configure the column comments to be documented, we get them with the name of the column, on the left of the table.

#  type                                                                                                            :enum             not null
#  book_id                                                                                                         :uuid             not null, indexed
#  parent_id(A null parent means it is a root register.)                                                           :uuid             indexed
#  starts_at(Opening date of the register (eg: for accounts, but not for categories).)                             :date
#  expires_at(Optional expiration date of the register (eg: for a credit card).)                                   :date
#  currency_iso_code                                                                                               :string(3)        not null

What is proposed here is to add a new configuration that allow the user to state if they want the comment with the column name (the actual behavior, and would be the default), or at the very end of the table (on the right).

The reason for such a feature is that those comments are extra information, and pushing the whole table further to the right for having them is not ideal. Also, they could potentially be long and it's then better to scroll right to read them comments, than to read their type / nullity / etc.

The proposed configuration key would be position_of_column_comment and could have the following values:

Value Description
with_name (default) The comment appears with next to the name, in parenthesis.
rightmost_column The comment appears in its own column, at the far right of the table.

Example above, configured with rightmost_column:

#  type               :enum             not null
#  book_id            :uuid             not null, indexed   A null parent means it is a root register.
#  parent_id          :uuid             indexed
#  starts_at          :date                                 Opening date of the register (eg: for accounts, but not for categories).
#  expires_at         :date                                 Optional expiration date of the register (eg: for a credit card).
#  currency_iso_code  :string(3)        not null

Contribution

As mentioned in the prelude, I offer to implement this myself, so do not hesitate to assign this to me if there is no objections.

Adeynack avatar Nov 14 '24 19:11 Adeynack

Hi, thanks for bringing this up. No objections here. I meant to get around to this after this refactor landed [1] (while unemployed), but then I got a job and haven't had a chance to sit down and get to it. Looking forward to having this as an addition. Please let me know if the refactors that I made do help or not, I'm actually very curious how it feels to make such changes.

[1] https://github.com/drwl/annotaterb/commit/710fec850cd6412863fd9432e86806ac14354b53

drwl avatar Nov 15 '24 02:11 drwl

Thanks for pointing out this refactor. Will help my understanding of the structure.

Adeynack avatar Nov 15 '24 12:11 Adeynack

@drwl : I am starting work on this. Please assign me to it, just to make it obvious and avoid someone maybe picking it up (if that is how you work on this repository).

Adeynack avatar Nov 15 '24 12:11 Adeynack

Sure I can assign you. I haven't had that issue yet where people would duplicate work (a good problem to have), but perfectly fine to make it clear.

drwl avatar Nov 16 '24 05:11 drwl

@drwl : I am starting work on this. Please assign me to it, just to make it obvious and avoid someone maybe picking it up (if that is how you work on this repository).

@drwl - I just switched to this gem and tried out the comments feature, and had the same thoughts. (It is not ideal to have it in it's present location).

So wanted to check how it's going with this change?

I also wanted to suggest instead of making it configurable, how about just changing it so that it shows up as you suggested? Seems just better across the board.

galori avatar Jan 23 '25 00:01 galori

@galori : I am sorry for my slow speed. But I am am still planning on working on this as soon as possible, since I am a huge fan of this feature and implemented it in the former annotate GEM.

EDIT: Actually, I'll work a bit on it tonight. Thanks for the reminder ;-)

Adeynack avatar Feb 03 '25 20:02 Adeynack

Update: Working more actively (free time in the evenings) on this.

Adeynack avatar Feb 05 '25 23:02 Adeynack

Let me know if you need a 2nd pair of eyes on this, if you're hitting any bugs, etc.

galori avatar Feb 25 '25 19:02 galori

Happy to report that a PR was just opened for this feature.

Adeynack avatar Mar 03 '25 21:03 Adeynack

Thansk for the merge! Exciting news, @drwl!

Just for information – not for pressure! – when can we expect a release that includes this feature?

Adeynack avatar Jul 01 '25 22:07 Adeynack