Skip to content

Commit

Permalink
add error check
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Mar 15, 2024
1 parent 6633f56 commit 792e2c6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions portal/eproms/static/css/eproms.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ <h2 class="title">{{_("We want to check with you ...")}}</h2>
</div>
</div>
<div class="error-message"></div>
<div class="continue-container hide">
<button class="btn btn-default continue-button">Continue</button>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-empro-primary btn-submit">Submit</button>
Expand Down
30 changes: 28 additions & 2 deletions portal/static/js/src/empro.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,29 @@ emproObj.prototype.initOptOutElementEvents = function () {
if (!this.hasOptOutModal()) {
return;
}

let errorObserver = new MutationObserver(function (mutations) {
for (let mutation of mutations) {
console.log("mutation? ", mutation);
if (mutation.type === "childList") {
// do something here if error occurred
document
.querySelector("#emproOptOutModal .continue-container")
.classList.remove("hide");
console.log("mutation ", mutation);
}
}
});
errorObserver.observe(
document.querySelector("#emproOptOutModal .error-message"),
{
characterData: true,
attributes: true,
childList: true,
}
);
$("#emproOptOutModal .btn-submit").on("click", function (e) {
e.stopPropagation();
EmproObj.initOptOutModal(false);
EmproObj.populateSelectedOptoutUI();
if (EmproObj.selectedOptOutDomains.length) {
var submitData = {
Expand All @@ -111,7 +131,10 @@ emproObj.prototype.initOptOutElementEvents = function () {
}
// TODO, call API to save selected opt out domains,
// if call failed, display error, e.g. $("#emproOptOutModal .error-message").html(message), else go to the thank you modal
EmproObj.initThankyouModal(true);
// EmproObj.initOptOutModal(false);
//EmproObj.initThankyouModal(true);
document.querySelector("#emproOptOutModal .error-message").innerText =
"Error! Not able to save your choices.";
});

$("#emproOptOutModal .btn-dismiss").on("click", function (e) {
Expand All @@ -132,6 +155,9 @@ emproObj.prototype.initOptOutElementEvents = function () {
);
}
});
$("#emproOptOutModal .continue-button").on("click", function () {
EmproObj.initThankyouModal(true);
});
};
emproObj.prototype.hasOptOutModal = function () {
return $("#emproOptOutModal").length > 0;
Expand Down
3 changes: 3 additions & 0 deletions portal/static/less/eproms.less
Original file line number Diff line number Diff line change
Expand Up @@ -4072,6 +4072,9 @@ section.header {
margin: 4px 2px 8px 0;
}
}
.continue-container {
margin-top: 8px;
}
}
.modal-footer {
background: @bodyBgColor;
Expand Down

0 comments on commit 792e2c6

Please sign in to comment.