From 05cc53239654ee70d2b73f4379cde805f7cc150e Mon Sep 17 00:00:00 2001 From: Juan Convers Date: Thu, 18 Apr 2024 20:31:36 +0200 Subject: [PATCH] Fixing issue with filters with dubplicate names. --- .../epfl-people/templates/dynamic-card.php | 18 ++++++++++++------ .../includes/dynamic-card-part.inc.php | 10 +++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/epfl-people/templates/dynamic-card.php b/frontend/epfl-people/templates/dynamic-card.php index 517b4acb..e9bd9bd4 100644 --- a/frontend/epfl-people/templates/dynamic-card.php +++ b/frontend/epfl-people/templates/dynamic-card.php @@ -41,14 +41,20 @@ function epfl_dynamic_people_card($persons, $from, $columns, $custom_data = "", $room_url = epfl_people_get_room_url($room); $people_url = epfl_people_get_people_url($person); - try { - $sciper_str = (string) $person_sciper; - $this_custom = $jsonObj[$sciper_str]; - $person_custom = json_encode($this_custom); - } catch (Exception $e) { + // Check $sciper_str is in $jsonObj + if (isset($jsonObj) && array_key_exists((string) $person_sciper, $jsonObj)){ + try { + $sciper_str = (string) $person_sciper; + $this_custom = $jsonObj[$sciper_str]; + $person_custom = json_encode($this_custom); + } catch (Exception $e) { + $person_custom = 'undefined'; + } + } else { $person_custom = 'undefined'; } - + + $people_data .= " { sciper: '$person_sciper', diff --git a/frontend/epfl-people/templates/includes/dynamic-card-part.inc.php b/frontend/epfl-people/templates/includes/dynamic-card-part.inc.php index f0df3733..d192bee1 100644 --- a/frontend/epfl-people/templates/includes/dynamic-card-part.inc.php +++ b/frontend/epfl-people/templates/includes/dynamic-card-part.inc.php @@ -48,8 +48,8 @@ if (!item.custom) { return item; } - const customObj = item.custom.reduce(function (obj, item) { - obj[item.key] = item.value; + const customObj = item.custom.reduce(function (obj, item, index) { + obj[item.key] = `\${item.key}_____\${item.value}`; return obj; }, {}); return Object.assign({}, item, customObj); @@ -96,7 +96,7 @@ function getFilterLabel (field) { peoplespace.getSingleCheckbox = function (option, id) { return `
-
` + ` }; peoplespace.checkIfAllCardsShouldBeHidden = function () { @@ -289,6 +289,10 @@ function getFilterLabel (field) { "); +// Initialize the $markup variable if is not set +$markup = $markup ?? ''; + +// Check the $markup variable is set and is not undefined $markup .= preg_replace('/peoplespace/', 'pspc', $payload); ?>