new: [galaxyCluster:index] Added badge showing number of custom clusters

pull/6628/head
mokaddem 2020-11-19 18:17:20 +01:00
parent 8b2cea7cdc
commit a890ff1021
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
4 changed files with 18 additions and 2 deletions

View File

@ -162,6 +162,13 @@ class GalaxyClustersController extends AppController
$clusters[$k]['csv'] = $csv[$k];
}
}
$customClusterCount = $this->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(), [
'count' => true,
'conditions' => [
'AND' => [$searchConditions, $aclConditions],
'GalaxyCluster.default' => 0,
]
]);
$this->loadModel('Attribute');
$distributionLevels = $this->Attribute->distributionLevels;
unset($distributionLevels[5]);
@ -169,6 +176,7 @@ class GalaxyClustersController extends AppController
$this->set('csv', $csv);
$this->set('list', $clusters);
$this->set('galaxy_id', $galaxyId);
$this->set('custom_cluster_count', $customClusterCount);
}
if ($this->request->is('ajax')) {
$this->layout = 'ajax';

View File

@ -975,6 +975,9 @@ class GalaxyCluster extends AppModel
$clusters = array();
if (isset($options['first']) && $options['first']) {
$clusters = $this->find('first', $params);
} else if (isset($options['count']) && $options['count']) {
$clusterCount = $this->find('count', $params);
return $clusterCount;
} else {
$clusters = $this->find('all', $params);
}

View File

@ -34,7 +34,7 @@
}
$dataFields = implode(' ', $dataFields);
echo sprintf(
'<a class="btn btn-small %s %s" %s href="%s" %s %s %s %s %s>%s%s%s</a>',
'<a class="btn btn-small %s %s" %s href="%s" %s %s %s %s %s>%s%s%s %s</a>',
empty($data['class']) ? '' : h($data['class']),
empty($data['active']) ? 'btn-inverse' : 'btn-primary', // Change the default class for highlighted/active toggles here
empty($data['id']) ? '' : 'id="' . h($data['id']) . '"',
@ -50,7 +50,8 @@
$data['fa-icon']
), // this has to be sanitised beforehand!
empty($data['html']) ? '' : $data['html'], // this has to be sanitised beforehand!
empty($data['text']) ? '' : h($data['text'])
empty($data['text']) ? '' : h($data['text']),
empty($data['badge']) ? '' : sprintf('<span class="badge badge-%s">%s</span>', empty($data['badge']['type']) ? 'info' : $data['badge']['type'], h($data['badge']['text']))
);
}
?>

View File

@ -29,6 +29,10 @@
'active' => $context === 'custom',
'url' => sprintf('%s/galaxies/view/%s/context:custom', $baseurl, $galaxy_id),
'text' => __('Custom'),
'badge' => [
'type' => 'info',
'text' => $custom_cluster_count
]
),
array(
'active' => $context === 'org',