diff --git a/changelog.md b/changelog.md index 6862c4652..9068406f6 100644 --- a/changelog.md +++ b/changelog.md @@ -103,6 +103,8 @@ including the `reopen_episode_modal.html` template and the url/view at `template * Adds in a footer updated/created by to the form base template +* Adds an index argument to `PatientList.as_menuitem()` and `Pathway.as_menuitem()` + #### Updates to the Dependency Graph * Letter: 0.4.1 -> 0.5 diff --git a/doc/docs/reference/pathways.md b/doc/docs/reference/pathways.md index 2524ea9f7..ef2b17fff 100644 --- a/doc/docs/reference/pathways.md +++ b/doc/docs/reference/pathways.md @@ -39,7 +39,7 @@ If set, this template will be used if your pathway is opened in a modal. If its ### Class Methods -#### `Pathway.as_menuitem(href=None, activepattern=None, icon=None, display=None)` +#### `Pathway.as_menuitem(href=None, activepattern=None, icon=None, display=None, index=None)` Return an instance of `opal.core.menus.MenuItem` that will direct the user to this pathway. diff --git a/doc/docs/reference/patient_list.md b/doc/docs/reference/patient_list.md index 9bfffd2a1..840551868 100644 --- a/doc/docs/reference/patient_list.md +++ b/doc/docs/reference/patient_list.md @@ -91,7 +91,7 @@ MyList.get_display_name() ``` -#### `PatientList.as_menuitem(href=None, activepattern=None, icon=None, display=None)` +#### `PatientList.as_menuitem(href=None, activepattern=None, icon=None, display=None, index=None)` Return an instance of `opal.core.menus.MenuItem` that will direct the user to this patient list. diff --git a/opal/core/pathway/pathways.py b/opal/core/pathway/pathways.py index 1fc20e367..bf1b1fde1 100644 --- a/opal/core/pathway/pathways.py +++ b/opal/core/pathway/pathways.py @@ -71,6 +71,7 @@ def as_menuitem(kls, **kwargs): activepattern=kwargs.get('activepattern', kls.get_absolute_url()), icon=kwargs.get('icon', kls.get_icon()), display=kwargs.get('display', kls.get_display_name()), + index=kwargs.get('index', '') ) def get_pathway_service(self, is_modal): diff --git a/opal/core/pathway/tests/test_pathways.py b/opal/core/pathway/tests/test_pathways.py index 07f79f30f..6ebfcfe12 100644 --- a/opal/core/pathway/tests/test_pathways.py +++ b/opal/core/pathway/tests/test_pathways.py @@ -481,6 +481,10 @@ def test_as_menuitem_from_kwargs(self): self.assertEqual('fa-sea', menu.icon) self.assertEqual('Bleu', menu.display) + def test_as_menuitem_set_index(self): + menu = ColourPathway.as_menuitem(index=-30) + self.assertEqual(-30, menu.index) + def test_as_menuitem_uses_getter_for_icon(self): menu = OveridePathway.as_menuitem() self.assertEqual('fa-django', menu.icon) diff --git a/opal/core/patient_lists.py b/opal/core/patient_lists.py index 2c84c94f2..44b11cceb 100644 --- a/opal/core/patient_lists.py +++ b/opal/core/patient_lists.py @@ -158,6 +158,7 @@ def as_menuitem(kls, **kwargs): activepattern=kwargs.get('activepattern', kls.get_absolute_url()), icon=kwargs.get('icon', kls.get_icon()), display=kwargs.get('display', kls.get_display_name()), + index=kwargs.get('index', '') ) def get_template_prefixes(self): diff --git a/opal/tests/test_patient_lists.py b/opal/tests/test_patient_lists.py index 23fa89ab6..65892cc98 100644 --- a/opal/tests/test_patient_lists.py +++ b/opal/tests/test_patient_lists.py @@ -299,6 +299,10 @@ def test_as_menuitem_from_kwargs(self): self.assertEqual(menu.icon, 'fa-foo') self.assertEqual(menu.display, 'Foo') + def test_as_menuitem_set_index(self): + menu = TaggingTestPatientList.as_menuitem(index=-30) + self.assertEqual(-30, menu.index) + def test_as_menuitem_uses_getter_for_icon(self): menu = IconicList.as_menuitem() self.assertEqual('fa-james-dean', menu.icon)