Commit 06ba67f661e38c11c3c7e0190cd2c083cffc7209

Authored by Amrita Vishnoi
1 parent 02852240

Apply search function is pasted.

400-SOURCECODE/AIAHTML5.Web/app/controllers/TinyViewListController.js
@@ -96,4 +96,194 @@ function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, Bod @@ -96,4 +96,194 @@ function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, Bod
96 } 96 }
97 97
98 98
  99 + $scope.ApplySearch = function (query) {
  100 +
  101 + $scope.filterstring = true;
  102 +
  103 + while ($scope.searchCIListViewData.length) {
  104 + $scope.searchCIListViewData.pop();
  105 + }
  106 +
  107 + //$('#grid-view').empty();
  108 +
  109 + filtercount = 0;
  110 + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null && query.selectedbodyregion !== "")) {
  111 + filtercount = filtercount + 1;
  112 + localStorage.setItem("CICurBodyRegion", query.selectedbodyregion);
  113 + }
  114 + else {
  115 + localStorage.setItem("CICurBodyRegion", '');
  116 + }
  117 +
  118 + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null && query.selectedbodysystem !== "")) {
  119 + filtercount = filtercount + 1;
  120 + localStorage.setItem("CICurBodySystem", query.selectedbodysystem);
  121 + }
  122 + else {
  123 + localStorage.setItem("CICurBodySystem", '');
  124 + }
  125 +
  126 + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== '')) {
  127 + filtercount = filtercount + 1;
  128 + localStorage.setItem("CICurOrientation", query.selectedorientation);
  129 + }
  130 + else {
  131 + localStorage.setItem("CICurOrientation", '');
  132 + }
  133 +
  134 + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null && query.selectedimagetype !== '')) {
  135 + filtercount = filtercount + 1;
  136 + localStorage.setItem("CICurImageType", query.selectedimagetype);
  137 + }
  138 + else {
  139 + localStorage.setItem("CICurImageType", '');
  140 + }
  141 +
  142 + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null && query.selectedspecialty !== '')) {
  143 + filtercount = filtercount + 1;
  144 + localStorage.setItem("CICurSpeciality", query.selectedspecialty);
  145 + }
  146 + else {
  147 + localStorage.setItem("CICurSpeciality", '');
  148 + }
  149 +
  150 +
  151 + var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
  152 + promise.then(
  153 + function (result) {
  154 + $scope.IllustrationData = result;
  155 + //$scope.selectedCIListViewData = $scope.IllustrationData.root.CIData;
  156 +
  157 + $scope.selectedCIListViewData = new jinqJs()
  158 + .from($scope.IllustrationData.root.CIData)
  159 + .orderBy([{ field: '_Title', sort: 'asc' }])
  160 + .select();
  161 +
  162 + $('#grid-view').empty();
  163 +
  164 + angular.forEach($scope.selectedCIListViewData, function (value, key) {
  165 +
  166 + var selectimg = true;
  167 + var count = 0;
  168 +
  169 +
  170 + if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null && query.selectedbodyregion !== "")) {
  171 + var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
  172 + if (posbodyregion > -1) {
  173 + selectimg = true;
  174 + count = count + 1;
  175 +
  176 + }
  177 + else {
  178 + selectimg = false;
  179 + count = count - 1;
  180 + }
  181 +
  182 + }
  183 +
  184 + if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null && query.selectedbodysystem !== "")) {
  185 + var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
  186 + if (posbodysystem > -1) {
  187 + count = count + 1;
  188 + selectimg = true;
  189 + } else {
  190 + selectimg = false;
  191 + count = count - 1;
  192 + }
  193 + }
  194 +
  195 + if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== "")) {
  196 + var posorientation = value._ViewOrientation.indexOf(query.selectedorientation);
  197 + if (posorientation > -1) {
  198 + count = count + 1;
  199 + selectimg = true;
  200 +
  201 + } else {
  202 + selectimg = false;
  203 + count = count - 1;
  204 + }
  205 +
  206 + }
  207 +
  208 + if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null && query.selectedimagetype !== "")) {
  209 + var posimagetype = value._ImageType.indexOf(query.selectedimagetype);
  210 + if (posimagetype > -1) {
  211 + count = count + 1;
  212 + selectimg = true;
  213 +
  214 + } else {
  215 + selectimg = false;
  216 + count = count - 1;
  217 + }
  218 +
  219 + }
  220 +
  221 + if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null && query.selectedspecialty !== "")) {
  222 + var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
  223 + if (posspeciality > -1) {
  224 + count = count + 1;
  225 + selectimg = true;
  226 + } else {
  227 + selectimg = false;
  228 + count = count - 1;
  229 + }
  230 +
  231 + }
  232 +
  233 + if (selectimg === true && count >= filtercount) {
  234 +
  235 +
  236 + $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
  237 +
  238 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
  239 + + '<div class="thumbnail" >'
  240 + + '<img id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
  241 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  242 +
  243 +
  244 + $compile($el)($scope);
  245 +
  246 + $(".sidebar").mCustomScrollbar({
  247 + autoHideScrollbar: true,
  248 + //theme:"rounded"
  249 + });
  250 +
  251 +
  252 + $scope.searchCIListViewData.push(
  253 + {
  254 + "_id": value._id,
  255 + "_ImageId": value._ImageId,
  256 + "_Title": value._Title,
  257 + "_contentImage": value._contentImage,
  258 + "_ThumbnailImage": value._ThumbnailImage,
  259 + "_BodySystem": value._BodySystem,
  260 + "_BodyRegion": value._BodyRegion,
  261 + "_ViewOrientation": value._ViewOrientation,
  262 + "_MedicalSpecialty": value._MedicalSpecialty,
  263 + "_ImageType": value._ImageType,
  264 + "_Summary": value._Summary
  265 +
  266 + });
  267 +
  268 + }
  269 +
  270 +
  271 + });
  272 +
  273 + //Show Error Message in case of gridview if no data is found
  274 + if ($scope.searchCIListViewData.length == 0) {
  275 +
  276 + var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');
  277 + $compile($el)($scope);
  278 + }
  279 + },
  280 + function (error) {
  281 + // handle errors here
  282 + console.log(' $scope.IllustrationData = ' + error.statusText);
  283 + }
  284 + );
  285 +
  286 +
  287 + }
  288 +
99 }]); 289 }]);