diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js index 5a5383c..4f58dd7 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js @@ -1171,8 +1171,9 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou $rootScope.onDrawingCanvasClick(); $rootScope.FreeStylePaint(); }); - + $rootScope.loadSearchData = function () { + //$("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); var imageId = $rootScope.imageId; var promise = ModuleService.getTermTextDataForAAImage(imageId) @@ -1190,22 +1191,38 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou .from($scope.AAPinTermData) .where('_LanguageId == ' + primaryLexicon) .select(); - + var sortedTermTextArray = []; for (var i = 0; i < $scope.matchedLanguageTermData.length; i++) { - $scope.pinTermData.push({ "LanguageId": $scope.matchedLanguageTermData[i]._LanguageId, "TermNumber": $scope.matchedLanguageTermData[i]._TermNumber, "TermTxt": $scope.matchedLanguageTermData[i]._TermText}); + sortedTermTextArray.push($scope.matchedLanguageTermData[i]._TermText); + sortedTermTextArray.sort(); } + + for (var i = 0; i <= sortedTermTextArray.length - 1; i++) { + for (var j = 0; j <= $scope.matchedLanguageTermData.length - 1; j++) { + if ($scope.matchedLanguageTermData[j]._TermText == sortedTermTextArray[i]) { + $scope.pinTermData.push({ "LanguageId": $scope.matchedLanguageTermData[j]._LanguageId, "TermNumber": $scope.matchedLanguageTermData[j]._TermNumber, "TermTxt": $scope.matchedLanguageTermData[j]._TermText }); + break; + } + } + } + + $scope.$watch('$scope.pinTermData', function (newValue, oldValue, scope) { - if ($('#termlistfilter').html() != "") - // $('#termList').empty(); - $('#termlistfilter').empty() + + if (($('#termlistfilter').html() != "")) + + $('#termlistfilter').empty(); if ($scope.pinTermData.length > 0) { $timeout(function () { console.log('pinTermData= ' + $scope.pinTermData.length); + $('#termList').empty(); for (var j = 0; j < $scope.pinTermData.length; j++) { var $el = $('
  • ' + $scope.pinTermData[j].TermTxt + '
  • ').appendTo('#termlistfilter') $compile($el)($scope); - var $selectedOptions = $('').appendTo("#termList") + var $selectedOptions = $('').appendTo("#termList") + $compile($selectedOptions)($scope); + $("#AABodySystems").empty(); $("#bodySystems").css("display","none"); $("#AABodySystems").css("display","block"); @@ -1229,37 +1246,46 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou $scope.$on('listManagerEvent', function (event, data) { + $("#viewName").empty(); $("#viewName").append(""); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); if ($rootScope.bodySystemSeletedId == null) { + $rootScope.loadSearchData(); } else { + $scope.refreshTermListOnAASystemSelection($rootScope.bodySystemSeletedId); } - + $timeout(function () { + $("#totalTerms").empty(); + $("#totalTerms").html("" + $("#termList option").length + " Structures"); + }, 1000); }); $scope.refreshTermListOnAASystemSelection = function (bodySystemId) { $rootScope.bodySystemSeletedId = bodySystemId; + $('#termList').empty(); var bodySystemName = $("#AABodySystems #" + bodySystemId).val(); if (bodySystemName == "All") { for (var j = 0; j <= $scope.pinTermData.length - 1; j++) { - var $selectedOptions = $('').appendTo("#termList") + var $selectedOptions = $('').appendTo("#termList") $compile($selectedOptions)($scope); } + $("#totalTerms").empty(); + $("#totalTerms").html("" + $("#termList option").length + " Structures"); } else { var imageId = $rootScope.imageId; $scope.pinDataUrl = "aa_dat_pinterm_" + imageId; $rootScope.bodySystemTermArray = []; - $('#termList').empty(); + $.ajax({ url: '~/../content/data/json/aa/aa_pinterm/' + $scope.pinDataUrl + '.json', type: 'GET', @@ -1275,7 +1301,7 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou if ($scope.aaPinData[i]._TermId == $rootScope.bodySystemTermArray[j].termNumbr) { if ($rootScope.bodySystemTermArray[j].language == "1") { console.log($rootScope.bodySystemTermArray[j].text); - var $selectedOptions = $('').appendTo("#termList") + var $selectedOptions = $('').appendTo("#termList") $compile($selectedOptions)($scope); } } @@ -1284,6 +1310,8 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou } } }); + $("#totalTerms").empty(); + $("#totalTerms").html("" + $("#termList option").length + " Structures"); } } $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo) { @@ -1502,7 +1530,7 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou } $scope.highlightPinBasedOnSerachItem = function (event) { - + $scope.searchItemId = event.currentTarget.id; $scope.searchItemText = event.currentTarget.innerHTML; $rootScope.searchSelectedText = $("#" + event.currentTarget.id).text();