From 7599479e5932a9c66b84ab204d6b850353fa9efd Mon Sep 17 00:00:00 2001 From: FyloZ Date: Mon, 8 Feb 2021 19:53:19 -0500 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20endpoint=20pour=20r=C3=A9cup?= =?UTF-8?q?=C3=A9rer=20les=20m=C3=A9langes=20qui=20ne=20sont=20pas=20des?= =?UTF-8?q?=20types=20de=20m=C3=A9lange.=20R=C3=A9paration=20de=20la=20mod?= =?UTF-8?q?ification=20du=20fichier=20SIMDUT=20des=20produits.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/pages/edit/edit.component.html | 9 ++++--- .../material/pages/edit/edit.component.ts | 5 ++-- .../material/pages/list/list.component.ts | 2 +- .../material/service/material.service.ts | 10 +++++--- .../rest/MaterialController.kt | 24 +++++++++++-------- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/main/frontend/src/app/modules/material/pages/edit/edit.component.html b/src/main/frontend/src/app/modules/material/pages/edit/edit.component.html index e52a94a..fae31be 100644 --- a/src/main/frontend/src/app/modules/material/pages/edit/edit.component.html +++ b/src/main/frontend/src/app/modules/material/pages/edit/edit.component.html @@ -14,9 +14,7 @@ + #simdutTemplate>
diff --git a/src/main/frontend/src/app/modules/material/pages/edit/edit.component.ts b/src/main/frontend/src/app/modules/material/pages/edit/edit.component.ts index a194cda..6a17fc0 100644 --- a/src/main/frontend/src/app/modules/material/pages/edit/edit.component.ts +++ b/src/main/frontend/src/app/modules/material/pages/edit/edit.component.ts @@ -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 => { diff --git a/src/main/frontend/src/app/modules/material/pages/list/list.component.ts b/src/main/frontend/src/app/modules/material/pages/list/list.component.ts index 43c578a..5fc6e62 100644 --- a/src/main/frontend/src/app/modules/material/pages/list/list.component.ts +++ b/src/main/frontend/src/app/modules/material/pages/list/list.component.ts @@ -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}, diff --git a/src/main/frontend/src/app/modules/material/service/material.service.ts b/src/main/frontend/src/app/modules/material/service/material.service.ts index fc167fb..c8ea1d8 100644 --- a/src/main/frontend/src/app/modules/material/service/material.service.ts +++ b/src/main/frontend/src/app/modules/material/service/material.service.ts @@ -17,6 +17,10 @@ export class MaterialService { return this.api.get('/material') } + get allNotMixType(): Observable { + return this.api.get('/material/notmixtype') + } + getAllForMixCreation(recipeId: number): Observable { return this.api.get(`/material/mix/create/${recipeId}`) } @@ -44,14 +48,14 @@ export class MaterialService { return this.api.post('/material/', body) } - update(id: number, name: string, inventoryQuantity: number, materialType: number, simdutFile: FileInput): Observable { + update(id: number, name: string, inventoryQuantity: number, materialType: number, simdutFile: File): Observable { 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('/material/', body) } diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/rest/MaterialController.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/rest/MaterialController.kt index 8a29191..a784ca6 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/rest/MaterialController.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/rest/MaterialController.kt @@ -21,6 +21,20 @@ class MaterialController(materialService: MaterialService) : materialService, MATERIAL_CONTROLLER_PATH ) { + @GetMapping("notmixtype") + fun getAllNotMixType(): ResponseEntity> = + ResponseEntity.ok(service.getAllNotMixType()) + + @GetMapping("mix/create/{recipeId}") + @ResponseStatus(HttpStatus.OK) + fun getAllForMixCreation(@PathVariable recipeId: Long): ResponseEntity> = + ResponseEntity.ok(service.getAllForMixCreation(recipeId)) + + @GetMapping("mix/update/{mixId}") + @ResponseStatus(HttpStatus.OK) + fun getAllForMixUpdate(@PathVariable mixId: Long): ResponseEntity> = + ResponseEntity.ok(service.getAllForMixUpdate(mixId)) + @GetMapping("{id}/simdut/exists") @ResponseStatus(HttpStatus.OK) fun hasSimdut(@PathVariable id: Long): ResponseEntity = @@ -38,16 +52,6 @@ class MaterialController(materialService: MaterialService) : } } - @GetMapping("mix/create/{recipeId}") - @ResponseStatus(HttpStatus.OK) - fun getAllForMixCreation(@PathVariable recipeId: Long): ResponseEntity> = - ResponseEntity.ok(service.getAllForMixCreation(recipeId)) - - @GetMapping("mix/update/{mixId}") - @ResponseStatus(HttpStatus.OK) - fun getAllForMixUpdate(@PathVariable mixId: Long): ResponseEntity> = - ResponseEntity.ok(service.getAllForMixUpdate(mixId)) - @PostMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) fun saveTest(@Valid entity: MaterialSaveDto, simdutFile: MultipartFile?): ResponseEntity = super.save(