Commit 51b7507167f3709294bc1c48c6d9910eda8492cc

Authored by Mitali Srivastava
1 parent b8c081ec

Maintain combo selection of CA

400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js
... ... @@ -13,62 +13,128 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, pages, B
13 13 $scope.SelectedCASummary = [];
14 14 $scope.filterstring = false;
15 15 $scope.query = {
16   - selectedbodyregion: null,
17   - selectedbodysystem: null,
18   - selectedspecialty: null,
  16 + selectedbodyregion: '',
  17 + selectedbodysystem: '',
  18 + selectedspecialty: '',
19 19 };
20 20  
21 21 $scope.$on('$viewContentLoaded', function (event) {
22 22 // code that will be executed ...
23 23 // every time this view is loaded
24 24  
  25 + $scope.LoadCAJsonData();
  26 +
25 27 $scope.CAAllBodyRegion = BodyRegions;
26 28 $scope.CAAllBodySystem = BodySystems;
27 29 $scope.CAAllSpeciality = MedicalSpecialties;
28 30 $scope.scroll();
29 31  
  32 + //set the local storage
  33 + var curBodyRegion = localStorage.getItem("CACurBodyRegion");
  34 + if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null) {
  35 + $scope.query.selectedbodyregion = curBodyRegion;
  36 + }
  37 + else {
  38 + $scope.query.selectedbodyregion = "";
  39 + }
  40 +
  41 + var curBodySystem = localStorage.getItem("CACurBodySystem");
  42 + if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null) {
  43 + $scope.query.selectedbodysystem = curBodySystem;
  44 + }
  45 + else {
  46 + $scope.query.selectedbodysystem = "";
  47 + }
  48 +
  49 + var curSpeciality = localStorage.getItem("CACurSpeciality");
  50 + if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null) {
  51 + $scope.query.selectedspecialty = curSpeciality;
  52 + }
  53 + else {
  54 + $scope.query.selectedspecialty = "";
  55 + }
  56 +
  57 +
  58 + if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedspecialty == "") {
  59 + $scope.loadAllCA();
  60 + }
  61 + else {
  62 + $scope.ApplySearch($scope.query);
  63 + }
  64 +
  65 +
