diff --git a/schedule/schedule-appengine/gulpfile.js b/schedule/schedule-appengine/gulpfile.js index bda0c63b..1c937fbb 100644 --- a/schedule/schedule-appengine/gulpfile.js +++ b/schedule/schedule-appengine/gulpfile.js @@ -336,7 +336,6 @@ function staticHtml() { } function i18n() { - console.log(paths.i18n); return gulp.src(paths.i18n) .pipe(gulp.dest(paths.build + '/i18n')); } diff --git a/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/booking-via-jasify.js b/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/booking-via-jasify.js index ff3fd8f7..10eb8291 100644 --- a/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/booking-via-jasify.js +++ b/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/booking-via-jasify.js @@ -45,6 +45,7 @@ angular.forEach(this.activityPackages, function (activityPackage) { ActivityPackage.getActivities(activityPackage.id).then(function (result) { vm.activityPackageActivities[activityPackage.id] = result; + activityPackageExistsCheck(activityPackage.id); updateSelectAllFlags(); }); }); @@ -56,6 +57,8 @@ this.disableActivityPackageActivitySelection = disableActivityPackageActivitySelection; this.confirmRemoveActivity = confirmRemoveActivity; this.confirmRemoveActivityPackage = confirmRemoveActivityPackage; + this.confirmClearActivitySelection = confirmClearActivitySelection; + this.confirmClearPackageSelection = confirmClearPackageSelection; this.hasCompletedActivityPackages = hasCompletedActivityPackages; this.packageSelectionIncomplete = packageSelectionIncomplete; this.packageSelectionComplete = packageSelectionComplete; @@ -116,6 +119,23 @@ }); } + function confirmClearPackageSelection() { + var translation = $translate('CLEAR_PACKAGE_SELECTION_PROMPT'); + jasDialogs.ruSure(translation, function () { + $rootScope.$apply(function () { + vm.activityPackageSelection = {}; + }); + }); + } + function confirmClearActivitySelection() { + var translation = $translate('CLEAR_ACTIVITY_SELECTION_PROMPT'); + jasDialogs.ruSure(translation, function () { + $rootScope.$apply(function () { + vm.activitySelection = []; + }); + }); + } + function confirmRemoveActivityPackage(activityPackage) { var translation = $translate('REMOVE_ACTIVITY_PACKAGE'); jasDialogs.ruSure(translation, function () { @@ -206,6 +226,27 @@ vm.activityPackageSelection = localStorageService.get(sessionStorageKeys.activityPackageSelection) || {}; vm.activitySelection = localStorageService.get(sessionStorageKeys.activitySelection) || []; + + activityExistsCheck(vm.activities); + } + + function activityPackageExistsCheck(activityPackageId) { + + var activityPackageSelection = vm.activityPackageSelection[activityPackageId] || []; + + _.remove(activityPackageSelection, function(activityPackageSelectedActivity) { + return !_.find(vm.activityPackageActivities[activityPackageId], { 'id': activityPackageSelectedActivity.id }); + }); + + if (activityPackageSelection.length === 0) { + delete vm.activityPackageSelection[activityPackageId]; + } + } + + function activityExistsCheck(activities) { + _.remove(vm.activitySelection, function(selectedActivity) { + return !_.find(activities, { 'id': selectedActivity.id }); + }); } function canSelectAllForActivityPackage(activityPackage) { @@ -305,4 +346,4 @@ } } } -}(window.angular, _)); \ No newline at end of file +}(window.angular, _)); diff --git a/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/checkout.selection.html b/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/checkout.selection.html index da658f8b..635fc055 100644 --- a/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/checkout.selection.html +++ b/schedule/schedule-appengine/src/main/client/jasify/booking-via-jasify/checkout.selection.html @@ -35,6 +35,10 @@