How to hide private comments

Added by Lubomír Vrána 7 days ago

Is there any way how to temporarily hide private comments?

Imagine the situation that I am at a customer and we go through the tasks together. Normally the customer doesn't see our private comments, but I do and so does the customer while watching my laptop's screen via a beamer :)

I need to hide them, just temporarily.

I was trying to google a solution, but I haven't found anything, not even a plugin.
Any ideas?

Replies (4)

RE: How to hide private comments - Added by Mayama Takeshi 6 days ago

You could use this plugin to execute javascript code:
https://github.com/martin-denizet/redmine_custom_js

Once you have it installed you would go to:
https://YOUR_REDMINE_SERVER/settings/plugin/redmine_custom_js
and write something like this:

$(document).ready(() => {
  $('.journal > div > h4 > span.private').parent().parent().parent().hide()
})

This would hide the private comments when the page is loaded.
However, the private comments will become visible again if you click on the "History" or "Notes" tabs.
So you might need to add further code to handle this. For example:

var hidePrivateComments = function() {
  $('.journal > div > h4 > span.private').parent().parent().parent().hide()
}

$(document).ready(() => {
  hidePrivateComments()

  $("#tab-history, #tab-notes").click(() => {
       setTimeout(() => { hidePrivateComments() }, 0)
  })
})

RE: How to hide private comments - Added by Bernhard Rohloff 6 days ago

Lubomír Vrána wrote:

Is there any way how to temporarily hide private comments?

Imagine the situation that I am at a customer and we go through the tasks together. Normally the customer doesn't see our private comments, but I do and so does the customer while watching my laptop's screen via a beamer :)
...

IMHO it sounds like a nice feature for Redmine core.
Would you mind to create a feature request for it?

Greetings,
Bernhard

RE: How to hide private comments - Added by Liane Hampe 6 days ago

Hi Lubomír,

When you don't like to code as suggested by Mayama, then you could simply add a new role which has most of the permissions you have but is not allowed to see private notes. With this role you could share your screen to your customer.

Best Regards,
Liane

RE: How to hide private comments - Added by Lubomír Vrána 6 days ago

Thank you very much. I installed Redmine Custom JS plugin and this is my solution:

My javascript code adds a checkbox "Show private comments" to the upper right corner (into the P element with the class 'author') and save the state in cookies (I use global functions getCookie and setCookie, they happen to exist, so I used them).
This checkbox is only visible if there is at least one private comment (something with 'private-notes' class) on the page.

document.addEventListener("DOMContentLoaded", () =>
{
    if ($(".private-notes").length)
    {
        var hidePrivateComments = getCookie('hide_private_comments');

        $("<span style='float:right'><input type='checkbox' id='show_private_comments' " + (hidePrivateComments === '1' ? "" : "checked='checked'") + " onchange='togglePrivateComments()' /><label for='show_private_comments'>Show private comments</label></span>").appendTo($("div.issue.details p.author"));

        togglePrivateComments();
    }
});

function togglePrivateComments()
{
    const checkboxShowPrivateComments = document.getElementById("show_private_comments");

    if (checkboxShowPrivateComments.checked)
    {
        $(".private-notes").show();
    }
    else
    {
        $(".private-notes").hide();
    }

    setCookie('hide_private_comments', (checkboxShowPrivateComments.checked ? '0' : '1'));
}

(1-4/4)