diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 8129e1a..7585759 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -5439,12 +5439,50 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } - $rootScope.openViews.push( - { - "module": $rootScope.currentActiveModuleTitle, "bodyView": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": currentBodyViewId, - "slug": $rootScope.currentSlug - } - ); + var correspondingBodyViewId = $scope.correspondingBodyViewIds[currentBodyViewId]; + var alraedyOpenedViewDetail; + if ($rootScope.openViews != null || $rootScope.openViews != undefined) { + if ($rootScope.openViews.length > 0) { + alraedyOpenedViewDetail = new jinqJs() + .from($rootScope.openViews) + .where("BodyViewId == " + correspondingBodyViewId) + .select(); + } + } + debugger; + if (alraedyOpenedViewDetail != undefined || alraedyOpenedViewDetail.length > 0) { + // $rootScope.openViews.removeValue('BodyViewId', correspondingBodyViewId); + + findAndRemove($rootScope.openViews, 'BodyViewId', correspondingBodyViewId); + function findAndRemove(array, property, value) { + array.forEach(function (result, index) { + if (result[property] === value) { + //Remove from array + array.splice(index, 1); + } + }); + } + + //Checks countries.result for an object with a property of 'id' whose value is 'AF' + //Then removes it ;p + + + $rootScope.openViews.push( + { + "module": $rootScope.currentActiveModuleTitle, "bodyView": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": currentBodyViewId, + "slug": $rootScope.currentSlug + } + ); + } + + else { + $rootScope.openViews.push( + { + "module": $rootScope.currentActiveModuleTitle, "bodyView": localStorage.getItem("currentViewTitle"), "state": 'max', "BodyViewId": currentBodyViewId, + "slug": $rootScope.currentSlug + } + ); + } var target = angular.element(event.currentTarget); var title_male_female = target.attr('title');