chg: [galaxyClusterRelations:add] Added picker for relation type

pull/6628/head
mokaddem 2020-11-19 18:48:57 +01:00
parent 3fe41cd22d
commit fb479d4b72
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 27 additions and 0 deletions

View File

@ -174,6 +174,8 @@ class GalaxyClusterRelationsController extends AppController
}
}
}
$existingRelations = $this->GalaxyClusterRelation->getExistingRelationships();
$this->set('existingRelations', $existingRelations);
$this->set('distributionLevels', $distributionLevels);
$this->set('initialDistribution', $initialDistribution);
$this->set('sharingGroups', $sgs);

View File

@ -41,6 +41,10 @@
'label' => __('Relationship Type'),
'placeholder' => __('is-similar'),
'type' => 'text',
'picker' => array(
'text' => __('Pick type'),
'function' => 'pickerTypes',
)
),
array(
'field' => 'tags',
@ -67,6 +71,8 @@
checkSharingGroup('GalaxyClusterRelation');
});
existingRelationTypes = <?= json_encode(array_values($existingRelations)) ?> ;
$(document).ready(function() {
checkSharingGroup('GalaxyClusterRelation');
$('[data-toggle=\"json\"]').each(function() {
@ -97,6 +103,25 @@
var target_type = 'galaxyClusterRelation';
popoverPopup(this, target_id + '/' + target_type, 'tags', 'selectTaxonomy')
}
function pickerTypes() {
var $select = $('<select id="pickerTypeSelect"/>');
existingRelationTypes.forEach(function(type) {
$select.append($('<option/>').val(type).text(type))
})
var html = '<div>' + $select[0].outerHTML + '</div>';
var that = this
openPopover(this, html, false, 'right', function($popover) {
$popover.find('select').chosen({
width: '300px',
}).on('change', function(evt, param) {
addPickedTypes()
$(that).popover('hide')
});
});
}
function addPickedTypes() {
$('#GalaxyClusterRelationReferencedGalaxyClusterType').val($('#pickerTypeSelect').val());
}
function setSourceUUIDAfterSelect(selected, additionalData) {
selectedUUID = additionalData.itemOptions[selected].uuid;
$('#GalaxyClusterRelationGalaxyClusterUuid').val(selectedUUID);