30 66 });
31 67  
32   - var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
33   - promise.then(
34   - function (result) {
35   - $scope.AnimationData = result;
36   - //$scope.selectedCAListViewData = $scope.AnimationData.root.CAData;
  68 + $scope.LoadCAJsonData = function () {
  69 +
  70 + var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
  71 + promise.then(
  72 + function (result) {
  73 + $scope.AnimationData = result;
  74 + //$scope.selectedCAListViewData = $scope.AnimationData.root.CAData;
  75 +
  76 + $scope.selectedCAListViewData = new jinqJs()
  77 + .from($scope.AnimationData.root.CAData)
  78 + .orderBy([{ field: '_Title', sort: 'asc' }])
  79 + .select();
37 80  
38   - $scope.selectedCAListViewData = new jinqJs()
39   - .from($scope.AnimationData.root.CAData)
40   - .orderBy([{ field: '_Title', sort: 'asc' }])
41   - .select();
  81 + //console.log($scope.selectedCAListViewData);
42 82  
43   - //console.log($scope.selectedCAListViewData);
  83 + },
  84 + function (error) {
  85 + // handle errors here
  86 + console.log(' $scope.AnimationData = ' + error.statusText);
  87 + }
  88 + );
44 89  
45   - $('#grid-view').empty();
46 90  
47   - angular.forEach($scope.selectedCAListViewData, function (value, key) {
48   - $scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
  91 + };
49 92  
  93 + $scope.loadAllCA = function () {
50 94  
51   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
52   - + '<div class="thumbnail" >'
53   - + '<img id="' + value._Title + '" class="img-responsive" style="width:100%;height:100%;" ng-src="' + $scope.imagePath + '" alt="" title="" >'
54   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  95 + var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
  96 + promise.then(
  97 + function (result) {
  98 + $scope.AnimationData = result;
  99 + //$scope.selectedCAListViewData = $scope.AnimationData.root.CAData;
  100 +
  101 + $scope.selectedCAListViewData = new jinqJs()
  102 + .from($scope.AnimationData.root.CAData)
  103 + .orderBy([{ field: '_Title', sort: 'asc' }])
  104 + .select();
  105 +
  106 + //console.log($scope.selectedCAListViewData);
  107 +
  108 + $('#grid-view').empty();
55 109  
  110 + angular.forEach($scope.selectedCAListViewData, function (value, key) {
  111 + $scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
56 112  
57   - $compile($el)($scope);
58 113  
59   - $(".sidebar").mCustomScrollbar({
60   - autoHideScrollbar: true,
61   - //theme:"rounded"
  114 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
  115 + + '<div class="thumbnail" >'
  116 + + '<img id="' + value._Title + '" class="img-responsive" style="width:100%;height:100%;" ng-src="' + $scope.imagePath + '" alt="" title="" >'
  117 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  118 +
  119 +
  120 + $compile($el)($scope);
  121 +
  122 + $(".sidebar").mCustomScrollbar({
  123 + autoHideScrollbar: true,
  124 + //theme:"rounded"
  125 + });
  126 +
62 127 });
63 128  
64   - });
  129 + },
  130 + function (error) {
  131 + // handle errors here
  132 + console.log(' $scope.AnimationData = ' + error.statusText);
  133 + }
  134 + );
65 135  
66   - },
67   - function (error) {
68   - // handle errors here
69   - console.log(' $scope.AnimationData = ' + error.statusText);
70   - }
71   - );
  136 +
  137 + }
72 138  
73 139 $scope.IsVisible = function () {
74 140 $scope.scroll();
... ... @@ -113,32 +179,21 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, pages, B
113 179  
114 180 $scope.Reset = function (query) {
115 181  
116   - query.selectedbodyregion = null;
117   - query.selectedbodysystem = null;
118   - query.selectedspecialty = null;
  182 + query.selectedbodyregion = "";
  183 + query.selectedbodysystem = "";
  184 + query.selectedspecialty = "";
  185 +
  186 + //set localstorage values
  187 + localStorage.setItem("CACurBodyRegion", query.selectedbodyregion);
  188 + localStorage.setItem("CACurBodySystem", query.selectedbodysystem);
  189 + localStorage.setItem("CACurSpeciality", query.selectedspecialty);
  190 +
119 191 $scope.filterstring = false;
120 192 while ($scope.searchCAListViewData.length) {
121 193 $scope.searchCAListViewData.pop();
122 194 }
123   - $('#grid-view').empty();
124   -
125   - angular.forEach($scope.selectedCAListViewData, function (value, key) {
126   - $scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
127   -
128   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
129   - + '<div class="thumbnail" >'
130   - + '<img id="' + value._Title + '" class="img-responsive" style="width:100%;height:100%;" ng-src="' + $scope.imagePath + '" alt="" title="" >'
131   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
132   -
133   -
134   - $compile($el)($scope);
135   -
136   - $(".sidebar").mCustomScrollbar({
137   - autoHideScrollbar: true,
138   - //theme:"rounded"
139   - });
140   -
141   - });
  195 +
  196 + $scope.loadAllCA();
142 197  
143 198 }
144 199  
... ... @@ -150,106 +205,132 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, pages, B
150 205 $scope.searchCAListViewData.pop();
151 206 }
152 207  
153   - $('#grid-view').empty();
  208 + //$('#grid-view').empty();
154 209  
155 210 filtercount = 0;
156 211 if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
157 212 filtercount = filtercount + 1;
  213 + localStorage.setItem("CACurBodyRegion", query.selectedbodyregion);
158 214 }
159 215 if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
160 216 filtercount = filtercount + 1;
  217 + localStorage.setItem("CACurBodySystem", query.selectedbodysystem);
161 218 }
162 219 if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
163 220 filtercount = filtercount + 1;
  221 + localStorage.setItem("CACurSpeciality", query.selectedspecialty);
