Skip to content

Commit

Permalink
Merge pull request #1645 from openhealthcare/as-menuitem-index
Browse files Browse the repository at this point in the history
Add an index argument to [Pathway|PatientList].as_menuitem()
  • Loading branch information
fredkingham committed Nov 9, 2018
2 parents 2eca04a + 6d42df5 commit cb779a5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/docs/reference/pathways.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion doc/docs/reference/patient_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions opal/core/pathway/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions opal/core/pathway/tests/test_pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions opal/core/patient_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions opal/tests/test_patient_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb779a5

Please sign in to comment.