Skip to content

Commit

Permalink
feat(bo): Add operator comment on tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
juliette-derancourt committed Nov 20, 2023
1 parent 07ac17b commit a50b777
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.security.Principal;
Expand Down Expand Up @@ -91,15 +92,15 @@ public class BOTenantController {
public String getTenant(@PathVariable Long id) {
Tenant tenant = tenantService.findTenantById(id);
if (tenant != null) {
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
return redirectToTenantPage(tenant);
}
throw new ObjectNotFoundException("TENANT", "Tenant is not found. Still exists?");
}

@GetMapping("/setAsTenantCreate/{id}")
public String setAsTenantCreate(@PathVariable Long id) {
Tenant tenant = userService.setAsTenantCreate(tenantService.findTenantById(id));
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
return redirectToTenantPage(tenant);
}

@GetMapping("/deleteCoTenant/{id}")
Expand Down Expand Up @@ -159,7 +160,7 @@ public String deleteDocument(@PathVariable("id") Long id, Principal principal) {
apartmentSharingService.resetDossierPdfGenerated(tenant.getApartmentSharing());
User operator = userService.findUserByEmail(principal.getName());
tenantService.updateTenantStatus(tenant, operator);
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
return redirectToTenantPage(tenant);
}

@GetMapping("/status/{id}")
Expand All @@ -168,7 +169,7 @@ public String changeStatusOfDocument(@PathVariable("id") Long id, MessageDTO mes
apartmentSharingService.resetDossierPdfGenerated(tenant.getApartmentSharing());
User operator = userService.findUserByEmail(principal.getName());
tenantService.updateTenantStatus(tenant, operator);
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
return redirectToTenantPage(tenant);
}
private void checkPartnerRights(Tenant tenant, Principal principal){
BOUser operator = userService.findUserByEmail(principal.getName());
Expand Down Expand Up @@ -207,7 +208,7 @@ public String deleteGuarantor(@PathVariable("guarantorId") Long guarantorId, Pri
apartmentSharingService.resetDossierPdfGenerated(tenant.getApartmentSharing());
User operator = userService.findUserByEmail(principal.getName());
tenantService.updateTenantStatus(tenant, operator);
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
return redirectToTenantPage(tenant);
}

private Boolean findNewMessageFromTenant(Long id) {
Expand All @@ -229,6 +230,18 @@ public String processFile(@PathVariable("id") Long id, CustomMessage customMessa
return tenantService.redirectToApplication(principal, null);
}

@PostMapping("/{id}/comment")
public String addOperatorComment(@PathVariable("id") Long id, @RequestParam String comment) {
Tenant tenant = tenantService.find(id);
tenant.setOperatorComment(comment);
tenantService.save(tenant);
return redirectToTenantPage(tenant);
}

private static String redirectToTenantPage(Tenant tenant) {
return "redirect:/bo/colocation/" + tenant.getApartmentSharing().getId() + "#tenant" + tenant.getId();
}

private List<ItemDetail> getItemDetailForSubcategoryOfDocument(DocumentSubCategory documentSubCategory, String tenantOrGuarantor) {

List<ItemDetail> itemDetails = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,33 +404,80 @@ <h5 class="modal-title bold" style="width: 80%;float: left;">
</div>
</div>
</div>


</div>
</div>
<div class="row" style="margin-bottom: 8px;">
<div class="col-md-12"
th:style="${partnerListByTenant.getNamesOfPartnerByTenantId(tenant.getId()).isEmpty()}?'display:none':'margin-bottom: 8px;'">
<div class="col-md-1">
<h4 style="margin-left: -15px;">Partner(s)</h4>
<div class="row" style="margin-top: 0.5em">
<div class="col-md-10">
<a class="btn btn-warning bo-btn" data-toggle="modal"
th:data-target="'#add-comment-'+${tenant.getId()}">
<span th:text="${T(org.apache.commons.lang3.StringUtils).isBlank(tenant.getOperatorComment())} ? 'Ajouter un commentaire' : 'Editer le commentaire'"></span>
</a>
</div>
<div class=" col-md-11">
<div class="scrollmenu"
style="background-color: #333;overflow: auto;white-space: nowrap;margin-right: -12px">
<a href="#"
style="display: inline-block;color: white;text-align: center;padding: 14px;text-decoration: none;"
th:each="item : ${partnerListByTenant.getNamesOfPartnerByTenantId(tenant.getId())}"
th:text="${item}"></a>
<div class="modal fade" th:id="'add-comment-' + ${tenant.getId()}" role="dialog"
tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title bold" style="width: 80%;float: left;">
Précisions concernant le traitement du dossier
</h5>
<button aria-label="Close" class="close" data-dismiss="modal"
type="button">
<span aria-hidden="true">&times;</span>
</button>
</div>

<form method="post" th:action="@{/bo/tenant/__${tenant.getId()}__/comment}">
<div class="modal-body">
<textarea id="comment" name="comment" class="input" rows="6"
type="text" th:text="${tenant.getOperatorComment()}"></textarea>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-info btn-save"
style="border-radius: 50px;font-size: 15px;line-height: 1;padding: 5px 8px 7px;">
Sauvegarder
</button>
<button class="btn btn-secondary" data-dismiss="modal"
style="border-radius: 50px;font-size: 15px;line-height: 1;padding: 5px 8px 7px;"
type="button">
Annuler
</button>
</div>
</form>

</div>
</div>
</div>
</div>
</div>

<div class="table-responsive">

<table class="table table-striped table-bordered table-hover"
th:with="partners=${partnerListByTenant.getNamesOfPartnerByTenantId(tenant.getId())}">
<tr th:if="${tenant.getOperatorComment() != null && !tenant.getOperatorComment().isEmpty()}">
<td style="width: 25%">⚠️ Commentaire opérateur</td>
<td th:text="${tenant.getOperatorComment()}"></td>
</tr>
<tr th:if="${!partners.isEmpty()}">
<td>Partenaire(s)</td>
<td>
<ul>
<li
th:each="item : ${partners}"
th:text="${item}"
>
</li>
</ul>
</td>
</tr>
</table>
</div>

<div class="table-responsive">

<table class="table table-striped table-bordered table-hover">
<tr>
<td>Tenant Id</td>
<td style="width: 25%">Tenant Id</td>
<td th:text="${tenant.getId()}"></td>
</tr>
<tr>
Expand Down

0 comments on commit a50b777

Please sign in to comment.