Ajout d'un endpoint pour récupérer les mélanges qui ne sont pas des types de mélange.
Réparation de la modification du fichier SIMDUT des produits.
This commit is contained in:
parent
99e30672ce
commit
7599479e59
|
@ -14,9 +14,7 @@
|
|||
|
||||
|
||||
<ng-template
|
||||
#simdutTemplate
|
||||
let-control="control"
|
||||
let-field="field">
|
||||
#simdutTemplate>
|
||||
<div class="simdut-file w-100 d-flex justify-content-between">
|
||||
<button
|
||||
mat-raised-button
|
||||
|
@ -27,10 +25,11 @@
|
|||
Voir la fiche signalitique
|
||||
</button>
|
||||
<cre-file-button
|
||||
#simdutFileButton
|
||||
color="accent"
|
||||
label="Modifier la fiche signalitique"
|
||||
[accept]="field.accept"
|
||||
[control]="control">
|
||||
accept="application/pdf"
|
||||
(change)="selectedSimdutFile = $event.target.files[0]">
|
||||
</cre-file-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
|
|
@ -8,6 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
|||
import {SubscribingComponent} from "../../../shared/components/subscribing.component";
|
||||
import {Material} from "../../../shared/model/material.model";
|
||||
import {environment} from "../../../../../environments/environment";
|
||||
import {FileButtonComponent} from "../../../shared/file-button/file-button.component";
|
||||
|
||||
@Component({
|
||||
selector: 'cre-edit',
|
||||
|
@ -16,7 +17,6 @@ import {environment} from "../../../../../environments/environment";
|
|||
})
|
||||
export class EditComponent extends SubscribingComponent {
|
||||
@ViewChild('simdutTemplate', {static: true}) simdutTemplateRef
|
||||
@ViewChild('simdutFileInput') simdutFileInput
|
||||
|
||||
material: Material | null
|
||||
formFields: FormField[] = [
|
||||
|
@ -67,6 +67,7 @@ export class EditComponent extends SubscribingComponent {
|
|||
unknownError = false
|
||||
errorMessage: string | null
|
||||
hasSimdut = false
|
||||
selectedSimdutFile: File | null
|
||||
|
||||
constructor(
|
||||
private materialService: MaterialService,
|
||||
|
@ -106,7 +107,7 @@ export class EditComponent extends SubscribingComponent {
|
|||
|
||||
submit(values) {
|
||||
this.subscribe(
|
||||
this.materialService.update(this.material.id, values.name, values.inventoryQuantity, values.materialType, values.simdutFile),
|
||||
this.materialService.update(this.material.id, values.name, values.inventoryQuantity, values.materialType, this.selectedSimdutFile),
|
||||
{
|
||||
next: () => this.router.navigate(['/catalog/material/list']),
|
||||
error: err => {
|
||||
|
|
|
@ -12,7 +12,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
|||
styleUrls: ['./list.component.sass']
|
||||
})
|
||||
export class ListComponent extends SubscribingComponent {
|
||||
materials$ = this.materialService.all
|
||||
materials$ = this.materialService.allNotMixType
|
||||
columns = [
|
||||
{def: 'name', title: 'Code', valueFn: t => t.name},
|
||||
{def: 'inventoryQuantity', title: 'Quantité', valueFn: t => t.inventoryQuantity},
|
||||
|
|
|
@ -17,6 +17,10 @@ export class MaterialService {
|
|||
return this.api.get<Material[]>('/material')
|
||||
}
|
||||
|
||||
get allNotMixType(): Observable<Material[]> {
|
||||
return this.api.get<Material[]>('/material/notmixtype')
|
||||
}
|
||||
|
||||
getAllForMixCreation(recipeId: number): Observable<Material[]> {
|
||||
return this.api.get<Material[]>(`/material/mix/create/${recipeId}`)
|
||||
}
|
||||
|
@ -44,14 +48,14 @@ export class MaterialService {
|
|||
return this.api.post<void>('/material/', body)
|
||||
}
|
||||
|
||||
update(id: number, name: string, inventoryQuantity: number, materialType: number, simdutFile: FileInput): Observable<void> {
|
||||
update(id: number, name: string, inventoryQuantity: number, materialType: number, simdutFile: File): Observable<void> {
|
||||
const body = new FormData()
|
||||
body.append('id', id.toString())
|
||||
body.append('name', name)
|
||||
body.append('inventoryQuantity', inventoryQuantity.toString())
|
||||
body.append('materialType', materialType.toString())
|
||||
if (simdutFile && simdutFile.files) {
|
||||
body.append('simdutFile', simdutFile.files[0])
|
||||
if (simdutFile) {
|
||||
body.append('simdutFile', simdutFile)
|
||||
}
|
||||
return this.api.put<void>('/material/', body)
|
||||
}
|
||||
|
|
|
@ -21,6 +21,20 @@ class MaterialController(materialService: MaterialService) :
|
|||
materialService,
|
||||
MATERIAL_CONTROLLER_PATH
|
||||
) {
|
||||
@GetMapping("notmixtype")
|
||||
fun getAllNotMixType(): ResponseEntity<Collection<Material>> =
|
||||
ResponseEntity.ok(service.getAllNotMixType())
|
||||
|
||||
@GetMapping("mix/create/{recipeId}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
fun getAllForMixCreation(@PathVariable recipeId: Long): ResponseEntity<Collection<Material>> =
|
||||
ResponseEntity.ok(service.getAllForMixCreation(recipeId))
|
||||
|
||||
@GetMapping("mix/update/{mixId}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
fun getAllForMixUpdate(@PathVariable mixId: Long): ResponseEntity<Collection<Material>> =
|
||||
ResponseEntity.ok(service.getAllForMixUpdate(mixId))
|
||||
|
||||
@GetMapping("{id}/simdut/exists")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
fun hasSimdut(@PathVariable id: Long): ResponseEntity<Boolean> =
|
||||
|
@ -38,16 +52,6 @@ class MaterialController(materialService: MaterialService) :
|
|||
}
|
||||
}
|
||||
|
||||
@GetMapping("mix/create/{recipeId}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
fun getAllForMixCreation(@PathVariable recipeId: Long): ResponseEntity<Collection<Material>> =
|
||||
ResponseEntity.ok(service.getAllForMixCreation(recipeId))
|
||||
|
||||
@GetMapping("mix/update/{mixId}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
fun getAllForMixUpdate(@PathVariable mixId: Long): ResponseEntity<Collection<Material>> =
|
||||
ResponseEntity.ok(service.getAllForMixUpdate(mixId))
|
||||
|
||||
@PostMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
|
||||
fun saveTest(@Valid entity: MaterialSaveDto, simdutFile: MultipartFile?): ResponseEntity<Material> =
|
||||
super.save(
|
||||
|
|
Loading…
Reference in New Issue