diff --git a/portal/config/eproms/Organization.json b/portal/config/eproms/Organization.json index 0b3d30da82..cda1c2b94e 100644 --- a/portal/config/eproms/Organization.json +++ b/portal/config/eproms/Organization.json @@ -1565,9 +1565,10 @@ }, { "research_protocols": [ - {"name": "IRONMAN v2", "retired_as_of": "2019-03-03T00:00:00Z"}, - {"name": "IRONMAN v3", "retired_as_of": "2020-08-07T04:00:00Z"}, - {"name": "IRONMAN v5"} + {"name": "IRONMAN v2", "retired_as_of": "2019-03-03T00:00:00Z"}, + {"name": "IRONMAN v3", "retired_as_of": "2020-08-07T04:00:00Z"}, + {"name": "IRONMAN v5"}, + {"name": "EMPRO v1"} ], "url": "http://us.truenth.org/identity-codes/research-protocol" } diff --git a/portal/static/js/src/bootstrapTableExtensions.js b/portal/static/js/src/bootstrapTableExtensions.js new file mode 100644 index 0000000000..cd3e7a253e --- /dev/null +++ b/portal/static/js/src/bootstrapTableExtensions.js @@ -0,0 +1,13 @@ +import {dateSorter, alphanumericSorter} from "./modules/Utility.js"; + +/* + * global variables, can be used in custom sort in datatable, e.g. patient list + */ +var tnthTables = window.tnthTables = { + dateSorter : dateSorter, + alphanumericSorter: alphanumericSorter +}; +/* + * function used by bootstrap datatable extension lib + */ +var alphanum = window.alphanum = alphanumericSorter; diff --git a/portal/static/js/src/modules/Utility.js b/portal/static/js/src/modules/Utility.js index 3464c49ad6..fc930d3efb 100644 --- a/portal/static/js/src/modules/Utility.js +++ b/portal/static/js/src/modules/Utility.js @@ -431,3 +431,12 @@ export function convertArrayToObject (array, key) { }, {}); return array; } + +export function dateSorter(a, b) { + return new Date(a) - new Date(b); +} +export function alphanumericSorter(a, b) { + return a.toString().localeCompare(b.toString(), "en", { numeric: true }); + //The localeCompare() method returns 1 if a reference string comes before, -1 it comes after or 0 if the reference string is the same as the given string. + //see relevant discussion here, https://stackoverflow.com/questions/4340227/sort-mixed-alpha-numeric-array +} diff --git a/portal/templates/admin/admin_base.html b/portal/templates/admin/admin_base.html index 1047784770..411848d93d 100644 --- a/portal/templates/admin/admin_base.html +++ b/portal/templates/admin/admin_base.html @@ -1,8 +1,8 @@ {%- extends "layout.html" -%} {% block additional_scripts %} + - diff --git a/portal/views/patch_flask_user.py b/portal/views/patch_flask_user.py index b7669a8599..314abf2a28 100644 --- a/portal/views/patch_flask_user.py +++ b/portal/views/patch_flask_user.py @@ -67,7 +67,7 @@ def patch_forgot_password(): # Do NOT allow non registered to change password non_registered_roles = set(current_app.config['PRE_REGISTERED_ROLES']) - current_roles = {r.name for r in user.roles} + current_roles = {r.name for r in user.roles} if user else set() disjoint = current_roles.isdisjoint(non_registered_roles) if disjoint and user: diff --git a/portal/webpack.common.js b/portal/webpack.common.js index 4effbbe6f7..39ae536e9d 100644 --- a/portal/webpack.common.js +++ b/portal/webpack.common.js @@ -10,6 +10,7 @@ module.exports = { "account": JsSrcPath+"/accountCreation.js", "admin": JsSrcPath+"/admin.js", "assessmentReport": JsSrcPath+"/assessmentReport.js", + "bootstrapTableExtensions": JsSrcPath+"/bootstrapTableExtensions.js", "CookieMonster": JsSrcPath+"/CookieMonster.js", "coredata": JsSrcPath+"/coredata.js", "initialQueries": JsSrcPath+"/initialQueries.js",