new: [galaxy] Added bulk galaxy tagging

pull/4024/head
mokaddem 2019-01-15 11:12:36 +01:00
parent ce75836d39
commit e9ed74426c
4 changed files with 34 additions and 11 deletions

View File

@ -258,8 +258,14 @@ class GalaxiesController extends AppController
public function attachMultipleClusters($target_id, $target_type = 'event')
{
if (!empty($this->request->data['Galaxy']['target_ids'])) {
$cluster_ids = json_decode($this->request->data['Galaxy']['target_ids'], true);
if ($target_id === 'selected') {
$target_id_list = json_decode($this->request->data['Galaxy']['attribute_ids']);
} else {
$target_id_list = array($target_id);
}
$cluster_ids = $this->request->data['Galaxy']['target_ids'];
if (!empty($cluster_ids)) {
$cluster_ids = json_decode($cluster_ids, true);
if ($cluster_ids === null) {
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'error' => __('Failed to parse request.'))), 'status'=>200, 'type' => 'json'));
}
@ -271,7 +277,9 @@ class GalaxiesController extends AppController
$cluster_ids = array($cluster_ids);
}
foreach ($cluster_ids as $cluster_id) {
$result = $this->Galaxy->attachCluster($this->Auth->user(), $target_type, $target_id, $cluster_id);
foreach ($target_id_list as $target_id) {
$result = $this->Galaxy->attachCluster($this->Auth->user(), $target_type, $target_id, $cluster_id);
}
}
if ($this->request->is('ajax')) {
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => $result, 'check_publish' => true)), 'status'=>200, 'type' => 'json'));

View File

@ -117,6 +117,7 @@
<span id="create-button" title="<?php echo __('Add attribute');?>" role="button" tabindex="0" aria-label="<?php echo __('Add attribute');?>" class="icon-plus useCursorPointer" onClick="clickCreateButton(<?php echo $event['Event']['id']; ?>, '<?php echo $possibleAction; ?>');"></span>
<span id="multi-edit-button" title="<?php echo __('Edit selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Edit selected Attributes');?>" class="hidden icon-edit mass-select useCursorPointer" onClick="editSelectedAttributes(<?php echo $event['Event']['id']; ?>);"></span>
<span id="multi-tag-button" title="<?php echo __('Tag selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Tag selected Attributes');?>" class="hidden icon-tag mass-select useCursorPointer" onClick="popoverPopup(this, 'selected/attribute', 'tags', 'selectTaxonomy');"></span>
<span id="multi-galaxy-button" title="<?php echo __('Add new cluster to selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Add new cluster to selected Attributes');?>" class="hidden icon-rebel fa-rebel mass-select useCursorPointer" style="font: normal normal normal 14px/1 FontAwesome; vertical-align: top;" onClick="popoverPopup(this, 'selected/attribute', 'galaxies', 'selectGalaxyNamespace');"></span>
<span id="multi-delete-button" title="<?php echo __('Delete selected Attributes');?>" role="button" tabindex="0" aria-label="<?php echo __('Delete selected Attributes');?>" class="hidden icon-trash mass-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'deleteAttributes');"></span>
<span id="multi-accept-button" title="<?php echo __('Accept selected Proposals');?>" role="button" tabindex="0" aria-label="<?php echo __('Accept selected Proposals');?>" class="hidden icon-ok mass-proposal-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'acceptProposals');"></span>
<span id="multi-discard-button" title="<?php echo __('Discard selected Proposals');?>" role="button" tabindex="0" aria-label="<?php echo __('Discard selected Proposals');?>" class="hidden icon-remove mass-proposal-select useCursorPointer" onClick="multiSelectAction(<?php echo $event['Event']['id']; ?>, 'discardProposals');"></span>

View File

@ -1,9 +1,16 @@
<div class="hidden">
<?php
echo $this->Form->create('Galaxy', array('url' => '/galaxies/attachMultipleClusters/' . $target_type . '/' . $target_id, 'style' => 'margin:0px;'));
echo $this->Form->create('Galaxy', array('url' => '/galaxies/attachMultipleClusters/' . $target_id . '/' . $target_type, 'style' => 'margin:0px;'));
echo $this->Form->input('target_ids', array('type' => 'text'));
echo $this->Form->input('attribute_ids', array('style' => 'display:none;', 'label' => false));
echo $this->Form->end();
?>
</div>
<?php echo $this->element('generic_picker'); ?>
<script>
$(document).ready(function() {
$('#GalaxyAttributeIds').attr('value', getSelected());
});
</script>

View File

@ -3397,25 +3397,32 @@ $('.galaxy-toggle-button').click(function() {
function addGalaxyListener(id) {
var target_type = $(id).data('target-type');
var target_id = $(id).data('target-id');
popoverPopup(id, target_type + '/' + target_id, 'galaxies', 'selectGalaxyNamespace');
popoverPopup(id, target_id + '/' + target_type, 'galaxies', 'selectGalaxyNamespace');
}
function quickSubmitGalaxyForm(cluster_ids, additionalData) {
scope = additionalData['target_id'];
scope_id = additionalData['target_type'];
var target_id = additionalData['target_id'];
var scope = additionalData['target_type'];
$('#GalaxyTargetIds').val(JSON.stringify(cluster_ids));
if (target_id == 'selected') {
$('#AttributeAttributeIds').val(getSelected());
}
$.ajax({
data: $('#GalaxySelectClusterForm').closest("form").serialize(),
beforeSend: function (XMLHttpRequest) {
$(".loading").show();
},
success:function (data, textStatus) {
loadGalaxies(scope_id, scope);
handleGenericAjaxResponse(data);
if (target_id === 'selected') {
location.reload();
} else {
loadGalaxies(target_id, scope);
handleGenericAjaxResponse(data);
}
},
error:function() {
showMessage('fail', 'Could not add cluster.');
loadGalaxies(scope_id, scope);
loadGalaxies(target_id, scope);
},
complete:function() {
$("#popover_form").fadeOut();
@ -3423,7 +3430,7 @@ function quickSubmitGalaxyForm(cluster_ids, additionalData) {
$(".loading").hide();
},
type:"post",
url: "/galaxies/attachMultipleClusters/" + scope_id + "/" + scope
url: "/galaxies/attachMultipleClusters/" + target_id + "/" + scope
});
return false;
}