Skip to content

Commit

Permalink
Merge pull request #10 from cgkineo/issue/#8
Browse files Browse the repository at this point in the history
update so that allComponentsComplete no longer uses PLP to determine …
  • Loading branch information
oliverfoster committed Mar 14, 2016
2 parents 8fcc148 + 402e2dc commit 4f7ce06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "adapt-pageIncompletePrompt",
"repository": "git://github.com/cgkineo/adapt-pageIncompletePrompt",
"framework": "^2.0.0",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "https://github.com/cgkineo/adapt-pageIncompletePrompt",
"issues": "https://github.com/cgkineo/adapt-pageIncompletePrompt/issues/",
"displayName": "Page Incomplete Prompt",
Expand Down
23 changes: 15 additions & 8 deletions js/adapt-pageIncompletePrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ define([
if (!this.inPopup) return;
this.inPopup = false;

this.stopListening(Adapt, "notify:cancelled");
this.enableRouterNavigation(true);
this.handleRoute = false;
this.inPage = false;
Expand All @@ -55,13 +56,16 @@ define([

onLeaveCancel: function() {
if (!this.inPopup) return;
this.inPopup = false;

this.stopListening(Adapt, "notify:cancelled");
this.routeArguments = undefined;
this.enableRouterNavigation(true);
this.handleRoute = true;
this.inPopup = false;
},

onRouterNavigate: function(routeArguments) {

if(!this.isEnabled() || this.allComponentsComplete()) return;

if (routeArguments[0]) {
Expand Down Expand Up @@ -114,7 +118,7 @@ define([
};
}

this.listenToOnce(Adapt, "notify:closed", this.onLeaveCancel);
this.listenToOnce(Adapt, "notify:cancelled", this.onLeaveCancel);

Adapt.trigger("notify:prompt", promptObject);
},
Expand Down Expand Up @@ -149,15 +153,18 @@ define([
},

allComponentsComplete: function() {
var allComplete = true;

_.each(this.pageComponents, function(component) {
var hasPageProgress = component.get("_pageLevelProgress") && component.get("_pageLevelProgress")._isEnabled;
if(this.pageComponents === null) return true;

for(var i = 0, count = this.pageComponents.length; i < count; i++) {
var component = this.pageComponents[i];
var isMandatory = (component.get('_isOptional') === false);
var isComplete = component.get("_isComplete");
if(hasPageProgress && !isComplete) allComplete = false;
});

return allComplete;
if(isMandatory && !isComplete) return false;
}

return true;
},

enableRouterNavigation: function(value) {
Expand Down

0 comments on commit 4f7ce06

Please sign in to comment.