Project

General

Profile

How to hide private comments

Added by Lubomír Vrána about 2 years 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 (6)

RE: How to hide private comments - Added by Mayama Takeshi about 2 years 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 about 2 years 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 about 2 years 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 about 2 years 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'));
}

RE: How to hide private comments - Added by Glenn Goffin over 1 year ago

@Lubomír Vrána,

Thanks for this nifty feature; the script below works great for me. Nice touch on showing the checking box only when private notes are found within the DOM and cookies support!

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'), 365);
}

function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {   
    document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

RE: How to hide private comments - Added by Nion Marvin over 1 year ago

I notice this option has been discussed many times. It would be really useful to hide private comments on inventory items, but really NOT useful to also hide location as a result like at simcasts.I print my orders and use them to check the stock itjem, and then printout for my customer's. I need the location info, but I don't want them to see my private comments about the item. So I would rather have the option to hide the PRIVATE comments only.This seems kind of logical to me, eg PRIVATE means they should be for me only. Thanks for answer before very useful! I'll try it

    (1-6/6)