Skip to content

Commit

Permalink
Merge pull request #1253 from UN-OCHA/berliner/HPC-9972
Browse files Browse the repository at this point in the history
HPC-9972: Allow to sum PiN figures in key figures element
  • Loading branch information
berliner authored Dec 12, 2024
2 parents c7d5a8b + 877f239 commit a89931b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public function getApiValue($type = NULL) {
public function getValueOperation(?array $type = NULL) {
$type = $type ?? $this->getType();
$custom_value = $this->getCustomValue();
if (!empty($type['allow_sum']) && $custom_value) {
$sum = ($sum ?? $this->get('sum')) && !empty($type['allow_sum']);
if ($sum && $custom_value) {
return $this->t('Sum');
}
elseif ($custom_value) {
Expand Down Expand Up @@ -293,24 +294,28 @@ private function getTypes() {
'label' => $this->t('People in need'),
'value_description' => $this->t('Enter amount as full integer to override the value from the API.'),
'data_type' => 'integer',
'allow_sum' => TRUE,
'theme' => 'hpc_amount',
],
'people_target' => [
'label' => $this->t('People targeted'),
'value_description' => $this->t('Enter amount as full integer to override the value from the API.'),
'data_type' => 'integer',
'allow_sum' => TRUE,
'theme' => 'hpc_amount',
],
'people_expected_reach' => [
'label' => $this->t('People expected reach'),
'value_description' => $this->t('Enter amount as full integer to override the value from the API.'),
'data_type' => 'integer',
'allow_sum' => TRUE,
'theme' => 'hpc_amount',
],
'people_reached' => [
'label' => $this->t('People latest reached'),
'value_description' => $this->t('Enter amount as full integer to override the value from the API.'),
'data_type' => 'integer',
'allow_sum' => TRUE,
'theme' => 'hpc_amount',
],
'people_reached_percent' => [
Expand All @@ -334,7 +339,7 @@ private function getTypes() {
'theme' => 'hpc_currency',
],
'funding_progress' => [
'label' => $this->t('Funding coverage'),
'label' => $this->t('Funding coverage (%)'),
'default_label' => $this->t('% Funded'),
'value_description' => $this->t('Enter a percentage value as a decimal between 0 and 100. <strong>Note that write-in values are ignored if you limit the data to include or exclude a global plan.</strong>'),
'data_type' => 'float',
Expand All @@ -343,6 +348,7 @@ private function getTypes() {
'countries_affected' => [
'label' => $this->t('Countries affected'),
'data_type' => 'integer',
'allow_sum' => TRUE,
'theme' => 'hpc_amount',
],
];
Expand Down

0 comments on commit a89931b

Please sign in to comment.