From b28870a1d0a91ac6cf951957442f5c6498557478 Mon Sep 17 00:00:00 2001
From: Carlos Vega <carlos.vega@uni.lu>
Date: Thu, 22 Nov 2018 11:49:53 +0100
Subject: [PATCH] activate sidebar elements properly based on sub-elements from
 the comnfiguration and others

---
 smash/web/templates/_base.html               |  4 ++++
 smash/web/templates/configuration/index.html |  2 +-
 smash/web/templates/doctors/index.html       | 13 ++++++++++++-
 smash/web/templates/languages/list.html      |  2 +-
 smash/web/templates/sidebar.html             | 12 ++++++------
 smash/web/templates/study/edit.html          |  2 +-
 smash/web/templates/voucher_types/list.html  |  2 +-
 7 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/smash/web/templates/_base.html b/smash/web/templates/_base.html
index e34aa85d..4c5c65f6 100644
--- a/smash/web/templates/_base.html
+++ b/smash/web/templates/_base.html
@@ -379,6 +379,10 @@ desired effect
         var activate = function (page_to_activate) {
             var $e = $(".sidebar-menu li[data-desc='" + page_to_activate + "']");
             $e.addClass("active");
+            if($($e).parents('li[data-desc]').length > 0){ //if there is a parent, it should also be active
+              $($e).parents('li[data-desc]').addClass("active");  
+            }
+            
         };
 
         activate({% block ui_active_tab %}{% endblock ui_active_tab %});
diff --git a/smash/web/templates/configuration/index.html b/smash/web/templates/configuration/index.html
index 7330cbc8..d5580458 100644
--- a/smash/web/templates/configuration/index.html
+++ b/smash/web/templates/configuration/index.html
@@ -9,7 +9,7 @@
 
 {% endblock styles %}
 
-{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
+{% block ui_active_tab %}'general_conf'{% endblock ui_active_tab %}
 {% block page_header %}Configuration{% endblock page_header %}
 {% block page_description %}{% endblock page_description %}
 
diff --git a/smash/web/templates/doctors/index.html b/smash/web/templates/doctors/index.html
index 1accfd94..315fe279 100644
--- a/smash/web/templates/doctors/index.html
+++ b/smash/web/templates/doctors/index.html
@@ -7,8 +7,18 @@
     <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
 {% endblock styles %}
 
-{% block ui_active_tab %}'workers'{% endblock ui_active_tab %}
+{% block ui_active_tab %}
+{% if worker_type == 'STAFF' %}
+'workers'
+{% elif worker_type == 'HEALTH_PARTNER' %}
+'health_partners'
+{% elif worker_type == 'VOUCHER_PARTNER' %}
+'voucher_partners'
+{% endif %}
+{% endblock ui_active_tab %}
+
 {% block page_header %}
+
 {% if worker_type == 'STAFF' %}
     Workers
 {% elif worker_type == 'HEALTH_PARTNER' %}
@@ -16,6 +26,7 @@
 {% elif worker_type == 'VOUCHER_PARTNER' %}
     Voucher Partners
 {% endif %}
+
 {% endblock page_header %}
 {% block breadcrumb %}
     {% include "doctors/breadcrumb.html" %}
diff --git a/smash/web/templates/languages/list.html b/smash/web/templates/languages/list.html
index eeb9eb68..33a5e517 100644
--- a/smash/web/templates/languages/list.html
+++ b/smash/web/templates/languages/list.html
@@ -7,7 +7,7 @@
     <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
 {% endblock styles %}
 
-{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
+{% block ui_active_tab %}'languages'{% endblock ui_active_tab %}
 {% block page_header %}Languages{% endblock page_header %}
 {% block page_description %}{% endblock page_description %}
 
diff --git a/smash/web/templates/sidebar.html b/smash/web/templates/sidebar.html
index f4b3c857..aedfcfa4 100644
--- a/smash/web/templates/sidebar.html
+++ b/smash/web/templates/sidebar.html
@@ -83,16 +83,16 @@
             </span>
         </a>
         <ul class="treeview-menu">
-            <li><a href="{% url 'web.views.configuration' %}">General</a></li>
-            <li><a href="{% url 'web.views.languages' %}">Languages</a></li>
+            <li data-desc="general_conf"><a href="{% url 'web.views.configuration' %}">General</a></li>
+            <li data-desc="languages"><a href="{% url 'web.views.languages' %}">Languages</a></li>
             {% if study.has_voucher_types %}
-            <li><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li>
+            <li data-desc="voucher_types"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li>
             {% endif %}
             {% if study.has_vouchers %}
-            <li><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher partners</a></li>
+            <li data-desc="voucher_partners"><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher partners</a></li>
             {% endif %}
-            <li><a href="{% url 'web.views.workers' 'HEALTH_PARTNER' %}">Health partners</a></li>
-            <li><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li>
+            <li data-desc="health_partners"><a href="{% url 'web.views.workers' 'HEALTH_PARTNER' %}">Health partners</a></li>
+            <li data-desc="study_conf"><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li>
         </ul>
     </li>
 
diff --git a/smash/web/templates/study/edit.html b/smash/web/templates/study/edit.html
index e37d38a1..760f930b 100644
--- a/smash/web/templates/study/edit.html
+++ b/smash/web/templates/study/edit.html
@@ -16,7 +16,7 @@
     {% include "includes/datetimepicker.css.html" %}
 {% endblock styles %}
 
-{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %}
+{% block ui_active_tab %}'study_conf'{% endblock ui_active_tab %}
 {% block page_header %}Edit subject{% endblock page_header %}
 {% block page_description %}{% endblock page_description %}
 
diff --git a/smash/web/templates/voucher_types/list.html b/smash/web/templates/voucher_types/list.html
index dec5cde7..22ae4733 100644
--- a/smash/web/templates/voucher_types/list.html
+++ b/smash/web/templates/voucher_types/list.html
@@ -7,7 +7,7 @@
     <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
 {% endblock styles %}
 
-{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
+{% block ui_active_tab %}'voucher_types'{% endblock ui_active_tab %}
 {% block page_header %}Voucher types{% endblock page_header %}
 {% block page_description %}{% endblock page_description %}
 
-- 
GitLab