Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPC-9661: Set column names for caseload and indicators and add translations #1130

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\ghi_form_elements\ConfigurationContainerItemPluginBase;
use Drupal\ghi_form_elements\Helpers\FormElementHelper;
use Drupal\ghi_plans\ApiObjects\Attachments\AttachmentInterface;
use Drupal\ghi_plans\ApiObjects\Attachments\DataAttachment;
use Drupal\ghi_plans\Helpers\AttachmentHelper;

/**
Expand Down Expand Up @@ -55,8 +56,16 @@ public function buildForm($element, FormStateInterface $form_state) {
* A default label.
*/
public function getDefaultLabel() {
$configuration = $this->getPluginConfiguration();
return $configuration['default_label'] ?? $this->t('Attachment');
$attachment = $this->getContextValue('attachment');
$label = NULL;
if ($attachment && $attachment instanceof DataAttachment) {
$label = $attachment->getPrototype()?->getName();
}
if (!$label) {
$configuration = $this->getPluginConfiguration();
$label = $configuration['default_label'] ?? $this->t('Attachment');
}
return $label;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,11 @@ public function canAddNewItem() {
public function getColumns(array $conf = NULL) {
$conf = $conf ?? ($this->getConfig()['table_form'] ?? []);
if (empty($conf['columns'])) {
$prototype = $this->getAttachmentPrototype();
$conf['columns'] = [
[
'item_type' => 'attachment_label',
'config' => [
'label' => $prototype?->getName() ?? (string) $this->t('Indicator'),
'label' => NULL,
],
],
];
Expand Down
8 changes: 7 additions & 1 deletion html/modules/custom/ghi_plans/translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ msgid "Response plan"
msgstr "Plan de respuesta"

msgid "Projects"
msgstr "Proyectos"
msgstr "Proyectos"

msgid "Caseload"
msgstr "Datos de Población"

msgid "Indicator"
msgstr "Indicador"
6 changes: 6 additions & 0 deletions html/modules/custom/ghi_plans/translations/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ msgstr "Plan de réponse"

msgid "Projects"
msgstr "Projets"

msgid "Caseload"
msgstr "Données de population"

msgid "Indicator"
msgstr "Indicateur"
5 changes: 2 additions & 3 deletions html/modules/custom/ghi_subpages/src/LogframeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private function buildCaseloadColumns(AttachmentPrototype $attachment_prototype,
$columns[] = [
'item_type' => 'attachment_label',
'config' => [
'label' => $attachment_prototype->getName(),
'label' => NULL,
],
'id' => 0,
];
Expand Down Expand Up @@ -486,13 +486,12 @@ private function buildCaseloadColumns(AttachmentPrototype $attachment_prototype,
* container items.
*/
private function buildIndicatorColumns(AttachmentPrototype $attachment_prototype, Plan $plan) {

$columns = [];
// Setup the columns.
$columns[] = [
'item_type' => 'attachment_label',
'config' => [
'label' => $attachment_prototype->getName(),
'label' => NULL,
],
'id' => count($columns),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function checkRequest(RequestEvent $event) {
$query_args = $request->query->all();
if (array_key_exists('check_logged_in', $query_args) && $this->currentUser->isAnonymous()) {
unset($query_args['check_logged_in']);
$url = Url::createFromRequest($request);
try {
$url = Url::createFromRequest($request);
}
catch (\Exception $e) {
return;
}
$url->setOption('query', $query_args);
$event->setResponse(new CacheableRedirectResponse($url->toString()));
}
Expand Down
Loading