From e73065f66c8656a515bcd2519a7dce044ff615f6 Mon Sep 17 00:00:00 2001
From: Thomas NOEL <tnoel@entrouvert.com>
Date: Wed, 28 Aug 2019 00:02:19 +0200
Subject: [PATCH] backoffice: show an slashed eye next to user hidden statuses
 (#34919)

---
 tests/test_form_pages.py                |  2 ++
 wcs/backoffice/management.py            |  6 +++++-
 wcs/qommon/static/css/dc2/admin.css     | 14 ++++++++++++++
 wcs/templates/wcs/formdata_history.html |  8 ++++++--
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/tests/test_form_pages.py b/tests/test_form_pages.py
index c095013d8..56fe4b3db 100644
--- a/tests/test_form_pages.py
+++ b/tests/test_form_pages.py
@@ -3713,6 +3713,7 @@ def test_formdata_generated_document_in_private_history(pub):
     resp = resp.form.submit('button_export_to')
     resp = resp.follow()
     assert 'Form exported in a model' in resp.body
+    assert 'visibility-off' in resp.body
 
     resp = resp.form.submit('button_jump2')
     resp = resp.follow()
@@ -3726,6 +3727,7 @@ def test_formdata_generated_document_in_private_history(pub):
 
     resp = login(get_app(pub), username='foo', password='foo').get(resp.request.url)
     assert not 'Form exported in a model' in resp.body
+    assert 'visibility-off' not in resp.body
 
 def test_formdata_form_file_download(pub):
     create_user(pub)
diff --git a/wcs/backoffice/management.py b/wcs/backoffice/management.py
index dfe968ff7..9fba14ecb 100644
--- a/wcs/backoffice/management.py
+++ b/wcs/backoffice/management.py
@@ -2116,7 +2116,11 @@ class FormBackOfficeStatusPage(FormStatusPage):
 
             r += htmltext('<p class="current-status"><span class="item" style="background: #%s; color: %s;"></span>' %
                     (status_colour, fg_colour))
-            r += htmltext('<span>%s %s</span></p>') % (_('Status:'), formdata.get_status_label())
+            r += htmltext('<span>%s %s') % (_('Status:'), formdata.get_status_label())
+            if formdata.get_status().get_visibility_restricted_roles():
+                r += htmltext('<span class="visibility-off" title="%s"></span>') % _(
+                        'This status is not visible to users.')
+            r += htmltext('</span></p>')
             if formdata.formdef.workflow.criticality_levels:
                 try:
                     level = formdata.get_criticality_level_object()
diff --git a/wcs/qommon/static/css/dc2/admin.css b/wcs/qommon/static/css/dc2/admin.css
index b5fe9d2ea..c8ab09748 100644
--- a/wcs/qommon/static/css/dc2/admin.css
+++ b/wcs/qommon/static/css/dc2/admin.css
@@ -1456,6 +1456,20 @@ p.current-status span {
 	line-height: 130%;
 }
 
+p.current-status span.visibility-off {
+	display: inline;
+	height: auto;
+}
+
+span.visibility-off::after {
+	cursor: help;
+	margin-left: 1rem;
+	content: "\f070";  /* fa-eye-slash */
+	font-family: FontAwesome;
+	font-weight: normal;
+	color: #3c3c33;
+}
+
 p.current-level .item,
 p.current-status .item {
 	float: left;
diff --git a/wcs/templates/wcs/formdata_history.html b/wcs/templates/wcs/formdata_history.html
index 5c5535448..743092979 100644
--- a/wcs/templates/wcs/formdata_history.html
+++ b/wcs/templates/wcs/formdata_history.html
@@ -7,12 +7,16 @@
     {% with status=evolution.get_status display_parts=evolution.display_parts %}
     <li class="{% if evolution.who == '_submitter' %}msg-in{% elif evolution.who %}msg-out{% else %}msg-system{% endif %}
                {% if status.is_endpoint %}endpoint{% endif %}
-               {{ status.extra_css_class }}">
+               {{ status.extra_css_class|default:"" }}">
       <span class="item {% if not evolution.status %}no-status-change{% endif %}" style="background: #{{ status.colour }}; color: {{ status.get_contrast_color}}"></span>
       <div>
        {% if evolution.status %}
          <div class="evolution-metadata">
-           <span class="status">{{evolution.get_status_label}}</span>
+           <span class="status">{{evolution.get_status_label}}
+             {% if status.get_visibility_restricted_roles %}
+             <span title="{% trans "This status is not visible to users" %}" class="visibility-off"></span>
+             {% endif %}
+           </span>
            <span class="time">{{evolution.datetime}}
              {% if evolution.last_jump_datetime and user.is_admin %}
              <span class="last-jump">({% trans "last check:" %} {{ evolution.last_jump_datetime }})</span>
-- 
2.23.0

