Merge pull request #8248 from JakubOnderka/fix-ui-typo

fix: [UI] Typo
pull/8250/head
Jakub Onderka 2022-03-30 09:33:01 +02:00 committed by GitHub
commit 4065642667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 76 additions and 122 deletions

View File

@ -320,9 +320,6 @@ echo $this->element('/genericElements/SideMenu/side_menu', ['menuList' => 'event
$('.screenshot').click(function() {
screenshotPopup($(this).attr('src'), $(this).attr('title'));
});
$('.addGalaxy').click(function() {
addGalaxyListener(this);
});
$('.sightings_advanced_add').click(function() {
var selected = [];
var object_context = $(this).data('object-context');

View File

@ -32,7 +32,7 @@ if (!empty($k)) {
$tr_class .= ' row_' . h($k);
}
$objectId = h($object['id']);
$objectId = (int) $object['id'];
$quickEdit = function($fieldName) use ($editScope, $object, $event) {
if ($object['deleted']) {
@ -143,9 +143,8 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
</td>
<td class="short">
<div class="attributeTagContainer">
<?php echo $this->element(
'ajaxTags',
array('attributeId' => $object['id'],
<?php echo $this->element('ajaxTags', array(
'attributeId' => $objectId,
'tags' => $object['AttributeTag'],
'tagAccess' => ($isSiteAdmin || $mayModify),
'localTagAccess' => ($isSiteAdmin || $mayModify || $me['org_id'] == $event['Event']['org_id'] || (int)$me['org_id'] === Configure::read('MISP.host_org_id')),
@ -160,7 +159,7 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
if (!empty($includeRelatedTags)) {
$element = '';
if (!empty($object['RelatedTags'])) {
$element = $this->element('ajaxAttributeTags', array('attributeId' => $object['id'], 'attributeTags' => $object['RelatedTags'], 'tagAccess' => false));
$element = $this->element('ajaxAttributeTags', array('attributeId' => $objectId, 'attributeTags' => $object['RelatedTags'], 'tagAccess' => false));
}
echo sprintf(
'<td class="shortish"><div %s>%s</div></td>',
@ -169,15 +168,14 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
);
}
?>
<?php $rowId = sprintf('attribute_%s_galaxy', h($objectId)); ?>
<td class="short" id="<?= $rowId ?>">
<td class="short" id="attribute_<?= $objectId ?>_galaxy">
<?php
echo $this->element('galaxyQuickViewNew', array(
'mayModify' => $mayModify,
'isAclTagger' => $isAclTagger,
'data' => (!empty($object['Galaxy']) ? $object['Galaxy'] : array()),
'event' => $event,
'target_id' => $object['id'],
'target_id' => $objectId,
'target_type' => 'attribute',
));
?>
@ -204,7 +202,7 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
</td>
<td class="shortish">
<?php
if (!empty($event['RelatedAttribute'][$object['id']])) {
if (!empty($event['RelatedAttribute'][$objectId])) {
echo '<ul class="inline" style="margin:0">';
echo $this->element('Events/View/attribute_correlations', array(
'scope' => 'Attribute',
@ -354,25 +352,25 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
if ($object['deleted']):
if ($isSiteAdmin || $mayModify):
?>
<span class="fas fa-redo useCursorPointer" title="<?php echo __('Restore attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Restore attribute');?>" onClick="deleteObject('attributes', 'restore', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Permanently delete attribute');?>" role="button" tabindex="0" aria-label="i<?php echo __('Permanently delete attribute');?>" onClick="deleteObject('attributes', 'delete', '<?= $objectId . '/true'; ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fas fa-redo useCursorPointer" title="<?php echo __('Restore attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Restore attribute');?>" onclick="deleteObject('attributes', 'restore', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Permanently delete attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Permanently delete attribute');?>" onclick="deleteObject('attributes', 'delete', '<?= $objectId . '/true'; ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<?php
endif;
else:
if ($isAclAdd && ($isSiteAdmin || !$mayModify)):
if (isset($modules) && isset($modules['types'][$object['type']])):
?>
<span class="fas fa-asterisk useCursorPointer" role="button" tabindex="0" aria-label="<?php echo __('Query enrichment');?>" onClick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/ShadowAttribute');" title="<?php echo __('Propose enrichment');?>">&nbsp;</span>
<span class="fas fa-asterisk useCursorPointer" role="button" tabindex="0" aria-label="<?php echo __('Query enrichment');?>" onclick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/ShadowAttribute');" title="<?php echo __('Propose enrichment');?>">&nbsp;</span>
<?php
endif;
if (isset($cortex_modules) && isset($cortex_modules['types'][$object['type']])):
?>
<span class="icon-eye-open useCursorPointer" title="<?php echo __('Query Cortex');?>" role="button" tabindex="0" aria-label="<?php echo __('Query Cortex');?>" onClick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/ShadowAttribute/Cortex');" title="<?php echo __('Propose enrichment through Cortex');?>"></span>
<span class="icon-eye-open useCursorPointer" role="button" tabindex="0" aria-label="<?php echo __('Query Cortex');?>" onclick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/ShadowAttribute/Cortex');" title="<?php echo __('Propose enrichment through Cortex');?>"></span>
<?php
endif;
?>
<a href="<?php echo $baseurl;?>/shadow_attributes/edit/<?= $objectId ?>" title="<?php echo __('Propose Edit');?>" aria-label="<?php echo __('Propose Edit');?>" class="fa fa-comment useCursorPointer"></a>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Propose Deletion');?>" role="button" tabindex="0" aria-label="Propose deletion" onClick="deleteObject('shadow_attributes', 'delete', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Propose Deletion');?>" role="button" tabindex="0" aria-label="Propose deletion" onclick="deleteObject('shadow_attributes', 'delete', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<?php
if ($isSiteAdmin):
?>
@ -382,12 +380,12 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
if ($isSiteAdmin || $mayModify):
if (isset($modules) && isset($modules['types'][$object['type']])):
?>
<span class="fas fa-asterisk useCursorPointer" onClick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/Attribute');" title="<?php echo __('Add enrichment');?>" role="button" tabindex="0" aria-label="<?php echo __('Add enrichment');?>">&nbsp;</span>
<span class="fas fa-asterisk useCursorPointer" onclick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/Attribute');" title="<?php echo __('Add enrichment');?>" role="button" tabindex="0" aria-label="<?php echo __('Add enrichment');?>">&nbsp;</span>
<?php
endif;
if (isset($cortex_modules) && isset($cortex_modules['types'][$object['type']])):
?>
<span class="icon-eye-open useCursorPointer" onClick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/Attribute/Cortex');" title="<?php echo __('Add enrichment');?>" role="button" tabindex="0" aria-label="<?php echo __('Add enrichment via Cortex');?>"></span>
<span class="icon-eye-open useCursorPointer" onclick="simplePopup('<?php echo $baseurl;?>/events/queryEnrichment/<?= $objectId ?>/Attribute/Cortex');" title="<?php echo __('Add enrichment');?>" role="button" tabindex="0" aria-label="<?php echo __('Add enrichment via Cortex');?>"></span>
<?php
endif;
?>
@ -395,11 +393,11 @@ $quickEdit = function($fieldName) use ($editScope, $object, $event) {
<?php
if (empty($event['Event']['publish_timestamp'])):
?>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Permanently delete attribute');?>" role="button" tabindex="0" aria-label="i<?php echo __('Permanently delete attribute');?>" onClick="deleteObject('attributes', 'delete', '<?= $objectId . '/true'; ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Permanently delete attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Permanently delete attribute');?>" onclick="deleteObject('attributes', 'delete', '<?= $objectId . '/true'; ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<?php
else:
?>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Soft-delete attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Soft-delete attribute');?>" onClick="deleteObject('attributes', 'delete', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Soft-delete attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Soft-delete attribute');?>" onclick="deleteObject('attributes', 'delete', '<?= $objectId ?>', '<?php echo h($event['Event']['id']); ?>');"></span>
<?php
endif;
endif;

View File

@ -161,5 +161,5 @@
'child' => $attrKey == $lastElement ? 'last' : true
));
}
echo '<tr class="objectAddFieldTr"><td><span class="fa fa-plus-circle objectAddField" title="' . __('Add an Object Attribute') .'" onclick="popoverPopup(this, ' . h($object['id']) . ', \'objects\', \'quickFetchTemplateWithValidObjectAttributes\')"></span></td></tr>';
echo '<tr class="objectAddFieldTr"><td><span class="fa fa-plus-circle objectAddField" title="' . __('Add an Object Attribute') .'" data-popover-popup="' . $baseurl . '/objects/quickFetchTemplateWithValidObjectAttributes/' . h($object['id']) .'"></span></td></tr>';
}

View File

@ -25,9 +25,10 @@
<?php
$addTagButton = '&nbsp;';
if ($full) {
$url = $baseurl . '/tags/selectTaxonomy/' . h($tagCollection['TagCollection']['id']) . '/tag_collection';
$addTagButton = sprintf(
'<button id="addTagButton" class="btn btn-inverse noPrint" style="line-height:10px; padding: 2px;" onClick="popoverPopup(this, %s);"><i class="fas fa-globe-americas"></i> +</button>',
sprintf("'%s/tag_collection', 'tags', 'selectTaxonomy'", h($tagCollection['TagCollection']['id']))
'<button id="addTagButton" class="btn addButton btn-inverse noPrint" data-popover-popup="%s"><i class="fas fa-globe-americas"></i> <i class="fas fa-plus"></i></button>',
$url
);
}
echo $addTagButton;

View File

@ -88,7 +88,7 @@
$span_delete = '';
if ($full || ($fullLocal && $tag['Tag']['local'])) {
$span_delete = sprintf(
'<span class="%s" title="%s" role="%s" tabindex="%s" aria-label="%s" onClick="%s">x</span>',
'<span class="%s" title="%s" role="%s" tabindex="%s" aria-label="%s" onclick="%s">x</span>',
'black-white tag useCursorPointer noPrint',
__('Remove tag'),
"button",
@ -107,43 +107,26 @@
$buttonData = array();
if ($full) {
$buttonData[] = sprintf(
'<button title="%s" role="button" tabindex="0" aria-label="%s" class="%s" style="%s" onClick="%s">%s</button>',
'<button title="%s" role="button" tabindex="0" aria-label="%s" class="%s" data-popover-popup="%s">%s</button>',
__('Add a tag'),
__('Add a tag'),
'addTagButton btn btn-inverse noPrint',
'line-height:10px; padding: 2px;',
sprintf(
"popoverPopup(this, '%s%s', '%s', '%s');",
$id,
($scope === 'event') ? '' : ('/' . $scope),
'tags',
'selectTaxonomy'
),
'<i class="fas fa-globe-americas"></i> +'
'addTagButton addButton btn btn-inverse noPrint',
$baseurl . '/tags/selectTaxonomy/' . $id . ($scope === 'event' ? '' : ('/' . $scope)),
'<i class="fas fa-globe-americas"></i> <i class="fas fa-plus"></i>'
);
}
if ($full || $fullLocal) {
$buttonData[] = sprintf(
'<button title="%s" role="button" tabindex="0" aria-label="%s" class="%s" style="%s" onClick="%s">%s</button>',
'<button title="%s" role="button" tabindex="0" aria-label="%s" class="%s" data-popover-popup="%s">%s</button>',
__('Add a local tag'),
__('Add a local tag'),
'addLocalTagButton btn btn-inverse noPrint',
'line-height:10px; padding: 2px;',
sprintf(
"popoverPopup(this, '%s%s', '%s', '%s')",
$id,
($scope === 'event') ? '' : ('/' . $scope),
'tags',
'selectTaxonomy/local:1'
),
'<i class="fas fa-user"></i> +'
'addLocalTagButton addButton btn btn-inverse noPrint',
$baseurl . '/tags/selectTaxonomy/local:1/' . $id . ($scope === 'event' ? '' : ('/' . $scope)),
'<i class="fas fa-user"></i> <i class="fas fa-plus"></i>'
);
}
if (!empty($buttonData)) {
$tagData .= sprintf(
'<span style="white-space:nowrap;">%s</span>',
implode(' ', $buttonData)
);
$tagData .= implode('', $buttonData);
}
echo sprintf(
'<span class="tag-list-container">%s</span>',
@ -156,11 +139,11 @@
$tagConflictData .= '<div class="text-container">';
foreach ($tagConflicts['global'] as $tagConflict) {
$tagConflictData .= sprintf(
'<strong>%s</strong></br>',
'<strong>%s</strong><br>',
h($tagConflict['conflict'])
);
foreach ($tagConflict['tags'] as $tag) {
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span></br>', h($tag));
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
}
}
$tagConflictData .= '</div></div></span>';
@ -171,14 +154,13 @@
$tagConflictData .= '<div class="text-container">';
foreach ($tagConflicts['local'] as $tagConflict) {
$tagConflictData .= sprintf(
'<strong>%s</strong></br>',
'<strong>%s</strong><br>',
h($tagConflict['conflict'])
);
foreach ($tagConflict['tags'] as $tag) {
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span></br>', h($tag));
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span><br>', h($tag));
}
}
$tagConflictData .= '</div></div></span>';
}
echo $tagConflictData;
?>

View File

@ -227,9 +227,6 @@ attributes or the appropriate distribution level. If you think there is a mistak
var deleted = <?php echo (!empty($deleted)) ? '1' : '0';?>;
var includeRelatedTags = <?php echo (!empty($includeRelatedTags)) ? '1' : '0';?>;
$(function() {
$('.addGalaxy').click(function() {
addGalaxyListener(this);
});
<?php
if (isset($focus)):
?>

View File

@ -71,8 +71,9 @@
'title' => __('Tag selected Attributes'),
'class' => 'mass-select hidden',
'fa-icon' => 'tag',
'onClick' => 'popoverPopup',
'onClickParams' => array('this', 'selected/attribute', 'tags', 'selectTaxonomy')
'data' => [
'popover-popup' => $baseurl . '/tags/selectTaxonomy/selected/attribute',
],
),
array(
'id' => 'multi-galaxy-button',
@ -80,8 +81,9 @@
'class' => 'mass-select hidden',
'fa-icon' => 'rebel',
'fa-source' => 'fab',
'onClick' => 'popoverPopup',
'onClickParams' => array('this', 'selected/attribute/eventid:' . $eventId, 'galaxies', 'selectGalaxyNamespace')
'data' => [
'popover-popup' => $baseurl . '/galaxies/selectGalaxyNamespace/selected/attribute/eventid:' . $eventId,
],
),
array(
'id' => 'group-into-object-button',

View File

@ -123,21 +123,21 @@ echo $this->Form->end();
<?php endif; ?>
<?php
if ($editButtonsEnabled) {
$link = "$baseurl/galaxies/selectGalaxyNamespace/" . h($target_id) . "/" . h($target_type) . "/local:0";
echo sprintf(
'<button class="%s" data-target-type="%s" data-target-id="%s" data-local="false" role="button" tabindex="0" aria-label="' . __('Add new cluster') . '" title="' . __('Add new cluster') . '">%s</button>',
'useCursorPointer btn btn-inverse addGalaxy',
h($target_type),
h($target_id),
'<button class="%s" data-popover-popup="%s" role="button" tabindex="0" aria-label="' . __('Add new cluster') . '" title="' . __('Add new cluster') . '">%s</button>',
'useCursorPointer addButton btn btn-inverse',
$link,
'<i class="fas fa-globe-americas"></i> <i class="fas fa-plus"></i>'
);
}
if ($editButtonsLocalEnabled) {
$link = "$baseurl/galaxies/selectGalaxyNamespace/" . h($target_id) . "/" . h($target_type) . "/local:1";
echo sprintf(
'<button class="%s" data-target-type="%s" data-target-id="%s" data-local="true" role="button" tabindex="0" aria-label="' . __('Add new local cluster') . '" title="' . __('Add new local cluster') . '">%s</button>',
'useCursorPointer btn btn-inverse addGalaxy',
h($target_type),
h($target_id),
'<button class="%s" data-popover-popup="%s" role="button" tabindex="0" aria-label="' . __('Add new local cluster') . '" title="' . __('Add new local cluster') . '">%s</button>',
'useCursorPointer addButton btn btn-inverse',
$link,
'<i class="fas fa-user"></i> <i class="fas fa-plus"></i>'
);
}

View File

@ -14,9 +14,4 @@ echo $this->element('galaxyQuickViewNew', [
?>
<script type="text/javascript">
var showContext = false;
$(function () {
$('.addGalaxy').click(function() {
addGalaxyListener(this);
});
});
</script>

View File

@ -1,11 +1,3 @@
<?php
echo $this->element('TagCollections/index_row');
?>
<script type="text/javascript">
$(document).ready(function() {
$('.addGalaxy').click(function() {
addGalaxyListener(this);
});
});
</script>

View File

@ -19,11 +19,4 @@
));
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'tag-collections', 'menuItem' => 'index'));
?>
<script type="text/javascript">
$(document).ready(function() {
$('.addGalaxy').click(function() {
addGalaxyListener(this);
});
});
</script>

View File

@ -2056,14 +2056,14 @@ a.discrete {
font-size: 12px;
}
button.addGalaxy {
button.addButton {
line-height: 10px;
padding: 2px;
margin-right: 5px;
margin-top: 1px;
}
button.addGalaxy .fa-plus {
button.addButton .fa-plus {
font-size: 11px;
line-height: 13px;
}

View File

@ -73,10 +73,7 @@ function xhr(options) {
function deleteObject(type, action, id) {
var url = baseurl + "/" + type + "/" + action + "/" + id;
$.get(url, function(data) {
openPopup("#confirmation_box");
$("#confirmation_box").html(data);
}).fail(xhrFailCallback)
$.get(url, openConfirmation).fail(xhrFailCallback)
}
function quickDeleteSighting(id, rawId, context) {
@ -1805,6 +1802,7 @@ function getPopup(id, context, target, admin, popupType) {
}
// Same as getPopup function but create a popover to populate first
// DEPRECATED
function popoverPopup(clicked, id, context, target, admin) {
var url = baseurl;
if (typeof admin !== 'undefined' && admin != '') url+= "/admin";
@ -1813,20 +1811,24 @@ function popoverPopup(clicked, id, context, target, admin) {
}
if (target != '') url += "/" + target;
if (id != '') url += "/" + id;
var popover = openPopover(clicked, undefined);
$clicked = $(clicked);
popoverPopupNew(clicked, url);
}
function popoverPopupNew(clicked, url) {
var $clicked = $(clicked);
var popover = openPopover($clicked, undefined);
// actual request //
$.ajax({
dataType:"html",
dataType: "html",
cache: false,
success:function (data) {
success: function (data) {
if (popover.options.content !== data) {
popover.options.content = data;
popover.options.content = data;
$clicked.popover('show');
}
},
error:function(jqXHR ) {
error: function(jqXHR) {
var errorJSON = '';
try {
errorJSON = JSON.parse(jqXHR.responseText);
@ -1903,12 +1905,13 @@ function simplePopup(url, requestType, data) {
data = data === undefined ? [] : data
$("#gray_out").fadeIn();
xhr({
dataType:"html",
success:function (data) {
$("#popover_form").html(data);
openPopup("#popover_form");
dataType: "html",
success: function (data) {
var $popover = $("#popover_form");
$popover.html(data);
openPopup($popover);
},
error:function(xhr) {
error: function(xhr) {
$("#gray_out").fadeOut();
xhrFailCallback(xhr);
},
@ -4223,18 +4226,6 @@ $('#eventToggleButtons button').click(function() {
}
});
function addGalaxyListener(id) {
var target_type = $(id).data('target-type');
var target_id = $(id).data('target-id');
var local = $(id).data('local');
if (local) {
local = 1;
} else {
local = 0;
}
popoverPopup(id, target_id + '/' + target_type + '/local:' + local, 'galaxies', 'selectGalaxyNamespace');
}
function quickSubmitGalaxyForm(cluster_ids, additionalData) {
cluster_ids = cluster_ids === null ? [] : cluster_ids;
var target_id = additionalData['target_id'];
@ -4775,12 +4766,18 @@ $(document.body).on('click', 'a[data-paginator]', function (e) {
});
});
// Any link with modal-open class will be treated as generic modal
// Any link with `modal-open` class will be treated as generic modal
$(document.body).on('click', 'a.modal-open', function (e) {
e.preventDefault();
openGenericModal($(this).attr('href'));
});
$(document.body).on('click', '[data-popover-popup]', function (e) {
e.preventDefault();
var url = $(this).data('popover-popup');
popoverPopupNew(this, url);
});
function queryEventLock(event_id, timestamp) {
if (!document.hidden) {
$.ajax({