Skip to content

Commit

Permalink
Merge pull request #146 from EsupPortail/testing
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
dlemaignent authored Sep 14, 2021
2 parents beae2c4 + e46a8ea commit cff0bc4
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 68 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>
<groupId>org.esupportail</groupId>
<artifactId>esup-signature</artifactId>
<version>1.14.7-SNAPSHOT</version>
<version>1.14.7</version>
<name>esup-signature</name>
<properties>
<start-class>org.esupportail.esupsignature.EsupSignatureApplication</start-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class SignRequestParams {

private Integer blue = 0;

private Integer fontSize = 12;

public Long getId() {
return id;
}
Expand Down Expand Up @@ -268,4 +270,12 @@ public Integer getBlue() {
public void setBlue(Integer blue) {
this.blue = blue;
}

public Integer getFontSize() {
return fontSize;
}

public void setFontSize(Integer fontSize) {
this.fontSize = fontSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.esupportail.esupsignature.entity.UserPropertie;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface UserPropertieRepository extends CrudRepository<UserPropertie, Long> {
UserPropertie findByUserEppn(String userEppn);
List<UserPropertie> findByUserEppn(String userEppn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;

@Service
public class UserPropertieService {
Expand All @@ -33,12 +30,16 @@ public void createUserPropertieFromMails(User user, List<String> recipientEmails
}

public void createUserPropertie(User user, User favoriteUser) {
UserPropertie userPropertie = getUserProperties(user.getEppn());
if (userPropertie == null) {
List<UserPropertie> userProperties = getUserProperties(user.getEppn());
if (userProperties == null || userProperties.size() == 0) {
addPropertie(user, favoriteUser);
} else {
userPropertie.getFavorites().put(favoriteUser, new Date());
userPropertieRepository.save(userPropertie);
for(UserPropertie userPropertie : userProperties) {
if(userPropertie.getFavorites().containsKey(favoriteUser)) {
userPropertie.getFavorites().put(favoriteUser, new Date());
userPropertieRepository.save(userPropertie);
}
}
}
}

Expand All @@ -50,26 +51,24 @@ private void addPropertie(User user, User favoriteUser) {
}

public List<String> getFavoritesEmails(String userEppn) {
List<String> favoriteUserEmails = new ArrayList<>();
UserPropertie userPropertie = getUserProperties(userEppn);
if(userPropertie != null) {
Map<User, Date> favorites = userPropertie.getFavorites();
if (favorites.size() > 0) {
List<Map.Entry<User, Date>> entrySet = new ArrayList<>(favorites.entrySet());
entrySet.sort(Map.Entry.<User, Date>comparingByValue().reversed());
for (int i = 0; i < Math.min(entrySet.size(), 5); i++) {
favoriteUserEmails.add(entrySet.get(i).getKey().getEmail());
Set<String> favoriteUserEmails = new HashSet<>();
List<UserPropertie> userProperties = getUserProperties(userEppn);
if(userProperties != null && userProperties.size() > 0) {
for(UserPropertie userPropertie : userProperties) {
Map<User, Date> favorites = userPropertie.getFavorites();
if (favorites.size() > 0) {
List<Map.Entry<User, Date>> entrySet = new ArrayList<>(favorites.entrySet());
entrySet.sort(Map.Entry.<User, Date>comparingByValue().reversed());
for (int i = 0; i < Math.min(entrySet.size(), 5); i++) {
favoriteUserEmails.add(entrySet.get(i).getKey().getEmail());
}
}
}
}
return favoriteUserEmails;
}

public UserPropertie getUserProperties(String userEppn) {
return userPropertieRepository.findByUserEppn(userEppn);
return new ArrayList<>(favoriteUserEmails);
}

public UserPropertie getUserPropertiesByUserEppn(String userEppn) {
public List<UserPropertie> getUserProperties(String userEppn) {
return userPropertieRepository.findByUserEppn(userEppn);
}

Expand All @@ -81,8 +80,10 @@ public void delete(Long id) {

@Transactional
public void delete(String authUserEppn, Long id) {
UserPropertie userPropertie = getUserPropertiesByUserEppn(authUserEppn);
User user = userService.getById(id);
userPropertie.getFavorites().remove(user);
List<UserPropertie> userProperties = getUserProperties(authUserEppn);
for(UserPropertie userPropertie : userProperties) {
User user = userService.getById(id);
userPropertie.getFavorites().remove(user);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ public void setWorkflowSetupFromJson(Long id, InputStream inputStream) throws IO
String savedTitle = workflow.getTitle();
ObjectMapper objectMapper = new ObjectMapper();
Workflow workflowSetup = objectMapper.readValue(inputStream.readAllBytes(), Workflow.class);
workflow.getWorkflowSteps().clear();
for(WorkflowStep workflowStepSetup : workflowSetup.getWorkflowSteps()) {
Optional<WorkflowStep> optionalWorkflowStep = workflow.getWorkflowSteps().stream().filter(workflowStep1 -> workflowStep1.getId().equals(workflowStepSetup.getId())).findFirst();
if(optionalWorkflowStep.isPresent()) {
Expand All @@ -606,7 +607,12 @@ public void setWorkflowSetupFromJson(Long id, InputStream inputStream) throws IO
workflow.getWorkflowSteps().add(newWorkflowStep);
}
}
update(workflow, workflowSetup.getCreateBy(), workflowSetup.getManagers().toArray(String[]::new), workflowSetup.getManagers());
workflow.getTargets().clear();
update(workflow, workflowSetup.getCreateBy(), null, workflowSetup.getManagers());
for(Target target : workflowSetup.getTargets()) {
Target newTarget = targetService.createTarget(target.getTargetType(), target.getTargetUri());
workflow.getTargets().add(newTarget);
}
workflow.setName(savedName);
workflow.setTitle(savedTitle);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void stampImageToPage(SignRequest signRequest, SignRequestParams signReq
addLink(signRequest, signRequestParams, user, fixFactor, pdDocument, pdPage, newDate, dateFormat, xAdjusted, yAdjusted);
}
} else if (signRequestParams.getTextPart() != null && !signRequestParams.getTextPart().isEmpty()) {
int fontSize = (int) (12 * signRequestParams.getSignScale() * .75);
int fontSize = (int) (signRequestParams.getFontSize() * signRequestParams.getSignScale() * .75);
PDFont pdFont = PDTrueTypeFont.load(pdDocument, new ClassPathResource("static/fonts/LiberationSans-Regular.ttf").getFile(), WinAnsiEncoding.INSTANCE);
contentStream.beginText();
contentStream.setFont(pdFont, fontSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@ public String importFormSetup(@PathVariable("id") Long id,
return "redirect:/admin/forms/update/" + id;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ public List<String> searchUserList(@RequestParam(value="searchString") String se

@GetMapping("/properties")
public String properties(@ModelAttribute("authUserEppn") String authUserEppn, Model model) {
UserPropertie userPropertie = userPropertieService.getUserPropertiesByUserEppn(authUserEppn);
if (userPropertie != null) {
List<Map.Entry<User, Date>> entrySet = new ArrayList<>(userPropertie.getFavorites().entrySet());
entrySet.sort(Map.Entry.<User, Date>comparingByValue().reversed());
List<UserPropertie> userProperties = userPropertieService.getUserProperties(authUserEppn);
if (userProperties != null && userProperties.size() > 0) {
Map<User, Date> sortedMap = new LinkedHashMap<>();
entrySet.forEach(e -> sortedMap.put(e.getKey(), e.getValue()));
for (UserPropertie userPropertie : userProperties) {
List<Map.Entry<User, Date>> entrySet = new ArrayList<>(userPropertie.getFavorites().entrySet());
entrySet.sort(Map.Entry.<User, Date>comparingByValue().reversed());
entrySet.forEach(e -> sortedMap.put(e.getKey(), e.getValue()));
}
model.addAttribute("userProperties", sortedMap);
}
List<FieldPropertie> fieldProperties = fieldPropertieService.getFieldProperties(authUserEppn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class FormWsController {
@PostMapping(value = "/{id}/new")
@Operation(description = "Création d'une nouvelle instance d'un formulaire")
public Long start(@PathVariable Long id,
@RequestParam String eppn,
@RequestParam @Parameter(description = "Eppn du propriétaire du futur document") String eppn,
@RequestParam(required = false) @Parameter(description = "Liste des participants pour chaque étape", example = "[stepNumber*email]") List<String> recipientEmails,
@RequestParam(required = false) @Parameter(description = "Lites des numéros d'étape pour lesquelles tous les participants doivent signer", example = "[stepNumber]") List<String> allSignToCompletes,
@RequestParam(required = false) @Parameter(description = "Liste des destinataires finaux", example = "[email]") List<String> targetEmails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class UserParamsHelp {
this.intro.addStep({
intro: "Sur cette page vous pouvez modifier vos paramètres de signature :" +
"<ul>" +
"<li>Ajouter / supprimer des images de votre siganture</li>" +
"<li>Ajouter / supprimer des images de votre signature</li>" +
"<li>Ajouter un certificat pour effectuer des signatures électroniques</li>" +
"<li>Ajuster vos paramètres d'alerte</li>" +
"</ul>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ export class WorkspacePdf {
}

checkSignsPositions() {
if(this.signPosition.signRequestParamses.size > 0) {
let testSign = Array.from(this.signPosition.signRequestParamses.values());
if(testSign.filter(s => s.signImageNumber >= 0 && s.isSign).length > 0) {
for (let i = 0; i < this.currentSignRequestParamses.length; i++) {
if (this.currentSignRequestParamses[i].ready == null || !this.currentSignRequestParamses[i].ready) {
return false;
Expand Down Expand Up @@ -993,13 +994,20 @@ export class WorkspacePdf {
selected: true
});
}
if(this.status === "draft" || this.status === "pending" || this.postits.length > 0) {
if(this.status === "draft" || this.status === "pending") {
data.push({
innerHTML: '<div style="width: 200px;"><i class="fas fa-comment text-warning pr-2"></i> <b>Annoter</b></div>',
text: 'Annoter',
value: 'comment'
});
}
if(this.status !== "draft" && this.status !== "pending" && this.postits.length > 0) {
data.push({
innerHTML: '<div style="width: 200px;"><i class="fas fa-comment text-warning pr-2"></i> <b>Voir les annotations</b></div>',
text: 'Consulter les annotations',
value: 'comment'
});
}
data.push({
innerHTML: '<div style="width: 200px;"><i class="fas fa-eye pr-2"></i> <b>Mode lecture</b></div>',
text: 'Lecture',
Expand All @@ -1015,6 +1023,9 @@ export class WorkspacePdf {
data: data
});
}
if(this.changeModeSelector != null) {
this.changeModeSelector.set("read");
}
}

changeMode(e) {
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/static/js/modules/utils/PdfViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ export class PdfViewer extends EventFactory {
$(this).unbind();
$(this).remove();
});
let signFieldNumber = 0;
let signFieldNumber = 1;
for (let i = 0; i < items.length; i++) {
let item = items[i];
console.debug("debug - " + ">> Start compute item of type : " + item.fieldType);
Expand All @@ -640,13 +640,14 @@ export class PdfViewer extends EventFactory {
signField.css("font-size", 8);
signField.attr("data-id", signFieldNumber);
signField.on('click', function () {
console.info("click on " + signFieldNumber);
let report = $("#report_" + $(this).attr("data-id"));
if (report.length) {
if (report != null) {
$("#reportModal").modal("show");
$("div[id^='report_']").each(function () {
$(this).hide();
});
report.show();
report.css("display", "block");
}
})
// signField.attr("data-toggle", "modal");
Expand Down
72 changes: 49 additions & 23 deletions src/main/resources/static/js/prototypes/SignRequestParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,7 @@ export class SignRequestParams extends EventFactory {
this.cross.css("z-index", "5");
this.cross.attr("data-id", this.id);
let self = this;
this.cross.draggable({
containment: "#pdf",
scroll: false,
drag: function() {
let thisPos = $(this).position();
if(!self.firstLaunch) {
let x = Math.round(thisPos.left / self.currentScale);
let y = Math.round(thisPos.top / self.currentScale);
self.xPos = x;
self.yPos = y;
} else {
self.firstLaunch = false;
window.scrollTo(0, self.yPos);
}
}
});
this.madeCrossDraggable();
this.cross.resizable({
aspectRatio: true,
resize: function(event, ui) {
Expand Down Expand Up @@ -193,6 +178,26 @@ export class SignRequestParams extends EventFactory {
}
}

madeCrossDraggable() {
let self = this;
this.cross.draggable({
containment: "#pdf",
scroll: false,
drag: function() {
let thisPos = $(this).position();
if(!self.firstLaunch) {
let x = Math.round(thisPos.left / self.currentScale);
let y = Math.round(thisPos.top / self.currentScale);
self.xPos = x;
self.yPos = y;
} else {
self.firstLaunch = false;
window.scrollTo(0, self.yPos);
}
}
});
}

initEventListeners() {
let self = this;
this.cross.on("mousedown click", function (e) {
Expand Down Expand Up @@ -303,9 +308,10 @@ export class SignRequestParams extends EventFactory {
this.border.removeClass("static-border");
this.border.addClass("anim-border");
this.tools.removeClass("d-none");
if(this.textareaExtra != null) {
this.textareaExtra.removeClass("sign-textarea-lock");
this.textareaExtra.focus();
if(this.textareaPart != null) {
this.textareaPart.removeClass("sign-textarea-lock");
this.textareaPart.focus();
this.cross.draggable("disable");
}
}

Expand Down Expand Up @@ -610,16 +616,36 @@ export class SignRequestParams extends EventFactory {
this.cross.append(divExtraHtml);
this.cross.attr('title', 'Double click pour éditer');
this.textareaPart = $("#textPart_" + this.id);
this.textareaPart.css('pointer-events', 'none');
this.textareaPart.css('width', '100%');
// this.textareaPart.css('height', '100%');
this.textareaPart.on("input", function () {
self.resizeText();
});
this.cross.dblclick(function() {
self.textareaPart.focus();
});
// this.cross.dblclick(function() {
// self.textareaPart.focus();
// });
this.resizeText();
this.cross.resizable("destroy");
let textGrow = $("#textGrow_" + this.id);
let textReduce = $("#textReduce_" + this.id);
textGrow.show();
textReduce.show();
textGrow.on("click", function () {
self.fontSize = self.fontSize + 1
self.resizeText();
});
textReduce.on("click", function () {
self.fontSize = self.fontSize - 1
self.resizeText();
});
this.textareaPart.focusout(function (){
self.cross.draggable("enable");
self.textareaPart.css('pointer-events', 'none');
});
this.textareaPart.focusin(function (){
self.cross.draggable("disable");
self.textareaPart.css('pointer-events', 'auto');
});
}

resizeText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="ms-1 mt-2">
<h5 class="text-center sidebar-label"><b>Filtres</b></h5>
<a th:classappend="${statusFilter == ''} ? 'btn-secondary' : 'btn-light'" class="btn col-3 col-md-12 mb-1 text-left" href="/user/signrequests/?statusFilter=all">Tout voir</a>
<div class="hr"><i class="fas fa-inbox me-1"></i><span class="sidebar-label"> Demandes reçus</span></div>
<div class="hr"><i class="fas fa-inbox me-1"></i><span class="sidebar-label"> Demandes reçues</span></div>
<a th:classappend="${statusFilter == 'tosign'} ? 'btn-secondary' : 'btn-light'" class="btn col-3 col-md-12 mb-1 text-left" href="/user/signrequests/?statusFilter=tosign">
<span class="sidebar-label">A signer</span>
<span title="Demandes à signer" th:if="${nbToSign > 0 && userEppn == authUserEppn}" class="badge bg-danger d-none d-md-inline" th:text="${nbToSign}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</th:block>
</div>
<div id="second-tools" class="d-none mb-1">
<th:block th:if="${toSignDocument.contentType == 'application/pdf'}">
<th:block th:if="${toSignDocument.contentType == 'application/pdf' && (signRequest.status == T(org.esupportail.esupsignature.entity.enums.SignRequestStatus).draft || signRequest.status == T(org.esupportail.esupsignature.entity.enums.SignRequestStatus).pending || comments.size() > 0)}">
<div class="btn btn-outline-dark disabled text-dark me-1">Choix du mode : </div>
<div class="me-1">
<select id="changeMode" name="changeMode" class=""></select>
Expand Down
Loading

0 comments on commit cff0bc4

Please sign in to comment.