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

Fixing issue with filters with dubplicate names. #399

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions frontend/epfl-people/templates/dynamic-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -96,7 +96,7 @@ function getFilterLabel (field) {
peoplespace.getSingleCheckbox = function (option, id) {
return `<div class='custom-control custom-checkbox'>
<input type='checkbox' value='\${option}' id='\${option}' class='custom-control-input' onclick='peoplespace.updateFilters()' name='\${id}' checked>
<label class='custom-control-label checkbox-label' for='\${option}'>\${option}</label></div>`
<label class='custom-control-label checkbox-label' for='\${option}'>\${option.replace(`\${id}_____`, '')}</label></div>`
};

peoplespace.checkIfAllCardsShouldBeHidden = function () {
Expand Down Expand Up @@ -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);

?>