new: [UI] Rework of the attribute index toolbar on the event view

pull/4438/head
iglocska 2019-02-24 00:20:25 +01:00
parent 232ccaffb8
commit cdc97ee268
8 changed files with 317 additions and 71 deletions

View File

@ -113,66 +113,18 @@
?>
</div>
<div id="attributeList" class="attributeListContainer">
<div class="tabMenu tabMenuEditBlock noPrint">
<span id="create-button" title="<?php echo __('Add attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Add attribute');?>" class="icon-plus useCursorPointer" onClick="clickCreateButton(<?php echo $event['Event']['id']; ?>, '<?php echo $possibleAction; ?>');"></span>
<span id="multi-edit-button" title="<?php echo __('Edit selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Edit selected Attributes');?>" class="hidden icon-edit mass-select useCursorPointer" onClick="editSelectedAttributes(<?php echo $event['Event']['id']; ?>);"></span>
<span id="multi-tag-button" title="<?php echo __('Tag selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Tag selected Attributes');?>" class="hidden icon-tag mass-select useCursorPointer" onClick="popoverPopup(this, 'selected/attribute', 'tags', 'selectTaxonomy');"></span>
<span id="multi-galaxy-button" title="<?php echo __('Add new cluster to selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Add new cluster to selected Attributes');?>" class="hidden icon-rebel fa-rebel mass-select useCursorPointer" style="font: normal normal normal 14px/1 FontAwesome; vertical-align: top;" onClick="popoverPopup(this, 'selected/attribute', 'galaxies', 'selectGalaxyNamespace');"></span>
<span id="multi-delete-button" title="<?php echo __('Delete selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Delete selected Attributes');?>" class="hidden icon-trash mass-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'deleteAttributes');"></span>
<span id="multi-accept-button" title="<?php echo __('Accept selected Proposals');?>" role="button" tabindex="0" aria-label="<?php echo __('Accept selected Proposals');?>" class="hidden icon-ok mass-proposal-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'acceptProposals');"></span>
<span id="multi-discard-button" title="<?php echo __('Discard selected Proposals');?>" role="button" tabindex="0" aria-label="<?php echo __('Discard selected Proposals');?>" class="hidden icon-remove mass-proposal-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'discardProposals');"></span>
<span id="multi-sighting-button" title="<?php echo __('Sightings display for selected attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Sightings display for selected attributes');?>" class="hidden icon-wrench mass-select useCursorPointer sightings_advanced_add" data-object-id="selected" data-object-context="attribute"></span>
</div>
<div class="tabMenu tabMenuToolsBlock noPrint">
<?php if ($mayModify): ?>
<span id="create-button" title="<?php echo __('Populate using a template');?>" role="button" tabindex="0" aria-label="<?php echo __('Populate using a template');?>" class="icon-list-alt useCursorPointer" onClick="getPopup(<?php echo $event['Event']['id']; ?>, 'templates', 'templateChoices');"></span>
<?php endif; ?>
<span id="freetext-button" title="<?php echo __('Populate using the freetext import tool');?>" role="button" tabindex="0" aria-label="<?php echo __('Populate using the freetext import tool');?>" class="icon-exclamation-sign icon-inverse useCursorPointer" onClick="getPopup(<?php echo $event['Event']['id']; ?>, 'events', 'freeTextImport');"></span>
<?php if ($mayModify): ?>
<span id="attribute-replace-button" title="<?php echo __('Replace all attributes of a category/type combination within the event');?>" role="button" tabindex="0" aria-label="<?php echo __('Replace all attributes of a category/type combination within the event');?>" class="icon-random useCursorPointer" onClick="getPopup(<?php echo $event['Event']['id']; ?>, 'attributes', 'attributeReplace');"></span>
<?php endif; ?>
</div>
<?php
$target = h($event['Event']['id']);
if ($extended) $target .= '/extended:1';
echo $this->element('eventattributetoolbar', array(
'target' => $target,
'attributeFilter' => $attributeFilter,
'urlHere' => $urlHere,
'filtered' =>$filtered,
'mayModify' => $mayModify,
'possibleAction' => $possibleAction
));
?>
<div class="tabMenu tabMenuFiltersBlock noPrint" style="padding-right:0px !important;">
<span id="filter_header" class="attribute_filter_header">Filters: </span>
<div id="filter_all" title="<?php echo __('Show all attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Show all attributes');?>" class="attribute_filter_text<?php if ($attributeFilter == 'all') echo '_active'; ?>" onClick="filterAttributes('all', '<?php echo $target; ?>');">All</div>
<?php
foreach ($typeGroups as $group):
?>
<div id="filter_<?php echo h($group); ?>" title="<?php echo __('Only show %s related attributes', h($group));?>" role="button" tabindex="0" aria-label="<?php echo __('Only show %s related attributes', h($group));?>" class="attribute_filter_text<?php if ($attributeFilter == $group) echo '_active'; ?>" onClick="filterAttributes('<?php echo $group; ?>', '<?php echo $target; ?>');"><?php echo ucfirst($group); ?></div>
<?php
endforeach;
?>
<div id="filter_proposal" title="<?php echo __('Only show proposals');?>" role="button" tabindex="0" aria-label="<?php echo __('Only show proposals');?>" class="attribute_filter_text<?php if ($attributeFilter == 'proposal') echo '_active'; ?>" onClick="filterAttributes('proposal', '<?php echo h($event['Event']['id']); ?>');"><?php echo __('Proposal');?></div>
<div id="filter_correlation" title="<?php echo __('Only show correlating attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Only show correlating attributes');?>" class="attribute_filter_text<?php if ($attributeFilter == 'correlation') echo '_active'; ?>" onClick="filterAttributes('correlation', '<?php echo h($event['Event']['id']); ?>');">Correlation</div>
<div id="filter_warning" title="<?php echo __('Only show potentially false positive attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Only show potentially false positive attributes');?>" class="attribute_filter_text<?php if ($attributeFilter == 'warning') echo '_active'; ?>" onClick="filterAttributes('warning', '<?php echo h($event['Event']['id']); ?>');"><?php echo __('Warnings');?></div>
<?php if ($me['Role']['perm_sync'] || $event['Orgc']['id'] == $me['org_id']): ?>
<div id="filter_deleted" title="<?php echo __('Include deleted attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Include deleted attributes');?>" class="attribute_filter_text<?php if ($deleted) echo '_active'; ?>" onClick="toggleBoolFilter('<?php echo $urlHere;?>', 'deleted');"><?php echo __('Deleted');?></div>
<?php endif; ?>
<div id="show_context" title="<?php echo __('Show attribute context fields');?>" role="button" tabindex="0" aria-label="<?php echo __('Show attribute context fields');?>" class="attribute_filter_text" onClick="toggleContextFields();"><?php echo __('Context');?></div>
<div id="show_correlating_tags" title="<?php echo __('Also display the tags derived from correlations');?>" role="button" tabindex="0" aria-label="<?php echo __('Also display the tags derived from correlations');?>" class="attribute_filter_text<?php if ($includeRelatedTags) echo '_active'; ?>" onClick="toggleBoolFilter('<?php echo $urlHere;?>', 'includeRelatedTags');"><?php echo __('Related Tags');?></div>
<div class="attribute_filter_text btn-<?php echo ($advancedFilteringActive ? 'success' : 'inverse'); ?> btn" style="padding: 0px 6px;font-size: 12px;margin: 0px 2px;font-weight: bold;" onclick="triggerEventFilteringTool(this)">
<it class="fa fa-filter"></it>
<?php echo __('Filtering tool'); ?>
<?php if($advancedFilteringActive): ?>
<span class="badge badge-warning" title="<?php echo h(count($advancedFilteringActiveRules)) . __(' active rule(s)')?>"><?php echo h(count($advancedFilteringActiveRules)) ?></span>
<?php endif; ?>
</div>
<div title="input filter" tabindex="0" aria-label="input filter" class="attribute_filter_text" style="padding-top:0px;">
<input type="text" id="attributesFilterField" style="height:20px;padding:0px;margin:0px;" class="form-control" data-eventid="<?php echo h($event['Event']['id']); ?>" value="<?php if ($filtered) echo h($passedArgsArray['all']); ?>"></input>
<span id="attributesFilterButton" role="button" class="icon-search" tabindex="0" aria-label="<?php echo __('Filter on attributes value');?>" onClick="filterAttributes('value', '<?php echo h($event['Event']['id']); ?>');"></span>
<?php if ($filtered):?>
<span tabindex="0" aria-label="<?php echo __('Show all attributes');?>" title="<?php echo __('Remove filters');?>" role="button" onClick="filterAttributes('all', '<?php echo h($event['Event']['id']); ?>');" class='icon-remove'></span>
<?php endif;?>
</div>
</div>
<?php echo $this->element('/Events/View/eventFilteringQueryBuilder'); ?>
<table class="table table-striped table-condensed">
<tr>
<?php
@ -395,6 +347,17 @@ attributes or the appropriate distribution level. If you think there is a mistak
$(this).parent().children(':nth-child(2)').attr('aria-label', 'Switch to binary representation');
}
});
$('.searchFilterButton').click(function() {
filterAttributes('value', '<?php echo h($event['Event']['id']); ?>');
});
$('#quickFilterButton').click(function() {
filterAttributes('value', '<?php echo h($event['Event']['id']); ?>');
});
$('#quickFilterField').on('keypress', function (e) {
if(e.which === 13) {
filterAttributes('value', '<?php echo h($event['Event']['id']); ?>');
}
});
</script>
<?php
echo $this->Js->writeBuffer();

