From 24525793d3b10ba12df7b064f3ef26648c17ab6e 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            | 7 ++++---
 wcs/qommon/static/css/dc2/admin.css     | 7 +++++++
 wcs/qommon/static/css/qommon.css        | 7 +++++++
 wcs/templates/wcs/formdata_history.html | 3 ++-
 5 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/tests/test_form_pages.py b/tests/test_form_pages.py
index c095013d..56fe4b3d 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 b71b6b5c..285d59fe 100644
--- a/wcs/backoffice/management.py
+++ b/wcs/backoffice/management.py
@@ -2105,10 +2105,11 @@ class FormBackOfficeStatusPage(FormStatusPage):
                 status_colour = None
             status_colour = status_colour or 'ffffff'
             fg_colour = misc.get_foreground_colour(status_colour)
+            visibility_off = 'visibility-off' if formdata.get_status().get_visibility_restricted_roles() else ''
 
-            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('<p class="current-status %s"><span class="item" style="background: #%s; color: %s;"></span>' %
+                    (visibility_off, status_colour, fg_colour))
+            r += htmltext('<span class="status">%s %s</span></p>') % (_('Status:'), formdata.get_status_label())
             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 b8802abe..de27c4cc 100644
--- a/wcs/qommon/static/css/dc2/admin.css
+++ b/wcs/qommon/static/css/dc2/admin.css
@@ -1451,6 +1451,13 @@ p.current-status span {
 	line-height: 130%;
 }
 
+p.current-status.visibility-off span.status::after {
+	margin-left: 1rem;
+	content: "\f070";  /* fa-eye-slash */
+	font-family: FontAwesome;
+	color: #3c3c33;
+}
+
 p.current-level .item,
 p.current-status .item {
 	float: left;
diff --git a/wcs/qommon/static/css/qommon.css b/wcs/qommon/static/css/qommon.css
index a34d9d2b..d916ca01 100644
--- a/wcs/qommon/static/css/qommon.css
+++ b/wcs/qommon/static/css/qommon.css
@@ -530,6 +530,13 @@ ul#evolutions span.status {
 	display: inline-block;
 }
 
+ul#evolutions li.visibility-off span.status::after {
+	margin-left: 1rem;
+	content: "\f070";  /* fa-eye-slash */
+	font-family: FontAwesome;
+	font-weight: normal;
+}
+
 ul#evolutions span.user {
 	display: block;
 	opacity: 0.5;
diff --git a/wcs/templates/wcs/formdata_history.html b/wcs/templates/wcs/formdata_history.html
index 5c553544..81e966ac 100644
--- a/wcs/templates/wcs/formdata_history.html
+++ b/wcs/templates/wcs/formdata_history.html
@@ -7,7 +7,8 @@
     {% 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 }}">
+               {% if status.get_visibility_restricted_roles %}visibility-off{% endif %}
+               {{ 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 %}
-- 
2.20.1

