Merge branch 'master' into 'master'

Fix corrective policy UI loading intermittent issue

See merge request entgra/carbon-device-mgt!373
feature/appm-store/pbac
Saad Sahibjan 5 years ago
commit 495534ce5f

@ -39,7 +39,6 @@ var validateInline = {};
var clearInline = {}; var clearInline = {};
var validateStep = {}; var validateStep = {};
var hasPolicyProfileScript = false; var hasPolicyProfileScript = false;
var isCorrectiveActionProfileAdded = false;
var enableInlineError = function (inputField, errorMsg, errorSign) { var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField; var fieldIdentifier = "#" + inputField;
@ -224,31 +223,26 @@ stepForwardFrom["policy-profile"] = function () {
} }
// add policy correction action page // add policy correction action page
if (!isCorrectiveActionProfileAdded) { var policyCorrectiveActionTemplateSrc =
var policyCorrectiveActionTemplateSrc = "/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
"/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs"; var policyCorrectiveActionScriptSrc =
var policyCorrectiveActionScriptSrc = "/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
"/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js"; var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc, function (template) {
function (template) { var content = template(
var content = template( {
{ "deviceType": policy["platform"],
"deviceType": policy["platform"], "correctivePolicies": $("#logged-in-user").data("corrective-policies")
"correctivePolicies": $("#logged-in-user").data("corrective-policies") }
} );
); $("#select-general-policy-type").html(content);
$("#select-general-policy-type").html(content)
});
var script = document.createElement('script'); var script = document.createElement('script');
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = context + policyCorrectiveActionScriptSrc; script.src = context + policyCorrectiveActionScriptSrc;
document.head.append(script); document.head.append(script);
});
isCorrectiveActionProfileAdded = true
}
// updating next-page wizard title with selected platform // updating next-page wizard title with selected platform
$("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); $("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
@ -645,8 +639,6 @@ $(document).ready(function () {
} }
}); });
isCorrectiveActionProfileAdded = false;
$('input[type=radio][name=policy-type-radio-btn]').change(function() { $('input[type=radio][name=policy-type-radio-btn]').change(function() {
if ($(this).val() === "CORRECTIVE") { if ($(this).val() === "CORRECTIVE") {
$("#select-general-policy-type").addClass("hidden"); $("#select-general-policy-type").addClass("hidden");

@ -42,7 +42,6 @@ var currentlyEffected = {};
var validateInline = {}; var validateInline = {};
var clearInline = {}; var clearInline = {};
var hasPolicyProfileScript = false; var hasPolicyProfileScript = false;
var isCorrectiveActionProfileAdded = false;
var enableInlineError = function (inputField, errorMsg, errorSign) { var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField; var fieldIdentifier = "#" + inputField;
@ -285,46 +284,41 @@ stepForwardFrom["policy-profile"] = function () {
$("input[name=policy-type-radio-btn][value=" + policyType + "]").prop("checked", true).trigger('change'); $("input[name=policy-type-radio-btn][value=" + policyType + "]").prop("checked", true).trigger('change');
// add policy correction action page // add policy correction action page
if (!isCorrectiveActionProfileAdded) { var policyCorrectiveActionTemplateSrc =
var policyCorrectiveActionTemplateSrc = "/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
"/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs"; var policyCorrectiveActionScriptSrc =
var policyCorrectiveActionScriptSrc = "/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
"/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js"; var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc, function (template) {
function (template) { var content = template(
var content = template( {
{ "deviceType": policy["platform"],
"deviceType": policy["platform"], "correctivePolicies": $("#logged-in-user").data("corrective-policies")
"correctivePolicies": $("#logged-in-user").data("corrective-policies") }
} );
); $("#select-general-policy-type").html(content);
$("#select-general-policy-type").html(content); if ("GENERAL" === policyType && currentlyEffected.correctiveActions &&
if ("GENERAL" === policyType && currentlyEffected.correctiveActions && currentlyEffected.correctiveActions.length > 0) {
currentlyEffected.correctiveActions.length > 0) { currentlyEffected.correctiveActions.forEach(function (correctiveAction) {
currentlyEffected.correctiveActions.forEach(function (correctiveAction) { if ("POLICY" === correctiveAction.actionType) {
if ("POLICY" === correctiveAction.actionType) { if ($("#corrective-policy-input option[value=" + correctiveAction.policyId + "]").length > 0) {
if ($("#corrective-policy-input option[value=" + correctiveAction.policyId + "]").length > 0) { $("#corrective-policy-input").val(correctiveAction.policyId);
$("#corrective-policy-input").val(correctiveAction.policyId); } else {
} else { $("#corrective-action-policy-id-missing-msg").removeClass("hidden");
$("#corrective-action-policy-id-missing-msg").removeClass("hidden");
}
// returned from for each since currently only supported corrective action type is
// POLICY.
return true;
} }
}); // returned from for each since currently only supported corrective action type is
} // POLICY.
}); return true;
}
var script = document.createElement('script'); });
script.type = 'text/javascript'; }
script.src = context + policyCorrectiveActionScriptSrc; var script = document.createElement('script');
document.head.prepend(script); script.type = 'text/javascript';
script.src = context + policyCorrectiveActionScriptSrc;
isCorrectiveActionProfileAdded = true; document.head.prepend(script);
} });
$(".policy-type-loading-corrective-actions").addClass("hidden"); $(".policy-type-loading-corrective-actions").addClass("hidden");
@ -768,8 +762,6 @@ $(document).ready(function () {
$("#policy-profile-wizard-steps").html($(".wr-steps").html()); $("#policy-profile-wizard-steps").html($(".wr-steps").html());
isCorrectiveActionProfileAdded = false;
$('input[type=radio][name=policy-type-radio-btn]').change(function() { $('input[type=radio][name=policy-type-radio-btn]').change(function() {
if ($(this).val() === "CORRECTIVE") { if ($(this).val() === "CORRECTIVE") {
$("#select-general-policy-type").addClass("hidden"); $("#select-general-policy-type").addClass("hidden");

Loading…
Cancel
Save