chg: [UI] Use choosen for tag select

pull/7228/head
Jakub Onderka 2021-03-20 20:02:00 +01:00
parent 2576891504
commit ac86b5f455
3 changed files with 22 additions and 77 deletions

View File

@ -1000,19 +1000,21 @@ class EventsController extends AppController
}
}
$this->set('filtering', json_encode($filtering));
$tagNames = $this->Event->EventTag->Tag->find('list', array('recursive' => -1, 'fields' => ['Tag.id', 'Tag.name']));
$tagJSON = array();
$tagNames = $this->Event->EventTag->Tag->find('list', [
'fields' => ['Tag.id', 'Tag.name'],
]);
$tagJSON = [];
foreach ($tagNames as $tagId => $tagName) {
$tagJSON[] = array('id' => $tagId, 'value' => h($tagName));
$tagJSON[] = array('id' => $tagId, 'value' => $tagName);
}
$rules = array('published', 'eventid', 'tag', 'date', 'eventinfo', 'threatlevel', 'distribution', 'sharinggroup', 'analysis', 'attribute', 'hasproposal');
if ($this->_isSiteAdmin()) {
$rules[] = 'email';
}
if (Configure::read('MISP.showorg')) {
$orgs = $this->Event->Orgc->find('list', array(
'conditions' => array(),
'recursive' => -1,
'fields' => array('Orgc.id', 'Orgc.name'),
'sort' => array('lower(Orgc.name) asc')
));

View File

@ -53,7 +53,7 @@
'options' => $sharingGroups,
'class' => 'input',
'label' => false,
'style' => 'display:none;width:438px;',
'style' => 'width:438px;',
'div' => false
));
if ($showorg) {
@ -61,19 +61,18 @@
'options' => $orgs,
'class' => 'input',
'label' => false,
'style' => 'display:none;width:438px;',
'style' => 'width:438px;',
'div' => false
));
}
echo $this->Form->input('searchtag', array(
'options' => array($tags),
'options' => $tags,
'class' => 'input',
'label' => false,
'style' => 'display:none;width:438px;',
'style' => 'width:438px',
'div' => false
));
echo $this->Form->input('searchdatefrom', array(
'div' => 'input clear',
'class' => 'datepicker',
'data-date-format' => 'yyyy-mm-dd',
'label' => false,
@ -230,10 +229,12 @@ if (isSiteAdmin == 1) {
var baseurl = "<?php echo $baseurl; ?>";
$(document).ready(function() {
$(function() {
$('.datepicker').datepicker().on('changeDate', function(ev) {
$('.dropdown-menu').hide();
});
$('#EventSearchtag, #EventSearchorg, #EventSearchsharinggroup').chosen();
$('#EventSearchtag_chosen, #EventSearchorg_chosen, #EventSearchsharinggroup_chosen').css('top', '-5px');
indexEvaluateFiltering();
});

View File

@ -2326,7 +2326,7 @@ function indexSetRowVisibility() {
}
function indexEvaluateSimpleFiltering(field) {
text = "";
var text = "";
if (filtering[field].OR.length == 0 && filtering[field].NOT.length == 0) {
$('#value_' + field).html(text);
return false;
@ -2411,19 +2411,21 @@ function indexRuleChange() {
$('[id^=' + context + 'Search]').hide();
var rule = $('#' + context + 'Rule').val();
var fieldName = '#' + context + 'Search' + rule;
if (fieldName == '#' + context + 'Searchdate') {
if (fieldName === '#' + context + 'Searchdate') {
$(fieldName + 'from').show();
$(fieldName + 'until').show();
} else {
$(fieldName).show();
if ($(fieldName + '_chosen').length) {
$(fieldName + '_chosen').show();
} else {
$(fieldName).show();
}
}
if (simpleFilters.indexOf(rule) != -1) {
$('#' + context + 'Searchbool').show();
} else $('#' + context + 'Searchbool').hide();
$('#addRuleButton').show();
$('#addRuleButton').unbind("click");
$('#addRuleButton').click({param1: rule}, indexAddRule);
$('#addRuleButton').show().unbind("click").click({param1: rule}, indexAddRule);
}
function indexFilterClearRow(field) {
@ -2446,66 +2448,6 @@ function indexFilterClearRow(field) {
indexEvaluateFiltering();
}
function restrictEventViewPagination() {
var showPages = new Array();
var start;
var end;
var i;
if (page < 6) {
start = 1;
if (count - page < 6) {
end = count;
} else {
end = page + (9 - (page - start));
}
} else if (count - page < 6) {
end = count;
start = count - 10;
} else {
start = page-5;
end = page+5;
}
if (start > 2) {
$("#apage" + start).parent().before("<li><a href id='aExpandLeft'>...</a></li>");
$("#aExpandLeft").click(function() {expandPagination(0, 0); return false;});
$("#bpage" + start).parent().before("<li><a href id='bExpandLeft'>...</a></li>");
$("#bExpandLeft").click(function() {expandPagination(1, 0); return false;})
}
if (end < (count - 1)) {
$("#apage" + end).parent().after("<li><a href id='aExpandRight'>...</a></li>");
$("#aExpandRight").click(function() {expandPagination(0, 1); return false;});
$("#bpage" + end).parent().after("<li><a href id='bExpandRight'>...</a></li>");
$("#bExpandRight").click(function() {expandPagination(1, 1); return false;})
}
for (i = 1; i < (count+1); i++) {
if (i != 1 && i != count && (i < start || i > end)) {
$("#apage" + i).hide();
$("#bpage" + i).hide();
}
}
}
function expandPagination(bottom, right) {
var i;
var prefix = "a";
if (bottom == 1) prefix = "b";
var start = 1;
var end = page;
if (right == 1) {
start = page;
end = count;
$("#" + prefix + "ExpandRight").remove();
} else $("#" + prefix + "ExpandLeft").remove();
for (i = start; i < end; i++) {
$("#" + prefix + "page" + i).show();
}
}
function getSubGroupFromSetting(setting) {
var temp = setting.split('.');
if (temp[0] == "Plugin") {