changeset 482:b05eb8708aee

fix history in Orthanc Explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jul 2013 11:30:24 +0200
parents 4f5b4b0fa626
children 8c3573d28868
files NEWS OrthancExplorer/explorer.js OrthancExplorer/libs/jqm.page.params.js
diffstat 3 files changed, 83 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Jul 16 10:10:55 2013 +0200
+++ b/NEWS	Tue Jul 16 11:30:24 2013 +0200
@@ -2,24 +2,33 @@
 ===============================
 
 
+Major changes
+-------------
+
+* Introduction of the C++ client
+* Access to signed images (instances/.../image-int16)
+  (Closes: Debian #716958)
+
+
+Minor changes
+-------------
+
+* Statistics about patients, studies, series and instances
+* Link from anonymized to original resource in Orthanc Explorer
+* Fixes for Red Hat and Debian packaging
+* Fixes for history in Orthanc Explorer
+* Fixes for boost::thread, as reported by Cyril Paulus
+
+
 Metadata
 --------
 
-* Access to the metadata through the REST API (/metadata)
+* Access to the metadata through the REST API (.../metadata)
 * Support of user-defined metadata
 * "LastUpdate" metadata for patients, studies and series
 * "/tools/now" to be used in combination with "LastUpdate"
 * Improved support of series with temporal positions
 
-Other
------
-
-* Access to signed images (instances/.../image-int16)
-  (Closes: Debian #716958)
-* Statistics about patients, studies, series and instances
-* Link from anonymized to original resource in Orthanc Explorer
-* Fixes for Red Hat and Debian packaging
-* Fixes for boost::thread, as reported by Cyril Paulus
 
 
 Version 0.5.2 (2013/05/07)
--- a/OrthancExplorer/explorer.js	Tue Jul 16 10:10:55 2013 +0200
+++ b/OrthancExplorer/explorer.js	Tue Jul 16 11:30:24 2013 +0200
@@ -12,6 +12,11 @@
 //$.mobile.page.prototype.options.addBackBtn = true;
 //$.mobile.defaultPageTransition = 'slide';
 
+
+var currentPage = '';
+var currentUuid = '';
+
+
 // http://stackoverflow.com/a/4673436
 String.prototype.format = function() {
   var args = arguments;
@@ -363,7 +368,7 @@
     $(buttonSelector).closest('li').show();
     $(buttonSelector).click(function(e) {
       window.location.assign('explorer.html#' + resourceType + '?uuid=' + resource.AnonymizedFrom);
-      window.location.reload();
+      //window.location.reload();
     });
   }
   else
@@ -373,7 +378,8 @@
 }
 
 
-$('#patient').live('pagebeforeshow', function() {
+function RefreshPatient()
+{
   if ($.mobile.pageData) {
     GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) {
       GetMultipleResources('studies', patient.Studies, function(studies) {
@@ -414,13 +420,17 @@
             $('#protection').val(v).slider('refresh');
           }
         });
+
+        currentPage = 'patient';
+        currentUuid = $.mobile.pageData.uuid;
       });
     });
   }
-});
+}
 
 
-$('#study').live('pagebeforeshow', function() {
+function RefreshStudy()
+{
   if ($.mobile.pageData) {
     GetSingleResource('studies', $.mobile.pageData.uuid, function(study) {
       GetSingleResource('patients', study.ParentPatient, function(patient) {
@@ -449,14 +459,18 @@
             target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID));
           }
           target.listview('refresh');
+
+          currentPage = 'study';
+          currentUuid = $.mobile.pageData.uuid;
         });
       });  
     });
   }
-});
+}
   
 
-$('#series').live('pagebeforeshow', function() {
+function RefreshSeries() 
+{
   if ($.mobile.pageData) {
     GetSingleResource('series', $.mobile.pageData.uuid, function(series) {
       GetSingleResource('studies', series.ParentStudy, function(study) {
@@ -485,12 +499,15 @@
               target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID));
             }
             target.listview('refresh');
+
+            currentPage = 'series';
+            currentUuid = $.mobile.pageData.uuid;
           });
         });
       });
     });
   }
-});
+}
 
 
 
@@ -545,7 +562,8 @@
 }
 
 
-$('#instance').live('pagebeforeshow', function() {
+function RefreshInstance()
+{
   if ($.mobile.pageData) {
     GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) {
       GetSingleResource('series', instance.ParentSeries, function(series) {
@@ -577,15 +595,49 @@
               }
             });
 
+            currentPage = 'instance';
+            currentUuid = $.mobile.pageData.uuid;
           });
         });
       });
     });
   }
+}
+
+$(document).live('pagebeforehide', function() {
+  currentPage = '';
+  currentUuid = '';
 });
 
 
 
+$('#patient').live('pagebeforeshow', RefreshPatient);
+$('#study').live('pagebeforeshow', RefreshStudy);
+$('#series').live('pagebeforeshow', RefreshSeries);
+$('#instance').live('pagebeforeshow', RefreshInstance);
+
+$(function() {
+  $(window).hashchange(function(e, data) {
+    // This fixes the navigation with the back button and with the anonymization
+    if ('uuid' in $.mobile.pageData &&
+        currentPage == $.mobile.pageData.active &&
+        currentUuid != $.mobile.pageData.uuid) {
+      if (currentPage == 'patient')
+        RefreshPatient();
+      else if (currentPage == 'study')
+        RefreshStudy();
+      else if (currentPage == 'series')
+        RefreshSeries();
+      else if (currentPage == 'instance')
+        RefreshInstance();
+    }
+  });
+});
+
+
+
+
+
 function DeleteResource(path)
 {
   $.ajax({
@@ -863,7 +915,7 @@
               //$.mobile.changePage('explorer.html#patient?uuid=' + s.PatientID);
 
               window.location.assign('explorer.html#patient?uuid=' + s.PatientID);
-              window.location.reload();
+              //window.location.reload();
             }
           });
         },
--- a/OrthancExplorer/libs/jqm.page.params.js	Tue Jul 16 10:10:55 2013 +0200
+++ b/OrthancExplorer/libs/jqm.page.params.js	Tue Jul 16 11:30:24 2013 +0200
@@ -105,7 +105,9 @@
 
 // http://stackoverflow.com/a/8295488
 $(document).bind("pagebeforechange", function( event, data ) {
-    $.mobile.pageData = (data && data.options && data.options.pageData)
+  $.mobile.pageData = (data && data.options && data.options.pageData)
     ? data.options.pageData
     : {};
+
+  $.mobile.pageData.active = data.toPage[0].id;
 });