164 222 }
165 223  
166   - angular.forEach($scope.selectedCAListViewData, function (value, key) {
  224 + var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
  225 + promise.then(
  226 + function (result) {
  227 + $scope.AnimationData = result;
  228 + //$scope.selectedCAListViewData = $scope.AnimationData.root.CAData;
167 229  
168   - var selectimg = true;
169   - var count = 0;
  230 + $scope.selectedCAListViewData = new jinqJs()
  231 + .from($scope.AnimationData.root.CAData)
  232 + .orderBy([{ field: '_Title', sort: 'asc' }])
  233 + .select();
170 234  
  235 + //console.log($scope.selectedCAListViewData);
171 236  
172   - if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
173   - var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
174   - if (posbodyregion > -1) {
175   - selectimg = true;
176   - count = count + 1;
  237 + $('#grid-view').empty();
177 238  
178   - }
179   - else {
180   - selectimg = false;
181   - count = count - 1;
182   - }
  239 + angular.forEach($scope.selectedCAListViewData, function (value, key) {
183 240  
184   - }
  241 + var selectimg = true;
  242 + var count = 0;
185 243  
186   - if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
187   - var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
188   - if (posbodysystem > -1) {
189   - count = count + 1;
190   - selectimg = true;
191   - } else {
192   - selectimg = false;
193   - count = count - 1;
194   - }
195   - }
196 244  
197   - if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
198   - var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
199   - if (posspeciality > -1) {
200   - count = count + 1;
201   - selectimg = true;
202   - } else {
203   - selectimg = false;
204   - count = count - 1;
205   - }
  245 + if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
  246 + var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
  247 + if (posbodyregion > -1) {
  248 + selectimg = true;
  249 + count = count + 1;
206 250  
207   - }
  251 + }
  252 + else {
  253 + selectimg = false;
  254 + count = count - 1;
  255 + }
208 256  
209   - if (selectimg === true && count >= filtercount) {
  257 + }
210 258  
  259 + if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
  260 + var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
  261 + if (posbodysystem > -1) {
  262 + count = count + 1;
  263 + selectimg = true;
  264 + } else {
  265 + selectimg = false;
  266 + count = count - 1;
  267 + }
  268 + }
211 269  
212   - $scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
  270 + if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
  271 + var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
  272 + if (posspeciality > -1) {
  273 + count = count + 1;
  274 + selectimg = true;
  275 + } else {
  276 + selectimg = false;
  277 + count = count - 1;
  278 + }
213 279  
214   - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
215   - + '<div class="thumbnail" >'
216   - + '<img id="' + value._Title + '" class="img-responsive" style="width:100%;height:100%;" ng-src="' + $scope.imagePath + '" alt="" title="" >'
217   - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
  280 + }
218 281  
  282 + if (selectimg === true && count >= filtercount) {
219 283  
220   - $compile($el)($scope);
221 284  
222   - $(".sidebar").mCustomScrollbar({
223   - autoHideScrollbar: true,
224   - //theme:"rounded"
225   - });
  285 + $scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
226 286  
  287 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="openView($event)">'
  288 + + '<div class="thumbnail" >'
  289 + + '<img id="' + value._Title + '" class="img-responsive" style="width:100%;height:100%;" ng-src="' + $scope.imagePath + '" alt="" title="" >'
  290 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
227 291  
228   - $scope.searchCAListViewData.push(
229   - {
230   - "_id": value._id,
231   - "_ImageId": value._ImageId,
232   - "_Title": value._Title,
233   - "_Video": value._Video,
234   - "_ThumbnailImage": value._ThumbnailImage,
235   - "_BodySystem": value._BodySystem,
236   - "_BodyRegion": value._BodyRegion,
237   - "_MedicalSpecialty": value._MedicalSpecialty,
238   - "_Summary": value._Summary,
239   - "_LowerSummary": value._LowerSummary
240   - });
241 292  
242   - }
  293 + $compile($el)($scope);
243 294  
  295 + $(".sidebar").mCustomScrollbar({
  296 + autoHideScrollbar: true,
  297 + //theme:"rounded"
  298 + });
244 299  
245   - });
246 300  
247   - //Show Error Message in case of gridview if no data is found
248   - if ($scope.searchCAListViewData.length == 0) {
  301 + $scope.searchCAListViewData.push(
  302 + {
  303 + "_id": value._id,
  304 + "_ImageId": value._ImageId,
  305 + "_Title": value._Title,
  306 + "_Video": value._Video,
  307 + "_ThumbnailImage": value._ThumbnailImage,
  308 + "_BodySystem": value._BodySystem,
  309 + "_BodyRegion": value._BodyRegion,
  310 + "_MedicalSpecialty": value._MedicalSpecialty,
  311 + "_Summary": value._Summary,
  312 + "_LowerSummary": value._LowerSummary
  313 + });
  314 +
  315 + }
  316 +
  317 +
  318 + });
  319 +
  320 + //Show Error Message in case of gridview if no data is found
  321 + if ($scope.searchCAListViewData.length == 0) {
  322 +
  323 + var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white;">No animation found for the selected search criteria!</strong></div>').appendTo('#grid-view');
  324 + $compile($el)($scope);
  325 + }
  326 +
  327 + },
  328 + function (error) {
  329 + // handle errors here
  330 + console.log(' $scope.AnimationData = ' + error.statusText);
  331 + }
  332 + );
249 333  
250   - var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white;">No animation found for the selected search criteria!</strong></div>').appendTo('#grid-view');
251   - $compile($el)($scope);
252   - }
253 334 }
254 335  
255 336  
... ...