chg: [UI] Open modal without onclick vol. 2

pull/8231/head
Jakub Onderka 2022-03-20 14:40:58 +01:00
parent 611f75026f
commit 38fc903501
4 changed files with 40 additions and 42 deletions

View File

@ -16,15 +16,8 @@
'type' => 'simple',
'fa-icon' => 'plus',
'text' => __('Add authentication key'),
'class' => 'btn btn-primary',
'onClick' => 'openGenericModal',
'onClickParams' => [
sprintf(
'%s/auth_keys/add%s',
$baseurl,
empty($user_id) ? '' : ('/' . $user_id)
)
]
'class' => 'btn-primary modal-open',
'url' => "$baseurl/auth_keys/add" . (empty($user_id) ? '' : ('/' . $user_id)),
]
]
],
@ -101,11 +94,9 @@
'title' => 'Edit auth key',
],
[
'onclick' => sprintf(
'openGenericModal(\'%s/authKeys/delete/[onclick_params_data_path]\');',
$baseurl
),
'onclick_params_data_path' => 'AuthKey.id',
'class' => 'modal-open',
'url' => "$baseurl/authKeys/delete",
'url_params_data_paths' => ['AuthKey.id'],
'icon' => 'trash',
'title' => __('Delete auth key'),
]

View File

@ -1,4 +1,5 @@
<?php
$eventId = (int) $event['Event']['id'];
if (!empty($this->passedArgs['correlation'])) {
$attributeFilter = 'correlation';
}
@ -28,7 +29,7 @@
'text' => __('Proposal'),
'active' => $attributeFilter == 'proposal',
'onClick' => 'filterAttributes',
'onClickParams' => array('proposal', $event['Event']['id'])
'onClickParams' => array('proposal', $eventId)
);
$simple_filter_data[] = array(
'id' => 'filter_correlation',
@ -44,7 +45,7 @@
'text' => __('Warning'),
'active' => $attributeFilter == 'warning',
'onClick' => 'filterAttributes',
'onClickParams' => array('warning', $event['Event']['id'])
'onClickParams' => array('warning', $eventId)
);
$data = array(
'children' => array(
@ -54,9 +55,8 @@
'id' => 'create-button',
'title' => $possibleAction === 'attribute' ? __('Add attribute') : __('Add proposal'),
'fa-icon' => 'plus',
'class' => 'last',
'onClick' => 'openGenericModal',
'onClickParams' => array('/' . $possibleAction . 's/add/' . h($event['Event']['id']))
'class' => 'last modal-open',
'url' => $baseurl . '/' . $possibleAction . 's/add/' . $eventId,
),
array(
'id' => 'multi-edit-button',
@ -64,7 +64,7 @@
'class' => 'mass-select hidden',
'fa-icon' => 'edit',
'onClick' => 'editSelectedAttributes',
'onClickParams' => array($event['Event']['id'])
'onClickParams' => array($eventId)
),
array(
'id' => 'multi-tag-button',
@ -81,7 +81,7 @@
'fa-icon' => 'rebel',
'fa-source' => 'fab',
'onClick' => 'popoverPopup',
'onClickParams' => array('this', 'selected/attribute/eventid:' . h($event['Event']['id']), 'galaxies', 'selectGalaxyNamespace')
'onClickParams' => array('this', 'selected/attribute/eventid:' . $eventId, 'galaxies', 'selectGalaxyNamespace')
),
array(
'id' => 'group-into-object-button',
@ -90,7 +90,7 @@
'fa-icon' => 'object-group',
'fa-source' => 'fa',
'onClick' => 'proposeObjectsFromSelectedAttributes',
'onClickParams' => array('this', $event['Event']['id'])
'onClickParams' => array('this', $eventId)
),
array(
'id' => 'multi-delete-button',
@ -98,7 +98,7 @@
'class' => 'mass-select hidden',
'fa-icon' => 'trash',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'deleteAttributes')
'onClickParams' => array($eventId, 'deleteAttributes')
),
array(
'id' => 'multi-accept-button',
@ -106,7 +106,7 @@
'class' => 'mass-proposal-select hidden',
'fa-icon' => 'check-circle',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'acceptProposals')
'onClickParams' => array($eventId, 'acceptProposals')
),
array(
'id' => 'multi-discard-button',
@ -114,7 +114,7 @@
'class' => 'mass-proposal-select hidden',
'fa-icon' => 'times',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'discardProposals')
'onClickParams' => array($eventId, 'discardProposals')
),
array(
'id' => 'multi-sighting-button',
@ -132,7 +132,7 @@
'title' => __('Populate using a template'),
'fa-icon' => 'list',
'onClick' => 'getPopup',
'onClickParams' => array($event['Event']['id'], 'templates', 'templateChoices'),
'onClickParams' => array($eventId, 'templates', 'templateChoices'),
'requirement' => $mayModify
),
array(
@ -140,14 +140,14 @@
'title' => __('Populate using the freetext import tool'),
'fa-icon' => 'align-left',
'onClick' => 'getPopup',
'onClickParams' => array($event['Event']['id'], 'events', 'freeTextImport')
'onClickParams' => array($eventId, 'events', 'freeTextImport')
),
array(
'id' => 'attribute-replace-button',
'title' => __('Replace all attributes of a category/type combination within the event'),
'fa-icon' => 'random',
'onClick' => 'getPopup',
'onClickParams' => array($event['Event']['id'], 'attributes', 'attributeReplace'),
'onClickParams' => array($eventId, 'attributes', 'attributeReplace'),
'requirement' => $mayModify
)
)
@ -236,7 +236,7 @@
'fa-icon' => 'times',
'title' => __('Remove filters'),
'onClick' => 'filterAttributes',
'onClickParams' => array('all', $event['Event']['id'])
'onClickParams' => array('all', $eventId)
)
)
)

View File

@ -114,13 +114,22 @@
$action['onclick']
);
}
$title = empty($action['title']) ? '' : h($action['title']);
$classes = [];
if (!empty($action['class'])) {
$classes[] = h($action['class']);
}
if (!empty($action['dbclickAction'])) {
$classes[] = 'dblclickActionElement';
}
echo sprintf(
'<a href="%s" title="%s" aria-label="%s" %s %s><i class="black %s"></i></a> ',
'<a href="%s" title="%s" aria-label="%s"%s%s><i class="black %s"></i></a> ',
$url,
empty($action['title']) ? '' : h($action['title']),
empty($action['title']) ? '' : h($action['title']),
empty($action['dbclickAction']) ? '' : 'class="dblclickActionElement"',
empty($action['onclick']) ? '' : sprintf('onclick="event.preventDefault();%s"', $action['onclick']),
$title,
$title,
empty($classes) ? '' : ' class="' . implode(' ', $classes) . '"',
empty($action['onclick']) ? '' : sprintf(' onclick="event.preventDefault();%s"', $action['onclick']),
$this->FontAwesome->getClass($action['icon'])
);
}

View File

@ -84,18 +84,16 @@ if ($isSiteAdmin) {
$actions = [
[
'url' => $baseurl . '/admin/roles/edit',
'url_params_data_paths' => array(
'Role.id'
),
'url_params_data_paths' => ['Role.id'],
'icon' => 'edit',
'title' => __('Edit role'),
],
[
'onclick' => sprintf(
'openGenericModal(\'%s/admin/roles/delete/[onclick_params_data_path]\');',
$baseurl
),
'onclick_params_data_path' => 'Role.id',
'class' => 'modal-open',
'url' => "$baseurl/admin/roles/delete",
'url_params_data_paths' => ['Role.id'],
'icon' => 'trash',
'title' => __('Delete role'),
]
];
} else {