diff --git a/CHANGELOG.md b/CHANGELOG.md
index 244dc73aec5098aeda879085fa1e9245e1f02833..36886264272b812e985cd2f1819878b84a3b0caa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
+- Show salary scale on search people page @dsavvidi
### Changed
diff --git a/src/main/java/nl/tudelft/tam/controller/PersonController.java b/src/main/java/nl/tudelft/tam/controller/PersonController.java
index da25e1a6ddf4faf18c02f65738293c10105ef5e2..f8ccdc0387c12dd87fcbc32c465d866ba789d549 100644
--- a/src/main/java/nl/tudelft/tam/controller/PersonController.java
+++ b/src/main/java/nl/tudelft/tam/controller/PersonController.java
@@ -153,7 +153,7 @@ public class PersonController {
@GetMapping("search")
@PreAuthorize("@authorisationService.isCoordinatorOfAny()")
public String searchForPeople(@RequestParam(required = false) String q, Model model) {
- List<PersonSummaryDTO> people = personService.searchForPeople(q);
+ Map<PersonSummaryDTO, Profile> people = personService.findPersonProfilePairs(q);
model.addAttribute("people", people);
return "person/search";
}
diff --git a/src/main/resources/templates/person/search.html b/src/main/resources/templates/person/search.html
index 14cf3cbe2a4aedd4d6e822cc30c608dfcea910c3..669ea0b3adeeb7a0cb1ec1724f29164313c2d865 100644
--- a/src/main/resources/templates/person/search.html
+++ b/src/main/resources/templates/person/search.html
@@ -52,6 +52,7 @@
<th th:text="#{person.number}"></th>
<th th:text="#{person.username}"></th>
<th th:text="#{person.email}"></th>
+ <th th:text="#{payscale}"></th>
<th th:text="#{jobOffer.queueFeedback}"></th>
<th></th>
</tr>
@@ -61,19 +62,20 @@
<a
class="link"
target="_blank"
- th:href="@{|/profile/${person.id}|}"
- th:text="${person.displayName}"></a>
+ th:href="@{|/profile/${person.getKey().id}|}"
+ th:text="${person.getKey().displayName}"></a>
</div>
</td>
- <td th:text="${person.number}"></td>
- <td th:text="${person.username}"></td>
- <td th:text="${person.email}"></td>
+ <td th:text="${person.getKey().number}"></td>
+ <td th:text="${person.getKey().username}"></td>
+ <td th:text="${person.getKey().email}"></td>
+ <td th:text="${person.getValue().payScale}"></td>
<td>
<a
class="link"
target="_blank"
th:text="#{jobOffer.queueFeedback.view}"
- th:href="|${@environment.getProperty('tam.queue-url')}/feedback/${person.id}|"></a>
+ th:href="|${@environment.getProperty('tam.queue-url')}/feedback/${person.getKey().id}|"></a>
</td>
</tr>
</table>
diff --git a/src/test/java/nl/tudelft/tam/controller/PersonControllerTest.java b/src/test/java/nl/tudelft/tam/controller/PersonControllerTest.java
index edf3bbe44d2b178d6f7c2656449a81ffa93d3660..69e9902a7f1a49d2dbc0cefc470da89f8ba3d8fe 100644
--- a/src/test/java/nl/tudelft/tam/controller/PersonControllerTest.java
+++ b/src/test/java/nl/tudelft/tam/controller/PersonControllerTest.java
@@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import java.util.List;
+import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -38,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
import application.test.TestTAMApplication;
import nl.tudelft.labracore.api.dto.PersonSummaryDTO;
+import nl.tudelft.tam.model.Profile;
import nl.tudelft.tam.security.AuthorisationService;
import nl.tudelft.tam.service.ApplicationService;
import nl.tudelft.tam.service.PersonService;
@@ -115,19 +117,21 @@ public class PersonControllerTest {
@Test
@WithUserDetails("admin")
void searchForPeopleTest() throws Exception {
+ Map<PersonSummaryDTO, Profile> entrymap = Map.ofEntries(Map.entry(person1, new Profile()),
+ Map.entry(person2, new Profile()));
when(authService.isCoordinatorOfAny()).thenReturn(true);
- when(personService.searchForPeople(anyString())).thenReturn(List.of(person1));
+ when(personService.findPersonProfilePairs(anyString())).thenReturn(entrymap);
String user = "test";
mvc.perform(get("/person/search")
- .param("q", user))
+ .param("q", user))
.andExpect(status().isOk()) // Expect HTTP 200 status
- .andExpect(model().attribute("people", List.of(person1))) // Expect the "people" attribute in the model
+ .andExpect(model().attribute("people", entrymap)) // Expect the "people" attribute in the model
.andExpect(view().name("person/search"));
verify(authService).isCoordinatorOfAny();
- verify(personService).searchForPeople(user);
+ verify(personService).findPersonProfilePairs(user);
}
@Test
@@ -137,12 +141,12 @@ public class PersonControllerTest {
mvc.perform(MockMvcRequestBuilders.get("/person/search"))
.andExpect(status().isOk())
- .andExpect(model().attribute("people", List.of()))
+ .andExpect(model().attribute("people", Map.of()))
.andExpect(view().name("person/search"));
verify(authService).isCoordinatorOfAny();
- verify(personService, times(0)).searchForPeople(anyString());
- verify(personService).searchForPeople(null);
+ verify(personService, times(0)).findPersonProfilePairs(anyString());
+ verify(personService).findPersonProfilePairs(null);
}
@Test
@@ -154,7 +158,7 @@ public class PersonControllerTest {
.andExpect(status().isForbidden());
verify(authService).isCoordinatorOfAny();
- verify(personService, times(0)).searchForPeople(anyString());
+ verify(personService, times(0)).findPersonProfilePairs(anyString());
}
@Test