feat: support decimal on weight
This commit is contained in:
parent
2fd09af0ea
commit
d857fce71f
@ -43,8 +43,8 @@ public class CompetitionGuestModel implements CombModel {
|
||||
|
||||
String country = "fr";
|
||||
|
||||
Integer weight = null;
|
||||
Integer weightReal = null;
|
||||
Float weight = null;
|
||||
Float weightReal = null;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
|
||||
@JoinTable(
|
||||
@ -109,7 +109,7 @@ public class CompetitionGuestModel implements CombModel {
|
||||
return Stream.concat(comb.stream(), guest.stream()).anyMatch(c -> Objects.equals(c, comb_));
|
||||
}
|
||||
|
||||
public Integer getWeight2() {
|
||||
public Float getWeight2() {
|
||||
return (this.weightReal != null) ? this.weightReal : this.weight;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ public class RegisterModel {
|
||||
@JoinColumn(name = "id_membre")
|
||||
MembreModel membre;
|
||||
|
||||
Integer weight;
|
||||
Integer weightReal;
|
||||
Float weight;
|
||||
Float weightReal;
|
||||
int overCategory = 0;
|
||||
Categorie categorie;
|
||||
|
||||
@ -61,7 +61,7 @@ public class RegisterModel {
|
||||
)
|
||||
List<CatPresetModel> categoriesInscrites = new ArrayList<>();
|
||||
|
||||
public RegisterModel(CompetitionModel competition, MembreModel membre, Integer weight, int overCategory,
|
||||
public RegisterModel(CompetitionModel competition, MembreModel membre, Float weight, int overCategory,
|
||||
Categorie categorie, ClubModel club) {
|
||||
this.id = new RegisterId(competition.getId(), membre.getId());
|
||||
this.competition = competition;
|
||||
@ -91,7 +91,7 @@ public class RegisterModel {
|
||||
return Categorie.values()[Math.min(tmp.ordinal() + this.overCategory, Categorie.values().length - 1)];
|
||||
}
|
||||
|
||||
public Integer getWeight2() {
|
||||
public Float getWeight2() {
|
||||
if (weightReal != null)
|
||||
return weightReal;
|
||||
return weight;
|
||||
|
||||
@ -27,7 +27,7 @@ public class CombEntity {
|
||||
Genre genre;
|
||||
String country;
|
||||
int overCategory;
|
||||
Integer weight;
|
||||
Float weight;
|
||||
List<CombEntity> teamMembers;
|
||||
List<Long> categoriesInscrites;
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ public class CompetitionData {
|
||||
public static class SimpleRegister {
|
||||
long id;
|
||||
int overCategory;
|
||||
Integer weight;
|
||||
Float weight;
|
||||
Categorie categorie;
|
||||
Long club;
|
||||
String club_str;
|
||||
|
||||
@ -18,8 +18,8 @@ public class RegisterRequestData {
|
||||
private String fname;
|
||||
private String lname;
|
||||
|
||||
private Integer weight;
|
||||
private Integer weightReal;
|
||||
private Float weight;
|
||||
private Float weightReal;
|
||||
private Integer overCategory;
|
||||
private boolean lockEdit = false;
|
||||
private List<Long> categoriesInscrites;
|
||||
|
||||
@ -26,8 +26,8 @@ public class SimpleRegisterComb {
|
||||
private Categorie categorie;
|
||||
private SimpleClubModel club;
|
||||
private Integer licence;
|
||||
private Integer weight;
|
||||
private Integer weightReal;
|
||||
private Float weight;
|
||||
private Float weightReal;
|
||||
private int overCategory;
|
||||
private boolean hasLicenceActive;
|
||||
private boolean lockEdit;
|
||||
|
||||
@ -86,7 +86,7 @@ public class RTeam {
|
||||
.max(Integer::compareTo)
|
||||
.map(i -> Categorie.values()[i]).orElse(Categorie.SENIOR1));
|
||||
|
||||
List<Integer> s = Stream.concat(
|
||||
List<Float> s = Stream.concat(
|
||||
pair.getKey().stream().map(RegisterModel::getWeight),
|
||||
pair.getValue().stream().map(CompetitionGuestModel::getWeight))
|
||||
.filter(Objects::nonNull).toList();
|
||||
@ -95,7 +95,7 @@ public class RTeam {
|
||||
} else if (s.size() == 1) {
|
||||
team.setWeight(s.get(0));
|
||||
} else {
|
||||
team.setWeight((int) s.stream().mapToInt(Integer::intValue)
|
||||
team.setWeight((float) s.stream().mapToDouble(Float::doubleValue)
|
||||
.average()
|
||||
.orElse(0));
|
||||
}
|
||||
|
||||
@ -554,11 +554,11 @@ function Modal_({data2, data3, error2, sendRegister, modalState, setModalState,
|
||||
<div className="input-group mb-3">
|
||||
<span className="input-group-text" id="weight">{t('comp.modal.poids')}</span>
|
||||
{source === "admin" && <span className="input-group-text" id="weightReal">{t('comp.modal.annoncé')}</span>}
|
||||
<input type="number" min={1} step={1} className="form-control" placeholder="--" aria-label="weight"
|
||||
<input type="number" min={1} step={0.1} className="form-control" placeholder="--" aria-label="weight"
|
||||
name="weight" aria-describedby="weight" disabled={!(data3.requiredWeight.includes(currenCat))} value={weight}
|
||||
onChange={e => setWeight(e.target.value)}/>
|
||||
{source === "admin" && <><span className="input-group-text" id="weightReal">{t('comp.modal.pesé')}</span>
|
||||
<input type="number" min={1} step={1} className="form-control" placeholder="--" aria-label="weightReal"
|
||||
<input type="number" min={1} step={0.1} className="form-control" placeholder="--" aria-label="weightReal"
|
||||
name="weightReal" aria-describedby="weightReal" value={weightReal}
|
||||
onChange={e => setWeightReal(e.target.value)}/></>}
|
||||
</div>
|
||||
|
||||
@ -156,11 +156,11 @@ function SelfRegister({data2}) {
|
||||
<h4 style={{textAlign: "left"}}>{t('comp.monInscription')}</h4>
|
||||
<div className="input-group mb-3" hidden={!(data2?.requiredWeight.includes(currenCat))}>
|
||||
<span className="input-group-text" id="weight">{t("comp.modal.poids")}</span>
|
||||
<input type="number" min={1} step={1} className="form-control" placeholder="--" aria-label="weight" disabled={disabled}
|
||||
<input type="number" min={1} step={0.1} className="form-control" placeholder="--" aria-label="weight" disabled={disabled}
|
||||
name="weight" aria-describedby="weight" value={weight} onChange={e => setWeight(e.target.value)}/>
|
||||
{data[0]?.weightReal && <>
|
||||
<span className="input-group-text" id="weight">{t("comp.modal.pesé")}</span>
|
||||
<input type="number" min={1} step={1} className="form-control" placeholder="--" aria-label="weight" disabled={true}
|
||||
<input type="number" min={1} step={0.1} className="form-control" placeholder="--" aria-label="weight" disabled={true}
|
||||
name="weight" aria-describedby="weight" value={data[0]?.weightReal} onChange={() => {
|
||||
}}/>
|
||||
</>}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user