diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js index f615fb4990..63807df7d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js @@ -18,7 +18,6 @@ var stepForwardFrom = {}; var stepBackFrom = {}; var policy = {}; -var configuredOperations = []; var validateInline = {}; var clearInline = {}; var validateStep = {}; @@ -173,7 +172,11 @@ stepForwardFrom["policy-platform"] = function (actionButton) { * Forward action of policy profile page. Generates policy profile payload. */ stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); + /* + generatePolicyProfile() function should be implemented in plugin side and should include the logic to build the + policy profile object. + */ + policy["profile"] = generatePolicyProfile(); // updating next-page wizard title with selected platform $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); }; @@ -182,8 +185,11 @@ stepForwardFrom["policy-profile"] = function () { * Backward action of policy profile page. Moves back to platform selection step. */ stepBackFrom["policy-profile"] = function () { - // reinitialize configuredOperations - configuredOperations = []; + /* + resetPolicyProfile() function should be implemented in plugin side and should include the logic to reset the policy + profile object. + */ + resetPolicyProfile(); }; /** @@ -359,18 +365,12 @@ stepForwardFrom["policy-naming"] = function () { }; var savePolicy = function (policy, isActive, serviceURL) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } + /* + generateProfileFeaturesList() should be implemented in the plugin side and should include logic to build the + profilePayloads array which contains objects, {featureCode:"value", deviceType:"value", content:"value"}. + policy["profile"] object will be available for the method which returns from the generatePolicyProfile() function. + */ + var profilePayloads = generateProfileFeaturesList(); $.each(profilePayloads, function (i, item) { $.each(item.content, function (key, value) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js index ce37d8d6a9..f06ae43796 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js @@ -20,7 +20,6 @@ var validateStep = {}; var skipStep = {}; var stepForwardFrom = {}; var stepBackFrom = {}; -var configuredOperations = []; var policy = {}; var currentlyEffected = {}; @@ -200,9 +199,11 @@ skipStep["policy-platform"] = function (policyPayloadObj) { script.type = 'text/javascript'; script.src = policyOperationsScriptSrc; $(".wr-advance-operations").prepend(script); - var configuredOperations = operationModule.populateProfile(policy["platform"], - policyPayloadObj["profile"]["profileFeaturesList"]); - polulateProfileOperations(configuredOperations); + /* + This method should be implemented in the relevant plugin side and should include the logic to + populate the policy profile in the plugin specific UI. + */ + polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]); } }); }); @@ -227,7 +228,11 @@ skipStep["policy-platform"] = function (policyPayloadObj) { * Forward action of policy profile page. Generates policy profile payload. */ stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); + /* + generatePolicyProfile() function should be implemented in plugin side and should include the logic to build the + policy profile object. + */ + policy["profile"] = generatePolicyProfile(); // updating next-page wizard title with selected platform $("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); }; @@ -415,19 +420,12 @@ var getParameterByName = function (name) { }; var updatePolicy = function (policy, state) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } + /* + generateProfileFeaturesList() should be implemented in the plugin side and should include logic to build the + profilePayloads array which contains objects, {featureCode:"value", deviceType:"value", content:"value"}. + policy["profile"] object will be available for the method which returns from the generatePolicyProfile() function. + */ + var profilePayloads = generateProfileFeaturesList(); $.each(profilePayloads, function (i, item) { $.each(item.content, function (key, value) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js index b7bea7684f..2d045b864f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js @@ -86,9 +86,11 @@ var displayPolicy = function (policyPayloadObj) { script.type = 'text/javascript'; script.src = policyOperationsScriptSrc; $(".wr-advance-operations").prepend(script); - var previouslyConfiguredOperations = operationModule.populateProfile(policy["platform"], - policyPayloadObj["profile"]["profileFeaturesList"]); - polulateProfileOperations(previouslyConfiguredOperations); + /* + This method should be implemented in the relevant plugin side and should include the logic to + populate the policy profile in the plugin specific UI. + */ + polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]); } }); });