mirror of https://github.com/MISP/MISP
new: Automatic cateory switching based on currently selected types for the freetext import/module triage screen
parent
12604debd5
commit
23adc990b9
|
@ -3353,6 +3353,10 @@ class EventsController extends AppController {
|
|||
$this->set('typeList', array_keys($this->Event->Attribute->typeDefinitions));
|
||||
$this->set('defaultCategories', $this->Event->Attribute->defaultCategories);
|
||||
$this->set('typeCategoryMapping', $typeCategoryMapping);
|
||||
foreach ($typeCategoryMapping as $k => $v) {
|
||||
$typeCategoryMapping[$k] = array_values($v);
|
||||
}
|
||||
$this->set('mapping', $typeCategoryMapping);
|
||||
$this->set('resultArray', $resultArray);
|
||||
$this->set('importComment', '');
|
||||
$this->set('title', 'Freetext Import Results');
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<td class="short context hidden">
|
||||
<?php echo h($object['uuid']); ?>
|
||||
</td>
|
||||
<td colspan="<?php echo $fieldCount; ?>" style="font-weight:bold;text-align:left;width:100%;">DELETE</td>
|
||||
<td colspan="<?php echo $fieldCount+2; ?>" style="font-weight:bold;text-align:left;width:100%;">DELETE</td>
|
||||
<td class="short action-links">
|
||||
<?php
|
||||
if (($event['Orgc']['id'] == $me['org_id'] && $mayModify) || $isSiteAdmin) {
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
|
||||
}
|
||||
?>
|
||||
<select id="<?php echo 'Attribute' . $k . 'Category'; ?>" style='padding:0px;height:20px;margin-bottom:0px;'>
|
||||
<select id="<?php echo 'Attribute' . $k . 'Category'; ?>" style='padding:0px;height:20px;margin-bottom:0px;' class="categoryToggle">
|
||||
<?php
|
||||
foreach ($typeCategoryMapping[$item['default_type']] as $category) {
|
||||
if (isset($item['categories']) && !in_array($category, $item['categories'])) {
|
||||
|
@ -231,8 +231,34 @@
|
|||
</div>
|
||||
<script>
|
||||
var options = <?php echo json_encode($optionsRearranged);?>;
|
||||
var typeCategoryMapping = <?php echo json_encode($typeCategoryMapping); ?>;
|
||||
$(document).ready(function() {
|
||||
popoverStartup();
|
||||
$('.typeToggle').on('change', function() {
|
||||
var currentId = $(this).attr('id');
|
||||
var selected = $(this).val();
|
||||
currentId = currentId.replace('Type', 'Category');
|
||||
var currentOptions = typeCategoryMapping[selected];
|
||||
/*
|
||||
// Coming soon - restrict further if a list of categories is passed by the modules / freetext import tool
|
||||
if ($('#' + currentId)).data('category-restrictions') {
|
||||
var category_restrictions = $('#' + currentId)).data('category-restrictions');
|
||||
currentOptions.forEach(function(category) {
|
||||
var found = False;
|
||||
category_restrictions.forEach(function(restricted_category) {
|
||||
|
||||
});
|
||||
});
|
||||
currentOptions.forEach() {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
$('#' + currentId).empty();
|
||||
for (var category in currentOptions) {
|
||||
$('#' + currentId).append($("<option></option>").attr("value", category).text(category));
|
||||
}
|
||||
});
|
||||
<?php
|
||||
if (!empty($optionsRearranged)):
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue