diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php
index 2d53e90e8..823b0b15d 100644
--- a/app/Controller/GalaxiesController.php
+++ b/app/Controller/GalaxiesController.php
@@ -358,7 +358,7 @@ class GalaxiesController extends AppController
$local = !empty($this->params['named']['local']) ? $this->params['named']['local'] : '0';
$data = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(), array(
'conditions' => $conditions,
- 'fields' => array('value', 'description', 'source', 'type', 'id'),
+ 'fields' => array('value', 'description', 'source', 'type', 'id', 'uuid'),
'order' => array('value asc'),
), false);
$clusters = array();
@@ -411,6 +411,9 @@ class GalaxiesController extends AppController
'template' => array(
'name' => $name,
'infoExtra' => $cluster['description'],
+ ),
+ 'additionalData' => array(
+ 'uuid' => $cluster['uuid']
)
);
if ($cluster['synonyms_string'] !== '') {
@@ -427,7 +430,7 @@ class GalaxiesController extends AppController
$this->set('items', $items);
$this->set('options', array( // set chosen (select picker) options
'functionName' => $onClickForm,
- 'multiple' => '-1',
+ 'multiple' => $target_type == 'galaxyClusterRelation' ? 0 : '-1',
'select_options' => array(
'additionalData' => array(
'target_id' => $target_id,
diff --git a/app/Controller/TagsController.php b/app/Controller/TagsController.php
index b7178adc6..0dc730e45 100644
--- a/app/Controller/TagsController.php
+++ b/app/Controller/TagsController.php
@@ -784,6 +784,9 @@ class TagsController extends AppController
)
),
'infoExtra' => $expanded[$tag['id']]
+ ),
+ 'additionalData' => array(
+ 'tag_name' => $tagName
)
);
if ($taxonomy_id === 'collections') {
diff --git a/app/View/Elements/generic_picker.ctp b/app/View/Elements/generic_picker.ctp
index e5c121af4..c3b2fe6f2 100644
--- a/app/View/Elements/generic_picker.ctp
+++ b/app/View/Elements/generic_picker.ctp
@@ -194,11 +194,20 @@ function submitFunction(clicked, callback) {
} else {
additionalData = {};
}
- additionalDataOption = options_additionalData[$select.attr('id')][selected];
+ additionalDataOption = options_additionalData[$select.attr('id')];
if (additionalData !== undefined) {
- $.extend(additionalData, additionalDataOption);
- execAndClose(clicked);
- callback(selected, additionalData);
+ additionalData['itemOptions'] = additionalDataOption;
+ // check needed if the function name is not defined in the controller but in the JS
+ var dismissId = $clicked.closest('.popover[data-dismissid]').data('dismissid');
+ var callingButton = $('button[data-dismissid="' + dismissId + '"]');
+ if (callingButton.data('popover-no-submit') && callingButton.data('popover-callback-function') !== undefined) {
+ callbackFunction = callingButton.data('popover-callback-function');
+ execAndClose(clicked);
+ callbackFunction(selected, additionalData);
+ } else {
+ execAndClose(clicked);
+ callback(selected, additionalData);
+ }
}
}
diff --git a/app/View/GalaxyClusterRelations/add.ctp b/app/View/GalaxyClusterRelations/add.ctp
index d9bc9e35c..6cb7238dc 100644
--- a/app/View/GalaxyClusterRelations/add.ctp
+++ b/app/View/GalaxyClusterRelations/add.ctp
@@ -25,7 +25,9 @@
'field' => 'referenced_galaxy_cluster_uuid',
'label' => __('Target UUID'),
'type' => 'text',
+ 'stayInLine' => 1
),
+ sprintf('', __('Pick target cluster')),
array(
'field' => 'referenced_galaxy_cluster_type',
'label' => __('Relationship Type'),
@@ -35,8 +37,10 @@
'field' => 'tags',
'label' => __('Tag list'),
'type' => 'textarea',
- 'placeholder' => 'estimative-language:likelihood-probability="very-likely", false-positive:risk="low"'
+ 'placeholder' => 'estimative-language:likelihood-probability="very-likely", false-positive:risk="low"',
+ 'stayInLine' => 1
),
+ sprintf('', __('Pick tags')),
),
'submit' => array(
'ajaxSubmit' => ''
@@ -57,6 +61,31 @@
$(this).attr('data-toggle', '')
.html(syntaxHighlightJson($(this).text().trim()));
});
+ $('#btnPickTarget').click(function() {
+ $(this).data('popover-no-submit', true);
+ $(this).data('popover-callback-function', setTargetUUIDAfterSelect);
+ var target_id = 0;
+ var target_type = 'galaxyClusterRelation';
+ popoverPopup(this, target_id + '/' + target_type, 'galaxies', 'selectGalaxyNamespace');
+ });
+ $('#btnPickTag').click(function() {
+ $(this).data('popover-no-submit', true);
+ $(this).data('popover-callback-function', setTagsAfterSelect);
+ var target_id = 0;
+ var target_type = 'galaxyClusterRelation';
+ popoverPopup(this, target_id + '/' + target_type, 'tags', 'selectTaxonomy')
+ });
});
+ function setTargetUUIDAfterSelect(selected, additionalData){
+ selectedUUID = additionalData.itemOptions[selected].uuid;
+ $('#GalaxyClusterRelationReferencedGalaxyClusterUuid').val(selectedUUID);
+ }
+ function setTagsAfterSelect(selected, additionalData){
+ selectedTags = [];
+ selected.forEach(function(selection) {
+ selectedTags.push(additionalData.itemOptions[selection].tag_name);
+ });
+ $('#GalaxyClusterRelationTags').val(selectedTags.join(', '));
+ }
Js->writeBuffer(); // Write cached scripts
\ No newline at end of file
diff --git a/app/webroot/js/misp.js b/app/webroot/js/misp.js
index b64f372ea..3647a22c5 100644
--- a/app/webroot/js/misp.js
+++ b/app/webroot/js/misp.js
@@ -4138,7 +4138,6 @@ function addGalaxyListener(id) {
var target_type = $(id).data('target-type');
var target_id = $(id).data('target-id');
var local = $(id).data('local');
- console.log(local);
if (local) {
local = 1;
} else {