From f79aa16c4eb6dd2ac3cf57f63e176a200ab6741f Mon Sep 17 00:00:00 2001 From: fredkingham Date: Mon, 15 Jun 2020 12:34:39 +0100 Subject: [PATCH 01/23] Bumps the version number from 0.18.3 to 0.18.4 --- doc/mkdocs.yml | 2 +- opal/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mkdocs.yml b/doc/mkdocs.yml index 257b2e8f5..02e5c2d67 100644 --- a/doc/mkdocs.yml +++ b/doc/mkdocs.yml @@ -122,7 +122,7 @@ dev_addr: 0.0.0.0:8965 include_next_prev: false extra: - version: v0.18.3 + version: v0.18.4 markdown_extensions: - fenced_code diff --git a/opal/_version.py b/opal/_version.py index ea9e97e63..d82f29c3f 100644 --- a/opal/_version.py +++ b/opal/_version.py @@ -1,4 +1,4 @@ """ Declare our current version string """ -__version__ = '0.18.3' +__version__ = '0.18.4' From 68b1b89b0c00ee4bfb650a4c55a7f3e051dbcfc9 Mon Sep 17 00:00:00 2001 From: fredkingham Date: Mon, 22 Jun 2020 11:50:21 +0100 Subject: [PATCH 02/23] Removes opal js features that have been deprecated --- changelog.md | 10 +++ opal/static/js/opal/filters.js | 38 +---------- opal/static/js/opal/services/record_editor.js | 10 +-- opal/static/js/test/filters.test.js | 65 ------------------- opal/static/js/test/record_editor_test.js | 30 ++------- 5 files changed, 19 insertions(+), 134 deletions(-) diff --git a/changelog.md b/changelog.md index 460ccd497..e76df9d6a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,13 @@ +### 0.18.4 (Minor Release) + +#### Remove shortDate and shortDateTime +The angular filters shortDate and shortDateTime have been deprecated for some time. + +#### Stop an index being passed to recordEditor.editItem +recordEditor.editItem used to take either a number or an item (subrecord) as its second argument. +Now it will only take an item. + + ### 0.18.3 (Minor Release) #### Complex objects are now serialized in the extract as json diff --git a/opal/static/js/opal/filters.js b/opal/static/js/opal/filters.js index e61d410b7..7cc1ed453 100644 --- a/opal/static/js/opal/filters.js +++ b/opal/static/js/opal/filters.js @@ -25,44 +25,8 @@ filters.filter('fromNow', function(toMomentFilter){ }; }); -filters.filter('shortDate', function(toMomentFilter, $log){ - return function(input){ - $log.warn('shortDate will be removed in Opal 0.14.0') - if(!input){ - return - } - - d = toMomentFilter(input); - - if (d.year() <= 2000) { - // if the date was before 1/1/2001, - // show the full year - return d.format('DD/MM/YYYY'); - } - else if (d.year() == moment().year()) { - // if the date was this year, - // don't show the year - return d.format('DD/MM'); - } - // show the year as two digits - return d.format('DD/MM/YY'); - } -}); - -filters.filter('shortDateTime', function(shortDateFilter, hhmmFilter, $log){ - return function(input){ - $log.warn('shortDateTime will be removed in Opal 0.14.0') - var datePart = shortDateFilter(input); - var timePart = hhmmFilter(input); - - if(datePart && timePart){ - return datePart + " " + timePart; - } - }; -}); - -filters.filter('shortTime', function(shortDateFilter, hhmmFilter){ +filters.filter('shortTime', function(hhmmFilter){ return function(input){ var toChange; if(_.isDate(input)){ diff --git a/opal/static/js/opal/services/record_editor.js b/opal/static/js/opal/services/record_editor.js index 251f01f55..c5dad3840 100644 --- a/opal/static/js/opal/services/record_editor.js +++ b/opal/static/js/opal/services/record_editor.js @@ -57,15 +57,7 @@ angular.module('opal.services').factory('RecordEditor', function( return deferred.promise; }; - self.editItem = function(name, iix, url){ - var item; - if(_.isNumber(iix)){ - $log.warn("The ability to pass in an index to recordEditor.editItem will be removed in Opal v0.15.0, please pass in an item"); - item = self.getItem(name, iix); - } - else{ - item = iix; - } + self.editItem = function(name, item, url){ return self.openEditItemModal(item, name, url); }; diff --git a/opal/static/js/test/filters.test.js b/opal/static/js/test/filters.test.js index db7508622..d1b43353b 100644 --- a/opal/static/js/test/filters.test.js +++ b/opal/static/js/test/filters.test.js @@ -84,45 +84,6 @@ describe('filters', function() { }); - describe('shortDate', function() { - var log; - - beforeEach(function(){ - inject(function($injector){ - log = $injector.get('$log'); - }); - - spyOn(log, 'warn'); - }); - - it('should log a warning message', function() { - inject(function(shortDateFilter) { - shortDateFilter(); - expect(log.warn).toHaveBeenCalledWith('shortDate will be removed in Opal 0.14.0'); - }); - }); - - it('should return undefined for no input', - inject(function(shortDateFilter) { - expect(shortDateFilter(null)).toBe(undefined); - })); - - it('should output a date before 1/1/2001 as DD/MM/YYYY', - inject(function(shortDateFilter) { - expect(shortDateFilter(new Date(2000, 1, 1))).toBe('01/02/2000'); - })); - - it('should output a date before this year as DD/MM/YY', - inject(function(shortDateFilter) { - expect(shortDateFilter(new Date(2001, 1, 1))).toBe('01/02/01'); - })); - - it('should output a date this year as DD/MM', - inject(function(shortDateFilter) { - expect(shortDateFilter(new Date(new Date().getFullYear(), 1, 1))).toBe('01/02'); - })); - }); - describe('shortTime', function(){ var shortTime; @@ -242,32 +203,6 @@ describe('filters', function() { }); - describe('shortDateTime', function(){ - var shortDateTime, log; - - beforeEach(function(){ - inject(function($injector){ - shortDateTime = $injector.get('shortDateTimeFilter'); - log = $injector.get('$log'); - }); - spyOn(log, 'warn'); - }); - - it('should log a warning message', function() { - shortDateTime() - expect(log.warn).toHaveBeenCalledWith('shortDateTime will be removed in Opal 0.14.0') - }); - - - it('should return undefined if no input', function(){ - expect(shortDateTime(null)).toBe(undefined); - }); - it('correct represent a string in date time format', function(){ - var expected = shortDateTime(new Date(2000, 1, 1, 20, 45)); - expect(expected).toBe('01/02/2000 20:45'); - }); - }); - describe('daysTo', function() { var daysTo diff --git a/opal/static/js/test/record_editor_test.js b/opal/static/js/test/record_editor_test.js index b7a92e1db..a64fcdd82 100644 --- a/opal/static/js/test/record_editor_test.js +++ b/opal/static/js/test/record_editor_test.js @@ -114,29 +114,13 @@ describe('RecordEditor', function(){ }); describe("edit item", function(){ - it('should open the EditItemCtrl with an index but warn', function(){ - var deferred, callArgs; - deferred = $q.defer(); - deferred.resolve(); - var modalPromise = deferred.promise; - spyOn($modal, 'open').and.returnValue({result: modalPromise} ); - episode.recordEditor.editItem('diagnosis', 1); - $scope.$digest(); - callArgs = $modal.open.calls.mostRecent().args; - var expected = "The ability to pass in an index to recordEditor.editItem will be removed in Opal v0.15.0, please pass in an item"; - expect($log.warn).toHaveBeenCalledWith(expected); - expect(callArgs.length).toBe(1); - var resolves = callArgs[0].resolve; - expect(resolves.item()).toEqual(episode.recordEditor.getItem('diagnosis', 1)); - }); - it('should accept a url that is passed through to the modal open', function(){ var deferred, callArgs; deferred = $q.defer(); deferred.resolve(); var modalPromise = deferred.promise; spyOn($modal, 'open').and.returnValue({result: modalPromise} ); - episode.recordEditor.editItem('diagnosis', 1, '/custom_template/'); + episode.recordEditor.editItem('diagnosis', episode.diagnosis[0], '/custom_template/'); $scope.$digest(); callArgs = $modal.open.calls.mostRecent().args; expect(callArgs[0].templateUrl).toBe("/custom_template/") @@ -176,7 +160,7 @@ describe('RecordEditor', function(){ var modalPromise = deferred.promise; spyOn($modal, 'open').and.returnValue({result: modalPromise} ); - episode.recordEditor.editItem('demographics', 0); + episode.recordEditor.editItem('demographics', episode.demographics[0]); $scope.$digest(); callArgs = $modal.open.calls.mostRecent().args; }); @@ -189,7 +173,7 @@ describe('RecordEditor', function(){ spyOn($modal, 'open').and.returnValue({result: modalPromise} ); $routeParams.slug = 'tropical-all' - episode.recordEditor.editItem('diagnosis', 0); + episode.recordEditor.editItem('diagnosis', episode.diagnosis[0]); $scope.$digest(); callArgs = $modal.open.calls.mostRecent().args; expect(callArgs.length).toBe(1); @@ -209,7 +193,7 @@ describe('RecordEditor', function(){ var modalPromise = deferred.promise; spyOn($modal, 'open').and.returnValue({result: modalPromise} ); - episode.recordEditor.editItem('demographics', 0); + episode.recordEditor.editItem('demographics', episode.demographics[0]); $scope.$digest(); expect($modal.open.calls.count()).toBe(0); }); @@ -225,7 +209,7 @@ describe('RecordEditor', function(){ deferred = $q.defer(); spyOn($modal, 'open').and.returnValue({result: deferred.promise}); - episode.recordEditor.editItem('demographics', 0); + episode.recordEditor.editItem('demographics', episode.demographics[0]); deferred.resolve('save'); $rootScope.$apply(); @@ -239,7 +223,7 @@ describe('RecordEditor', function(){ deferred = $q.defer(); spyOn($modal, 'open').and.returnValue({result: deferred.promise}); - episode.recordEditor.editItem('demographics', 0).then(function(modalResult){ + episode.recordEditor.editItem('demographics', episode.demographics[0]).then(function(modalResult){ called = modalResult == "save"; }); @@ -258,7 +242,7 @@ describe('RecordEditor', function(){ nestedDeferred = $q.defer() spyOn($modal, 'open').and.returnValue({result: deferred.promise}); - episode.recordEditor.editItem('demographics', 0).then(function(modalResult){ + episode.recordEditor.editItem('demographics', episode.demographics[0]).then(function(modalResult){ called = modalResult == "delete"; }); From 7433c6d9bc230fe986c62fed436d8a32e4c85668 Mon Sep 17 00:00:00 2001 From: fredkingham Date: Thu, 25 Jun 2020 13:17:29 +0100 Subject: [PATCH 03/23] Remove the user detail account page --- changelog.md | 2 ++ opal/core/application.py | 1 - opal/static/js/opal/controllers/account.js | 1 - opal/static/js/opal/routes.js | 6 +--- opal/templates/accounts/account_detail.html | 39 --------------------- opal/tests/test_core_application.py | 1 - 6 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 opal/static/js/opal/controllers/account.js delete mode 100644 opal/templates/accounts/account_detail.html diff --git a/changelog.md b/changelog.md index e76df9d6a..0d613fb77 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,8 @@ The angular filters shortDate and shortDateTime have been deprecated for some ti recordEditor.editItem used to take either a number or an item (subrecord) as its second argument. Now it will only take an item. +#### Removes the account page +Removes the user account detail page as this is not tested/used and can be easily created within an app. ### 0.18.3 (Minor Release) diff --git a/opal/core/application.py b/opal/core/application.py index e60a24c5b..bb600086f 100644 --- a/opal/core/application.py +++ b/opal/core/application.py @@ -76,7 +76,6 @@ class OpalApplication(object): "js/opal/controllers/edit_item.js", "js/opal/controllers/edit_teams.js", "js/opal/controllers/delete_item_confirmation.js", - "js/opal/controllers/account.js", "js/opal/controllers/keyboard_shortcuts.js", "js/opal/controllers/patient_access_log.js", "js/opal/controllers/lookup_list_reference.js" diff --git a/opal/static/js/opal/controllers/account.js b/opal/static/js/opal/controllers/account.js deleted file mode 100644 index 53667f35a..000000000 --- a/opal/static/js/opal/controllers/account.js +++ /dev/null @@ -1 +0,0 @@ -controllers.controller('AccountCtrl', function($scope){}); diff --git a/opal/static/js/opal/routes.js b/opal/static/js/opal/routes.js index b9c64b1da..0f7caa74c 100644 --- a/opal/static/js/opal/routes.js +++ b/opal/static/js/opal/routes.js @@ -37,12 +37,8 @@ profile: function(UserProfile){ return UserProfile.load(); }, metadata: function(Metadata){ return Metadata.load(); } }, - templateUrl: function(params){ return '/templates/patient_detail.html' } + templateUrl: function(params){ return '/templates/patient_detail.html' } }) - .when('/account', { - controller: 'AccountCtrl', - templateUrl: '/accounts/account_detail.html' - }) .otherwise({redirectTo: '/'}); }] diff --git a/opal/templates/accounts/account_detail.html b/opal/templates/accounts/account_detail.html deleted file mode 100644 index cfbde87b8..000000000 --- a/opal/templates/accounts/account_detail.html +++ /dev/null @@ -1,39 +0,0 @@ -
- -
- -
-

