From a2d9d4302ca91271bd110ee5528aade2a339d427 Mon Sep 17 00:00:00 2001
From: dilanua <dilan.u.ariyaratne@gmail.com>
Date: Sun, 23 Oct 2016 20:41:59 +0530
Subject: [PATCH] Fixing feature configured icon malfunctioning issue on switch
 double-click

---
 .../public/js/policy-create.js                   | 16 ++++++++++++----
 .../units/mdm.unit.policy.edit/public/js/edit.js | 16 ++++++++++++----
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js
index 1c1eefcfd..bcef26ec8 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js
@@ -2793,20 +2793,28 @@ $(document).ready(function () {
     // <start - fixing feature-configuring switch double-click issue>
     $(advanceOperations).on('hidden.bs.collapse', function (event) {
         var collapsedFeatureBody = event.target.id;
-        var featureConfiguringSwitch = "#" + collapsedFeatureBody.
-            substr(0, collapsedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]";
+        var operation = collapsedFeatureBody.substr(0, collapsedFeatureBody.lastIndexOf("-"));
+        var featureConfiguringSwitch = "#" + operation + "-heading input[type=checkbox]";
+        var featureConfiguredIcon = "#" + operation + "-configured";
         if ($(featureConfiguringSwitch).prop("checked") == true) {
             $(featureConfiguringSwitch).prop("checked", false);
         }
+        if (!$(featureConfiguredIcon).hasClass("hidden")) {
+            $(featureConfiguredIcon).addClass("hidden");
+        }
     });
 
     $(advanceOperations).on('shown.bs.collapse', function (event) {
         var expandedFeatureBody = event.target.id;
-        var featureConfiguringSwitch = "#" + expandedFeatureBody.
-            substr(0, expandedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]";
+        var operation = expandedFeatureBody.substr(0, expandedFeatureBody.lastIndexOf("-"));
+        var featureConfiguringSwitch = "#" + operation + "-heading input[type=checkbox]";
+        var featureConfiguredIcon = "#" + operation + "-configured";
         if ($(featureConfiguringSwitch).prop("checked") == false) {
             $(featureConfiguringSwitch).prop("checked", true);
         }
+        if ($(featureConfiguredIcon).hasClass("hidden")) {
+            $(featureConfiguredIcon).removeClass("hidden");
+        }
     });
     // <end - fixing feature-configuring switch double-click issue>
 
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js
index 7c899b3cb..3e2728ca1 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js
@@ -2556,20 +2556,28 @@ $(document).ready(function () {
     // <start - fixing feature-configuring switch double-click issue>
     $(advanceOperations).on('hidden.bs.collapse', function (event) {
         var collapsedFeatureBody = event.target.id;
-        var featureConfiguringSwitch = "#" + collapsedFeatureBody.
-            substr(0, collapsedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]";
+        var operation = collapsedFeatureBody.substr(0, collapsedFeatureBody.lastIndexOf("-"));
+        var featureConfiguringSwitch = "#" + operation + "-heading input[type=checkbox]";
+        var featureConfiguredIcon = "#" + operation + "-configured";
         if ($(featureConfiguringSwitch).prop("checked") == true) {
             $(featureConfiguringSwitch).prop("checked", false);
         }
+        if (!$(featureConfiguredIcon).hasClass("hidden")) {
+            $(featureConfiguredIcon).addClass("hidden");
+        }
     });
 
     $(advanceOperations).on('shown.bs.collapse', function (event) {
         var expandedFeatureBody = event.target.id;
-        var featureConfiguringSwitch = "#" + expandedFeatureBody.
-            substr(0, expandedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]";
+        var operation = expandedFeatureBody.substr(0, expandedFeatureBody.lastIndexOf("-"));
+        var featureConfiguringSwitch = "#" + operation + "-heading input[type=checkbox]";
+        var featureConfiguredIcon = "#" + operation + "-configured";
         if ($(featureConfiguringSwitch).prop("checked") == false) {
             $(featureConfiguringSwitch).prop("checked", true);
         }
+        if ($(featureConfiguredIcon).hasClass("hidden")) {
+            $(featureConfiguredIcon).removeClass("hidden");
+        }
     });
     // <end - fixing feature-configuring switch double-click issue>