View File

@ -0,0 +1,207 @@
<?php
$simple_filter_data = array(
array(
'id' => 'filter_all',
'title' => __('Show all attributes'),
'text' => __('All'),
'active' => $attributeFilter == 'all',
'onClick' => 'filterAttributes',
'onClickParams' => array('all', $target)
)
);
foreach ($typeGroups as $group) {
$simple_filter_data[] = array(
'id' => 'filter_' . h($group),
'title' => __('Only show %s related attributes', h($group)),
'text' => Inflector::humanize($group),
'active' => $attributeFilter == $group,
'onClick' => 'filterAttributes',
'onClickParams' => array($group, $target)
);
}
$simple_filter_data[] = array(
'id' => 'filter_proposal',
'title' => __('Only show proposals'),
'text' => __('Proposal'),
'active' => $attributeFilter == 'proposal',
'onClick' => 'filterAttributes',
'onClickParams' => array('proposal', $event['Event']['id'])
);
$simple_filter_data[] = array(
'id' => 'filter_correlation',
'title' => __('Only show correlating attributes'),
'text' => __('Correlation'),
'active' => $attributeFilter == 'correlation',
'onClick' => 'filterAttributes',
'onClickParams' => array('correlation', $event['Event']['id'])
);
$simple_filter_data[] = array(
'id' => 'filter_warning',
'title' => __('Only show potentially false positive attributes'),
'text' => __('Warning'),
'active' => $attributeFilter == 'warning',
'onClick' => 'filterAttributes',
'onClickParams' => array('warning', $event['Event']['id'])
);
$data = array(
'children' => array(
array(
'children' => array(
array(
'id' => 'create-button',
'title' => __('Add attribute'),
'fa-icon' => 'plus',
'onClick' => 'clickCreateButton',
'onClickParams' => array($event['Event']['id'], $possibleAction)
),
array(
'id' => 'multi-edit-button',
'title' => __('Edit selected Attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'edit',
'onClick' => 'editSelectedAttributes',
'onClickParams' => array($event['Event']['id'])
),
array(
'id' => 'multi-tag-button',
'title' => __('Tag selected Attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'tag',
'onClick' => 'popoverPopup',
'onClickParams' => array('this', 'selected/attribute', 'tags', 'selectTaxonomy')
),
array(
'id' => 'multi-galaxy-button',
'title' => __('Add new cluster to selected Attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'rebel',
'onClick' => 'popoverPopup',
'onClickParams' => array('this', 'selected/attribute', 'galaxies', 'selectGalaxyNamespace')
),
array(
'id' => 'multi-delete-button',
'title' => __('Delete selected Attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'trash',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'deleteAttributes')
),
array(
'id' => 'multi-accept-button',
'title' => __('Accept selected Proposals'),
'class' => 'mass-proposal-select hidden',
'fa-icon' => 'check-circl',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'acceptProposals')
),
array(
'id' => 'multi-discard-button',
'title' => __('Discard selected Proposals'),
'class' => 'mass-proposal-select hidden',
'fa-icon' => 'times',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'discardProposals')
),
array(
'id' => 'multi-sighting-button',
'title' => __('Sightings display for selected attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'wrench',
'onClick' => 'multiSelectAction',
'onClickParams' => array($event['Event']['id'], 'discardProposals')
)
)
),
array(
'children' => array(
array(
'id' => 'template-button',
'title' => __('Populate using a template'),
'fa-icon' => 'list',
'onClick' => 'getPopup',
'onClickParams' => array($event['Event']['id'], 'templates', 'templateChoices'),
'requirement' => $mayModify
),
array(
'id' => 'freetext-button',
'title' => __('Populate using the freetext import tool'),
'fa-icon' => 'align-left',
'onClick' => 'getPopup',
'onClickParams' => array($event['Event']['id'], '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'),
'requirement' => $mayModify
)
)
),
array(
'children' => array(
array(
'id' => 'simple_filter',
'type' => 'group',
'title' => __('Use a list of simple scopes to filter the data'),
'text' => __('Scope toggle'),
'children' => $simple_filter_data
),
array(
'id' => 'filter_deleted',
'title' => __('Include deleted attributes'),
'fa-icon' => 'trash',
'text' => __('Deleted'),
'active' => $deleted,
'onClick' => 'toggleBoolFilter',
'onClickParams' => array($urlHere, 'deleted'),
'requirement' => ($me['Role']['perm_sync'] || $event['Orgc']['id'] == $me['org_id'])
),
array(
'id' => 'show_attribute_context',
'title' => __('Show attribute context fields'),
'fa-icon' => 'info-circle',
'text' => __('Context'),
'active' => $deleted,
'onClick' => 'toggleContextFields'
),
array(
'id' => 'advanced_filtering',
'title' => __('Advanced filtering tool'),
'fa-icon' => 'filter',
'html' => sprintf(
'%s%s',
__('Filtering tool'),
$advancedFilteringActive ? sprintf(
' (<span class="bold" title="%s">%s</span>)',
sprintf(
__('%s active rule(s)'),
h(count($advancedFilteringActiveRules))
),
h(count($advancedFilteringActiveRules))
) : ''
),
'active' => $advancedFilteringActive,
'onClick' => 'triggerEventFilteringTool',
'onClickParams' > array('this')
)
)
),
array(
'type' => 'search',
'fa-icon' => 'search',
'placeholder' => 'Enter value to search',
'data' => '',
'cancel' => array(
'fa-icon' => 'times',
'title' => __('Remove filters'),
'onClick' => 'filterAttributes',
'onClickParams' => array('all', $event['Event']['id'])
)
)
)
);
echo $this->element('/genericElements/ListTopBar/scaffold', array('data' => $data));
echo $this->element('/Events/View/eventFilteringQueryBuilder');
?>

View File

@ -0,0 +1,46 @@
<?php
if (!isset($data['requirement']) || $data['requirement']) {
if (!empty($data['onClick']) || empty($data['url'])) {
$onClickParams = array();
if (!empty($data['onClickParams'])) {
foreach ($data['onClickParams'] as $param) {
$onClickParams[] = '\'' . h($param) . '\'';
}
}
$onClickParams = implode(',', $onClickParams);
$onClick = sprintf(
'onClick = "%s%s"',
(empty($data['url'])) ? 'event.preventDefault();' : '',
(!empty($data['onClick']) ? sprintf(
'%s(%s)',
h($data['onClick']),
$onClickParams
) : '')
);
}
$dataFields = array();
if (!empty($data['data'])) {
foreach ($data['data'] as $dataKey => $dataValue) {
$dataFields[] = sprintf(
'data-%s="%s"',
h($dataKey),
h($dataValue)
);
}
}
$dataFields = implode(' ', $dataFields);
echo sprintf(
'<li><a class="%s %s" id="%s" href="%s" %s %s %s>%s%s%s</a></li>',
empty($data['class']) ? '' : h($data['class']),
empty($data['active']) ? '' : 'background-blue', // Change the default class for highlighted/active toggles here
empty($data['id']) ? '' : 'id="' . h($data['id']) . '"',
empty($data['url']) ? '#' : h($data['url']), // prevent default is passed if the url is not set
empty($onClick) ? '' : $onClick, // pass $data['onClick'] for the function name to call and $data['onClickParams'] for the parameter list
empty($dataFields) ? '' : $dataFields,
empty($data['title']) ? '' : sprintf('title="%s"', h($data['title'])),
empty($data['fa-icon']) ? '' : sprintf('<i class="fa fa-%s"></i>', $data['fa-icon']), // this has to be sanitised beforehand!
empty($data['html']) ? '' : $data['html'], // this has to be sanitised beforehand!
empty($data['text']) ? '' : h($data['text'])
);
}
?>

View File

@ -0,0 +1,32 @@
<?php
if (!isset($data['requirement']) || $data['requirement']) {
$dataFields = array();
if (!empty($data['data'])) {
foreach ($data['data'] as $dataKey => $dataValue) {
$dataFields[] = sprintf(
'data-%s="%s"',
h($dataKey),
h($dataValue)
);
}
}
$dataFields = implode(' ', $dataFields);
if (!empty($data['children'])) {
$child_data = '';
foreach ($data['children'] as $child) {
$child_data .= $this->element('/genericElements/ListTopBar/element_embedded', array('data' => $child));
}
}
echo sprintf(
'<a class="btn btn-small btn-dropdown-toggle %s %s" %s data-toggle="dropdown" href="#" %s>%s%s%s <span class="caret"></span></a><ul class="dropdown-menu">%s</ul>',
empty($data['class']) ? '' : h($data['class']),
empty($data['active']) ? 'btn-inverse' : 'btn-primary', // Change the default class for highlighted/active toggles here
empty($data['id']) ? '' : 'id="' . h($data['id']) . '"',
empty($data['title']) ? '' : sprintf('title="%s"', h($data['title'])),
empty($data['fa-icon']) ? '' : sprintf('<i class="fa fa-%s"></i>', $data['fa-icon']), // this has to be sanitised beforehand!
empty($data['html']) ? '' : $data['html'], // this has to be sanitised beforehand!
empty($data['text']) ? '' : h($data['text']),
empty($data['children']) ? '' : $child_data
);
}
?>

View File

@ -38,7 +38,7 @@
empty($onClick) ? '' : $onClick, // pass $data['onClick'] for the function name to call and $data['onClickParams'] for the parameter list
empty($dataFields) ? '' : $dataFields,
empty($data['title']) ? '' : sprintf('title="%s"', h($data['title'])),
empty($data['fa-icon']) ? '' : sprintf('<i class="fa fa-%s"></i>', $data['fa-icon']), // this has to be sanitised beforehand!
empty($data['fa-icon']) ? '' : sprintf('<i class="fa fa-%s"></i> ', $data['fa-icon']), // this has to be sanitised beforehand!
empty($data['html']) ? '' : $data['html'], // this has to be sanitised beforehand!
empty($data['text']) ? '' : h($data['text'])
);

View File

@ -1,14 +1,19 @@
<?php
if (!isset($data['requirement']) || $data['requirement']) {
$button = empty($data['button']) ? '' : sprintf(
'<button class=" btn btn-small btn-inverse" %s id="quickFilterButton">%s</button>',
$button = empty($data['button']) && empty($data['fa-icon']) ? '' : sprintf(
'<button class=" btn btn-small btn-inverse" %s id="quickFilterButton">%s%s</button>',
empty($data['data']) ? '' : h($data['data']),
h($data['button'])
empty($data['fa-icon']) ? '' : sprintf('<i class="fa fa-%s"></i>', h($data['fa-icon'])),
empty($data['button']) ? '' : h($data['button'])
);
if (!empty($data['cancel'])) {
$button .= $this->element('/genericElements/ListTopBar/element_simple', array('data' => $data['cancel']));
}
$input = sprintf(
'<input type="text" class="span3 input-small" placeholder="%s" aria-label="%s" style="padding: 2px 6px;" id="quickFilterField">',
'<input type="text" class="span3 input-small" placeholder="%s" aria-label="%s" style="padding: 2px 6px;" id="%s">',
empty($data['placeholder']) ? '' : h($data['placeholder']),
empty($data['placeholder']) ? '' : h($data['placeholder'])
empty($data['placeholder']) ? '' : h($data['placeholder']),
empty($data['id']) ? 'quickFilterField' : h($data['id'])
);
echo sprintf(
'<div class="btn-group pull-right"><div class="input-append" style="margin-bottom:0px;">%s%s</div></div>',

View File

@ -100,13 +100,6 @@
if (!$ajax) {
echo $this->element('/genericElements/ListTopBar/scaffold', array('data' => $data));
}
$tab = "Center";
if (!isset($simple)) $simple = false;
$filtered = false;
if (!$simple && count($passedArgsArray) > 0) {
$tab = "Left";
$filtered = true;
}
echo $this->element('Events/eventIndexTable');
?>
<p>

View File

@ -2974,11 +2974,11 @@ function syncUserSelected() {
function filterAttributes(filter, id) {
url = "/events/viewEventAttributes/" + id + "/attributeFilter:" + filter;
if(filter === 'value'){
filter = $('#attributesFilterField').val().trim();
filter = $('#quickFilterField').val().trim();
url += filter.length > 0 ? "/searchFor:" + filter : "";
} else if(filter !== 'all') {
url += "/filterColumnsOverwrite:" + filter;
filter = $('#attributesFilterField').val().trim();
filter = $('#quickFilterField').val().trim();
url += filter.length > 0 ? "/searchFor:" + filter : "";
}
if (deleted) url += '/deleted:true';