Your Account

-
-
-
-
-
    -
  • - First name: - {{ request.user.first_name }} -
  • -
  • - Last name: - {{ request.user.last_name }} -
  • -
  • - Username: - {{ request.user.username }} -
  • -
  • - Email: - {{ request.user.email }} -
  • - -
-
- - - Reset Password - -
-
-
-
-
diff --git a/opal/tests/test_core_application.py b/opal/tests/test_core_application.py index 0cdc57cc9..4936f9688 100644 --- a/opal/tests/test_core_application.py +++ b/opal/tests/test_core_application.py @@ -29,7 +29,6 @@ def test_get_core_javascripts(self): "js/opal/controllers/edit_item.js", "js/opal/controllers/edit_teams.js", "js/opal/controllers/delete_item_confirmation.js", - "js/opal/controllers/account.js", "js/opal/controllers/keyboard_shortcuts.js", "js/opal/controllers/patient_access_log.js", "js/opal/controllers/lookup_list_reference.js" From 6c6c21180e1f588979f28854853fb6cef51b630a Mon Sep 17 00:00:00 2001 From: fredkingham Date: Thu, 25 Jun 2020 15:43:33 +0100 Subject: [PATCH 04/23] Remove unused imports and variables --- .../static/js/pathway/services/pathway.js | 2 +- .../controllers/delete_item_confirmation.js | 3 +- opal/static/js/opal/controllers/edit_item.js | 2 +- opal/static/js/opal/controllers/edit_teams.js | 2 +- .../js/opal/controllers/patient_detail.js | 3 +- .../js/opal/controllers/patient_list.js | 4 +- opal/static/js/opal/services/episode.js | 4 +- .../js/opal/services/episode_resource.js | 2 +- opal/static/js/opal/services/metadata.js | 2 +- .../static/js/opal/services/patient_loader.js | 2 +- .../js/opal/services/patientlist_loader.js | 2 +- opal/static/js/opal/services/record_editor.js | 4 +- opal/static/js/opal/services/record_loader.js | 2 +- opal/static/js/opal/services/referencedata.js | 2 +- opal/static/js/opal/services/user_profile.js | 2 +- .../js/test/edit_item.controller.test.js | 4 +- opal/static/js/test/episode.service.test.js | 4 +- .../test/episode_visibility.service.test.js | 2 +- opal/static/js/test/item.service.test.js | 2 +- opal/static/js/test/patient.service.test.js | 2 +- .../js/test/patient_list.controller.test.js | 6 +-- opal/static/js/test/record_editor_test.js | 40 ++----------------- 22 files changed, 30 insertions(+), 68 deletions(-) diff --git a/opal/core/pathway/static/js/pathway/services/pathway.js b/opal/core/pathway/static/js/pathway/services/pathway.js index b8268dbbe..c4be74201 100644 --- a/opal/core/pathway/static/js/pathway/services/pathway.js +++ b/opal/core/pathway/static/js/pathway/services/pathway.js @@ -1,5 +1,5 @@ angular.module('opal.services').service('Pathway', function( - $http, FieldTranslator, $q, $controller, $window, $rootScope + $http, FieldTranslator, $q, $window, $rootScope ){ "use strict"; var Pathway = function(pathwayDefinition, episode){ diff --git a/opal/static/js/opal/controllers/delete_item_confirmation.js b/opal/static/js/opal/controllers/delete_item_confirmation.js index b95c31f00..7f8b1c076 100644 --- a/opal/static/js/opal/controllers/delete_item_confirmation.js +++ b/opal/static/js/opal/controllers/delete_item_confirmation.js @@ -1,7 +1,6 @@ angular.module('opal.controllers').controller( 'DeleteItemConfirmationCtrl', - function($scope, $timeout, - $modalInstance, item) { + function($scope, $modalInstance, item) { // TODO: Reimplement this! // // $timeout(function() { diff --git a/opal/static/js/opal/controllers/edit_item.js b/opal/static/js/opal/controllers/edit_item.js index f8250543a..63b722d47 100644 --- a/opal/static/js/opal/controllers/edit_item.js +++ b/opal/static/js/opal/controllers/edit_item.js @@ -1,5 +1,5 @@ angular.module('opal.controllers').controller( - 'EditItemCtrl', function($scope, $timeout, + 'EditItemCtrl', function($scope, $modalInstance, $modal, $q, ngProgressLite, $analytics, referencedata, metadata, diff --git a/opal/static/js/opal/controllers/edit_teams.js b/opal/static/js/opal/controllers/edit_teams.js index cb519fbd8..ee6d20d73 100644 --- a/opal/static/js/opal/controllers/edit_teams.js +++ b/opal/static/js/opal/controllers/edit_teams.js @@ -1,6 +1,6 @@ angular.module('opal.controllers').controller( 'EditTeamsCtrl', function( - $scope, $modalInstance, $modal, $q, ngProgressLite, episode, UserProfile) { + $scope, $modalInstance, ngProgressLite, episode, UserProfile) { UserProfile.load().then(function(profile){ $scope.editingName = episode.getFullName(); diff --git a/opal/static/js/opal/controllers/patient_detail.js b/opal/static/js/opal/controllers/patient_detail.js index f636f235b..148aa0a06 100644 --- a/opal/static/js/opal/controllers/patient_detail.js +++ b/opal/static/js/opal/controllers/patient_detail.js @@ -1,8 +1,7 @@ angular.module('opal.controllers').controller( 'PatientDetailCtrl', function( - $rootScope, $scope, $modal, $location, $routeParams, - Item, patientLoader, patient, profile, metadata + $scope, $routeParams, patientLoader, patient, profile, metadata ){ $scope.profile = profile; $scope.patient = patient; diff --git a/opal/static/js/opal/controllers/patient_list.js b/opal/static/js/opal/controllers/patient_list.js index fed80cbc5..4e962c254 100644 --- a/opal/static/js/opal/controllers/patient_list.js +++ b/opal/static/js/opal/controllers/patient_list.js @@ -1,13 +1,11 @@ angular.module('opal.controllers').controller( - 'PatientListCtrl', function($scope, $q, $http, $cookies, + 'PatientListCtrl', function($scope, $cookies, $location, $routeParams, $modal, $rootScope, $window, $injector, - growl, Item, Episode, episodedata, metadata, profile, episodeLoader, episodeVisibility){ $scope.ready = false; - var version = window.version; if(episodedata.status == 'error'){ if($cookies.get('opal.previousPatientList')){ $cookies.remove('opal.previousPatientList'); diff --git a/opal/static/js/opal/services/episode.js b/opal/static/js/opal/services/episode.js index 44bb9734d..acbbf6560 100644 --- a/opal/static/js/opal/services/episode.js +++ b/opal/static/js/opal/services/episode.js @@ -3,8 +3,8 @@ // angular.module('opal.services') .factory('Episode', function( - $http, $q, $rootScope, $routeParams, $window, - Item, RecordEditor, FieldTranslator) { + $http, $q, $rootScope, $window, + Item, RecordEditor) { "use strict"; // TODO: Set this with a more idiomatic Angular way, and set it once. diff --git a/opal/static/js/opal/services/episode_resource.js b/opal/static/js/opal/services/episode_resource.js index 5df512cdd..5c61709d8 100644 --- a/opal/static/js/opal/services/episode_resource.js +++ b/opal/static/js/opal/services/episode_resource.js @@ -1,6 +1,6 @@ angular.module('opal.services') - .factory('EpisodeResource', function($resource, $q) { + .factory('EpisodeResource', function($resource) { resource = $resource('/api/v0.1/episode/:id/', {id: '@id'}); return resource }); diff --git a/opal/static/js/opal/services/metadata.js b/opal/static/js/opal/services/metadata.js index 3cd7c041f..a641d6976 100644 --- a/opal/static/js/opal/services/metadata.js +++ b/opal/static/js/opal/services/metadata.js @@ -1,4 +1,4 @@ -angular.module('opal.services').factory('Metadata', function($q, $http, $window, $log) { +angular.module('opal.services').factory('Metadata', function($q, $http, $window) { "use strict"; var url = '/api/v0.1/metadata/'; diff --git a/opal/static/js/opal/services/patient_loader.js b/opal/static/js/opal/services/patient_loader.js index 56d4f07e4..a269bf0ab 100644 --- a/opal/static/js/opal/services/patient_loader.js +++ b/opal/static/js/opal/services/patient_loader.js @@ -1,6 +1,6 @@ angular.module('opal.services').factory('patientLoader', function( $q, $window, $http, $route, - recordLoader, FieldTranslator, Patient + recordLoader, Patient ){ return function(patientId) { "use strict"; diff --git a/opal/static/js/opal/services/patientlist_loader.js b/opal/static/js/opal/services/patientlist_loader.js index ab7ec210b..f8c02b223 100644 --- a/opal/static/js/opal/services/patientlist_loader.js +++ b/opal/static/js/opal/services/patientlist_loader.js @@ -1,5 +1,5 @@ angular.module('opal.services') - .factory('patientListLoader', function($q, $window, + .factory('patientListLoader', function($q, $http, $route, Episode, diff --git a/opal/static/js/opal/services/record_editor.js b/opal/static/js/opal/services/record_editor.js index c5dad3840..2f15dcea1 100644 --- a/opal/static/js/opal/services/record_editor.js +++ b/opal/static/js/opal/services/record_editor.js @@ -1,6 +1,6 @@ angular.module('opal.services').factory('RecordEditor', function( - $http, $q, Item, $modal, $rootScope, $routeParams, $log, - UserProfile){ + $q, $modal, $rootScope, $routeParams, UserProfile +){ "use strict"; var RecordEditor = function(episode){ var self = this; diff --git a/opal/static/js/opal/services/record_loader.js b/opal/static/js/opal/services/record_loader.js index 1d4193812..ad0506644 100644 --- a/opal/static/js/opal/services/record_loader.js +++ b/opal/static/js/opal/services/record_loader.js @@ -1,5 +1,5 @@ angular.module('opal.services') - .factory('recordLoader', function($q, $http, $rootScope, $window, $log){ + .factory('recordLoader', function($q, $http, $rootScope, $window){ "use strict"; var load = function(){ diff --git a/opal/static/js/opal/services/referencedata.js b/opal/static/js/opal/services/referencedata.js index eb84d9699..a24fcb40b 100644 --- a/opal/static/js/opal/services/referencedata.js +++ b/opal/static/js/opal/services/referencedata.js @@ -1,4 +1,4 @@ -angular.module('opal.services').factory('Referencedata', function($q, $http, $window, $log) { +angular.module('opal.services').factory('Referencedata', function($q, $http, $window) { "use strict"; diff --git a/opal/static/js/opal/services/user_profile.js b/opal/static/js/opal/services/user_profile.js index af68ca2a7..28f7c9944 100644 --- a/opal/static/js/opal/services/user_profile.js +++ b/opal/static/js/opal/services/user_profile.js @@ -1,5 +1,5 @@ angular.module('opal.services') - .service('UserProfile', function($q, $http, $window, $routeParams, $log) { + .service('UserProfile', function($q, $http, $window, $routeParams) { var UserProfile = function(profiledata){ var profile = this; diff --git a/opal/static/js/test/edit_item.controller.test.js b/opal/static/js/test/edit_item.controller.test.js index 3895dfe46..06322b9e2 100644 --- a/opal/static/js/test/edit_item.controller.test.js +++ b/opal/static/js/test/edit_item.controller.test.js @@ -2,8 +2,8 @@ describe('EditItemCtrl', function (){ "use strict"; var $scope, $timeout, $modal, $httpBackend; - var item, Item, existingEpisode, opalTestHelper; - var dialog, Episode, episode, ngProgressLite, $q, $rootScope; + var item, Item, opalTestHelper; + var Episode, episode, ngProgressLite, $q, $rootScope; var $controller, controller, fakeModalInstance; var $analytics, metadataCopy, profile, referencedata; diff --git a/opal/static/js/test/episode.service.test.js b/opal/static/js/test/episode.service.test.js index 6ab9c2e45..0858d3d42 100644 --- a/opal/static/js/test/episode.service.test.js +++ b/opal/static/js/test/episode.service.test.js @@ -1,8 +1,8 @@ describe('Episode', function() { "use strict"; - var Episode, EpisodeResource, Item, $scope, $rootScope, columns, $window; - var episode, episodeData, resource, tag_hierarchy, fields; + var Episode, Item, $scope, $rootScope, $window; + var episode, episodeData; var $routeParams, opalTestHelper; beforeEach(function() { diff --git a/opal/static/js/test/episode_visibility.service.test.js b/opal/static/js/test/episode_visibility.service.test.js index 4c7baa4ce..d54f354a3 100644 --- a/opal/static/js/test/episode_visibility.service.test.js +++ b/opal/static/js/test/episode_visibility.service.test.js @@ -1,7 +1,7 @@ describe('episodeVisibility', function(){ "use strict"; - var $scope, episode, episodeVisibility, episodeData, opalTestHelper; + var $scope, episode, episodeVisibility, opalTestHelper; var $rootScope; diff --git a/opal/static/js/test/item.service.test.js b/opal/static/js/test/item.service.test.js index cc136ba4a..15da1cb81 100644 --- a/opal/static/js/test/item.service.test.js +++ b/opal/static/js/test/item.service.test.js @@ -1,7 +1,7 @@ describe('Item', function() { "use strict"; - var columns, episodeData, recordSchema, list_schema, mockWindow; + var episodeData, recordSchema, mockWindow; var opalTestHelper, $rootScope, Item, $httpBackend, item, episode; var angularServiceMock; diff --git a/opal/static/js/test/patient.service.test.js b/opal/static/js/test/patient.service.test.js index 2dfab3f19..255117000 100644 --- a/opal/static/js/test/patient.service.test.js +++ b/opal/static/js/test/patient.service.test.js @@ -4,7 +4,7 @@ describe('Patient', function() { "use strict"; - var $httpBackend, $route, $rootScope, Patient, EpisodeSpy, patientData; + var $httpBackend, $route, $rootScope, Patient, patientData; var opalTestHelper, episodeData; beforeEach(function(){ diff --git a/opal/static/js/test/patient_list.controller.test.js b/opal/static/js/test/patient_list.controller.test.js index 7c88c1950..775f2aaf6 100644 --- a/opal/static/js/test/patient_list.controller.test.js +++ b/opal/static/js/test/patient_list.controller.test.js @@ -1,14 +1,14 @@ describe('PatientListCtrl', function() { "use strict"; - var episodeData, episodeData2, metaData, patientData; + var episodeData, episodeData2, metaData; var Episode, Item, episode, episodeVisibility; var profile, episode2; - var $scope, $cookies, $controller, $q, $dialog, $httpBackend; + var $scope, $cookies, $controller, $q, $httpBackend; var $$injector; var $location, $routeParams, $http; var opalTestHelper; var episodedata, controller; - var $modal, metadata, $rootScope; + var $modal, $rootScope; var _makecontroller; diff --git a/opal/static/js/test/record_editor_test.js b/opal/static/js/test/record_editor_test.js index a64fcdd82..969c20218 100644 --- a/opal/static/js/test/record_editor_test.js +++ b/opal/static/js/test/record_editor_test.js @@ -2,42 +2,12 @@ describe('RecordEditor', function(){ "use strict"; var $scope, $modal, $routeParams; - var $rootScope, $q, $controller; - var Episode, episode; - var controller, UserProfile; + var $rootScope, $q; + var episode; + var UserProfile; var opalTestHelper; var profile, $log; - var episodeData = { - id: 123, - active: true, - prev_episodes: [], - next_episodes: [], - demographics: [{ - id: 101, - patient_id: 99, - name: 'John Smith', - date_of_birth: '1980-07-31' - }], - tagging: [{'mine': true, 'tropical': true}], - location: [{ - category: 'Inepisode', - hospital: 'UCH', - ward: 'T10', - bed: '15', - date_of_admission: '2013-08-01', - }], - diagnosis: [{ - id: 102, - condition: 'Dengue', - provisional: true, - }, { - id: 103, - condition: 'Malaria', - provisional: false, - }] - }; - var columns = { "default": [ { @@ -89,9 +59,7 @@ describe('RecordEditor', function(){ $rootScope = $injector.get('$rootScope'); $scope = $rootScope.$new(); $routeParams = $injector.get('$routeParams'); - $controller = $injector.get('$controller'); $modal = $injector.get('$modal'); - Episode = $injector.get('Episode'); $q = $injector.get('$q'); UserProfile = $injector.get('UserProfile'); opalTestHelper = $injector.get('opalTestHelper'); @@ -109,8 +77,6 @@ describe('RecordEditor', function(){ spyOn($log, "warn"); episode = opalTestHelper.newEpisode($rootScope); - // $rootScope.fields = fields; - // episode = new Episode(angular.copy(episodeData)); }); describe("edit item", function(){ From 98501a59c3ee0b28901ed20440d1ea6b6fb837cf Mon Sep 17 00:00:00 2001 From: fredkingham Date: Tue, 7 Jul 2020 10:02:52 +0100 Subject: [PATCH 05/23] removes the directory scroll to top as this is not used --- changelog.md | 3 ++ .../javascript/javascript_helpers.md | 8 ----- opal/static/js/opal/directives.js | 27 ---------------- opal/static/js/test/directives.test.js | 32 ------------------- 4 files changed, 3 insertions(+), 67 deletions(-) diff --git a/changelog.md b/changelog.md index 0d613fb77..edfee37b5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ ### 0.18.4 (Minor Release) +#### Removes scroll to top +Removes the directory `scrolllto-top` as this is not commonly used. `go-to-top` is directive that is a a drop in replacement that will take the user up to the top of the page but without scrolling. + #### Remove shortDate and shortDateTime The angular filters shortDate and shortDateTime have been deprecated for some time. diff --git a/doc/docs/reference/javascript/javascript_helpers.md b/doc/docs/reference/javascript/javascript_helpers.md index 205f6cd1d..1c78f4dcc 100644 --- a/doc/docs/reference/javascript/javascript_helpers.md +++ b/doc/docs/reference/javascript/javascript_helpers.md @@ -70,14 +70,6 @@ If the form is valid, it will allow the ng-click function to be called. This means that if you only want to show error messages after the user has clicked the save button you can do so with the form.$submitted variable. -#### scroll-top - -Adds a click handler to the element that when click will animate the body of the element to scroll to the top - -#### go-to-top - -Similar to scroll-top, this moves the scroll bar to the top of the page but doesn't animate the transition. - #### copy to clipboard ##### e.g. diff --git a/opal/static/js/opal/directives.js b/opal/static/js/opal/directives.js index e0184608b..e357cdf69 100644 --- a/opal/static/js/opal/directives.js +++ b/opal/static/js/opal/directives.js @@ -81,32 +81,6 @@ directives.directive("freezeHeaders", function () { }; }); -directives.directive('scrollTop', function () { - return { - link: function (scope, element, attrs) { - var body = $("html, body"); - element.bind("click", function(){ - body.animate({ scrollTop: "0" }); - }); - - $(window).on("scroll.scrollTop", function(){ - window.requestAnimationFrame(function(){ - if($(window).scrollTop() > 0){ - $(element).removeClass("hidden-at-top"); - } - else{ - $(element).addClass("hidden-at-top"); - } - }); - }); - - scope.$on('$destroy', function(){ - $(window).off("resize.fixHeight"); - }); - } - }; -}); - directives.directive('goToTop', function () { return { priority: 1, @@ -119,7 +93,6 @@ directives.directive('goToTop', function () { }; }); - directives.directive('placeholder', function($timeout){ if ($.support.placeholder) { return {}; diff --git a/opal/static/js/test/directives.test.js b/opal/static/js/test/directives.test.js index 0d7c0a948..32a26446b 100644 --- a/opal/static/js/test/directives.test.js +++ b/opal/static/js/test/directives.test.js @@ -185,38 +185,6 @@ describe('OPAL Directives', function(){ }); - describe('scrollTop', function(){ - - it('should animate on click', function() { - var markup = ''; - spyOn($.fn, "animate"); - compileDirective(markup); - $(element).click(); - expect($.fn.animate).toHaveBeenCalledWith({ scrollTop: '0' }); - }); - - it('should set the class when at top', function() { - var markup = ''; - spyOn($.fn, 'scrollTop').and.returnValue(0) - spyOn(window, 'requestAnimationFrame').and.callFake(function(f){f()}); - compileDirective(markup); - $(window).trigger('scroll.scrollTop') - var btn = $(element.find("button")); - expect($(element[0]).hasClass('hidden-at-top')).toBe(true); - }); - - it('should remove the class when below top', function() { - var markup = ''; - spyOn($.fn, 'scrollTop').and.returnValue(100) - spyOn(window, 'requestAnimationFrame').and.callFake(function(f){f()}); - compileDirective(markup); - $(window).trigger('scroll.scrollTop') - var btn = $(element.find("button")); - expect($(element[0]).hasClass('hidden-at-top')).toBe(false); - }); - - }) - describe('goToTop', function(){ it('should compile', function() { var markup = ''; From f350d299e553930eff3a645ec89a5d8efce6bfb1 Mon Sep 17 00:00:00 2001 From: fredkingham Date: Sun, 2 Aug 2020 18:09:12 +0100 Subject: [PATCH 06/23] Removes the reference to the opal flow service which no longer exists --- opal/templates/base.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/opal/templates/base.html b/opal/templates/base.html index 677f6f7dc..9ea1cf3fe 100644 --- a/opal/templates/base.html +++ b/opal/templates/base.html @@ -33,10 +33,7 @@ {% plugin_opal_angular_tracking_exclude %}