mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Allow passing additional columns & specifying a sequence
This commit is contained in:
@ -214,7 +214,7 @@ class ObjectChangeTable(BaseTable):
|
||||
template_code=OBJECTCHANGE_REQUEST_ID,
|
||||
verbose_name='Request ID'
|
||||
)
|
||||
actions = ActionsColumn(actions=())
|
||||
actions = ActionsColumn(sequence=())
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ObjectChange
|
||||
|
@ -59,7 +59,7 @@ class FHRPGroupAssignmentTable(BaseTable):
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions=('edit', 'delete')
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
|
@ -154,7 +154,7 @@ class VLANDevicesTable(VLANMembersTable):
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions=('edit',)
|
||||
sequence=('edit',)
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
@ -168,7 +168,7 @@ class VLANVirtualMachinesTable(VLANMembersTable):
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions=('edit',)
|
||||
sequence=('edit',)
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
|
@ -162,7 +162,7 @@ class ContactAssignmentTable(BaseTable):
|
||||
linkify=True
|
||||
)
|
||||
actions = ActionsColumn(
|
||||
actions=('edit', 'delete')
|
||||
sequence=('edit', 'delete')
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
|
@ -102,18 +102,22 @@ class ActionsItem:
|
||||
class ActionsColumn(tables.Column):
|
||||
attrs = {'td': {'class': 'text-end noprint'}}
|
||||
empty_values = ()
|
||||
_actions = {
|
||||
actions = {
|
||||
'edit': ActionsItem('Edit', 'pencil', 'change'),
|
||||
'delete': ActionsItem('Delete', 'trash-can-outline', 'delete'),
|
||||
'changelog': ActionsItem('Changelog', 'history'),
|
||||
}
|
||||
|
||||
def __init__(self, *args, actions=('edit', 'delete', 'changelog'), **kwargs):
|
||||
def __init__(self, *args, extra_actions=None, sequence=('edit', 'delete', 'changelog'), **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Add/update any extra actions passed
|
||||
if extra_actions:
|
||||
self.actions.update(extra_actions)
|
||||
|
||||
# Determine which actions to enable
|
||||
self.actions = {
|
||||
name: self._actions[name] for name in actions
|
||||
name: self.actions[name] for name in sequence
|
||||
}
|
||||
|
||||
def header(self):
|
||||
|
Reference in New Issue
Block a user