corrections: Impossible de créer plus que un (deux?) mélanges avec le même nom

This commit is contained in:
FyloZ 2020-03-09 10:52:57 -04:00
parent 24ae85f56f
commit 499435387e
7 changed files with 26 additions and 14 deletions

View File

@ -38,12 +38,12 @@ public class MixType implements IModel {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MixType mixType = (MixType) o;
return Objects.equals(id, mixType.id) &&
Objects.equals(name, mixType.name);
return Objects.equals(name, mixType.name) &&
Objects.equals(material, mixType.material);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
return Objects.hash(name, material);
}
}

View File

@ -120,6 +120,7 @@ public class MixService extends AbstractService<Mix, MixDao> {
if (materialService.existsByName(mixType.getName()) && !materialService.getByName(mixType.getName()).isMixType())
throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.OTHER, MixType.IDENTIFIER_MATERIAL_NAME, mixType.getName());
mixTypeService.update(mixType);
update(mix);
}

View File

@ -37,10 +37,10 @@ public class SIMDUTFilesController {
headers.setContentType(MediaType.APPLICATION_PDF);
return new ResponseEntity<>(simdutContent, headers, HttpStatus.OK);
} else {
headers.add("Location", request.getHeader("referer"));
headers.add("Location", "/" + CLOSE_TAB);
}
} catch (EntityNotFoundException ex) {
headers.add("Location", "/" + CLOSE_TAB);
headers.add("Location", request.getHeader("referer"));
}
return new ResponseEntity<>(headers, HttpStatus.FOUND);

View File

@ -14,13 +14,10 @@ $(() => {
const materialID = row.data("materialid");
// SIMDUT
axios.post(`/simdut/${materialID}`)
.catch(function (err) {
if (err.response.status === 404) {
row.parent().addClass("nosimdut");
row.parent().title = simdutNotFoundText;
}
});
if (!checkSimdutAvailability(materialID)) {
row.parent().addClass("nosimdut");
row.parent().title = simdutNotFoundText;
}
});
$(".messageBox").each(function () {
checkMessageBoxesDisplay($(this)[0])
@ -85,6 +82,17 @@ $(() => {
});
});
function checkSimdutAvailability(materialId) {
axios.post(`/simdut/${materialId}`)
.then(function (d) {
return true;
})
.catch(function (err) {
if (err.response.status === 404) return false;
else return false;
});
}
function confirmDatabaseExport() {
showConfirm(exportAllWarningText, false, () => {
window.location.href = "./recipe/xls";

View File

@ -102,6 +102,9 @@
window.location.href = `/material/simdut/${materialId}`;
}
});
console.log(checkSimdutAvailability(materialId));
if (!checkSimdutAvailability(materialId)) $("#showSIMDUT").hide();
});
function switchUnits(unitSelect) {

View File

@ -133,7 +133,7 @@
<tr th:each="mixQuantity : ${mix.mixQuantities}"
th:with="material = ${mixQuantity.material}"
th:id="'material-' + ${material.id}">
<td class="materialCodeColumn"
<td class="materialCodeColumn materialCode"
th:classappend="${material.isMixType()} ? '' : name"
th:data-materialId="${material.id}"
th:text="${material.name}"></td>

View File

@ -121,7 +121,7 @@
class="materialRow"
th:data-materialtypename="${material.materialType.name}"
th:id="'material-' + ${material.id}">
<td class="materialCodeColumn"
<td class="materialCodeColumn materialCode"
th:classappend="${material.isMixType()} ? '' : name"
th:data-materialId="${material.id}"
th:text="${material.name}"></td>