From 2e4e4ea71684a983baf308b2b52b28fd1fc71609 Mon Sep 17 00:00:00 2001 From: Jason White Date: Mon, 3 Jul 2017 12:37:15 -0400 Subject: [PATCH] including restart lesson fix for lesson overview --- .../js/goatApp/controller/LessonController.js | 6 ++++++ .../static/js/goatApp/view/LessonContentView.js | 5 ++++- .../js/goatApp/view/PaginationControlView.js | 15 +++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js index a18a68f65..8fcb97c0d 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/controller/LessonController.js @@ -192,6 +192,7 @@ define(['jquery', }).done(function(lessonLink) { self.loadLesson(self.name); self.updateMenu(); + self.callPaginationUpdate(); }); }; @@ -200,9 +201,14 @@ define(['jquery', this.lessonContentView.showTestParam(param); }; + this.callPaginationUpdate = function () { + this.lessonContentView.updatePagination(); + } + }; + return Controller; }); diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/LessonContentView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/LessonContentView.js index 1cd3ae286..fbc2abf94 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/LessonContentView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/LessonContentView.js @@ -60,6 +60,9 @@ define(['jquery', this.paginationControlView = new PaginationControlView(this.$contentPages,this.model.get('lessonUrl')); }, + updatePagination: function() { + this.paginationControlView.updateCollection(); + }, getCurrentPage: function () { return this.currentPage; @@ -121,7 +124,7 @@ define(['jquery', markAssignmentComplete: function () { this.curForm.reset(); $(this.curForm).siblings('.assignment-success').find('i').removeClass('hidden'); - this.paginationControlView.updateModel(); + this.paginationControlView.updateCollection(); }, markAssignmentIncomplete: function () { diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/PaginationControlView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/PaginationControlView.js index 66e5c75bb..2dcecf136 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/PaginationControlView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/PaginationControlView.js @@ -15,13 +15,12 @@ define(['jquery', initialize: function ($contentPages,baseLessonUrl) { this.$contentPages = $contentPages; this.collection = new LessonOverviewCollection(); - this.listenTo(this.collection, 'change add reset delete update', this.render); + this.listenTo(this.collection, 'reset', this.render); this.numPages = this.$contentPages.length; this.baseUrl = baseLessonUrl; - - this.collection.fetch(); + this.collection.fetch({reset:true}); this.initPagination(); - this.render(); + //this.render(); }, render: function (e) { @@ -32,8 +31,8 @@ define(['jquery', this.hideShowNavButtons(); }, - updateModel: function() { - this.collection.fetch(); + updateCollection: function() { + this.collection.fetch({reset:true}); }, bindNavButtons: function() { @@ -142,7 +141,7 @@ define(['jquery', this.hideNextPageButton(); this.showPrevPageButton; } - this.model.fetch(); + this.collection.fetch({reset:true}); }, decrementPageView: function() { @@ -159,7 +158,7 @@ define(['jquery', this.hidePrevPageButton(); this.showNextPageButton() } - this.model.fetch(); + this.collection.fetch({reset:true}); }, hideShowNavButtons: function () {