Skip to content

Commit

Permalink
updated according to comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wolendranh committed Nov 13, 2018
1 parent ec3298d commit 8c386d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
20 changes: 9 additions & 11 deletions arctic/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,19 +711,17 @@ def get_action_links(self):

return self._allowed_action_links

def _get_custom_attributes(self, action_link):
attributes = None
if len(action_link) == 4:
attributes = action_link[3]
# take into account that 3 parameter can be string icon class
elif len(action_link) == 3 and isinstance(action_link[2], dict):
attributes = action_link[2]
return attributes

def _build_action_link(self, action_link):
icon = action_link[2] if len(action_link) >= 3 and isinstance(action_link[2], str) else None
icon, attributes = None, None
if len(action_link) == 3:
# icon can be 3-rd arg of link or specified inside inside dict with same index
if isinstance(action_link[2], str):
icon = action_link[2]
elif isinstance(action_link[2], dict):
icon = action_link[2].get('icon_class', None)
attributes = action_link[2].get('attributes', None)
return {"label": action_link[0], "url": action_link[1],
"icon": icon, "attributes": self._get_custom_attributes(action_link)}
"icon": icon, "attributes": attributes}

def get_tool_links(self):
if not self.tool_links:
Expand Down
5 changes: 3 additions & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ standard notation by prepending a minus to the field, for example `-name`.
optional list of `('name', 'base_url', 'optional icon class')` links, that
appear on the last column of the table and can apply a certain action, such
as delete.
In case if some custom attributes required, they can be specified as last argument in form of dict.
`('name', 'base_url', 'optional icon class', {'custom_attr_name': 'custom_attr_value'})`
In case if some custom attributes required, they can be specified as last argument in form of dict. In this case
optional icon class can be provided as part of that argument dict
`('name', 'base_url', 'optional icon class', {'icon_class': 'fa', 'attributes': {'custom_attr_name': 'custom_attr_value'}})`

### `get_field_actions(row)`

Expand Down

0 comments on commit 8c386d4

Please sign in to comment.