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

View File

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

View File

@ -114,13 +114,22 @@
$action['onclick'] $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( 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, $url,
empty($action['title']) ? '' : h($action['title']), $title,
empty($action['title']) ? '' : h($action['title']), $title,
empty($action['dbclickAction']) ? '' : 'class="dblclickActionElement"', empty($classes) ? '' : ' class="' . implode(' ', $classes) . '"',
empty($action['onclick']) ? '' : sprintf('onclick="event.preventDefault();%s"', $action['onclick']), empty($action['onclick']) ? '' : sprintf(' onclick="event.preventDefault();%s"', $action['onclick']),
$this->FontAwesome->getClass($action['icon']) $this->FontAwesome->getClass($action['icon'])
); );
} }

View File

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