Merge branch 'features' into 'master'

Ajout de plusieurs fonctionnalités

See merge request color-recipes-explorer/frontend!15
This commit is contained in:
William Nolin 2021-04-06 14:56:56 +00:00
commit d4e6429992
4 changed files with 38 additions and 8 deletions

View File

@ -72,13 +72,12 @@
<td mat-cell *matCellDef="let mixMaterial">
<mat-form-field *ngIf="materials">
<mat-select
#select
[value]="mixMaterial.materialId"
(valueChange)="setMixMaterialMaterial(mixMaterial, $event)">
<mat-option
*ngFor="let material of getAvailableMaterials(mixMaterial)"
*ngFor="let material of sortedMaterials(getAvailableMaterials(mixMaterial))"
[value]="material.id">
{{material.name}}
{{materialDisplayName(material)}}
</mat-option>
</mat-select>
</mat-form-field>

View File

@ -4,7 +4,7 @@ import {
MixMaterial,
MixMaterialDto,
mixMaterialsAsMixMaterialsDto,
Recipe, RecipeStep,
Recipe,
sortMixMaterialsDto
} from '../../../shared/model/recipe.model'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
@ -21,7 +21,6 @@ import {ConfirmBoxComponent} from '../../../shared/components/confirm-box/confir
import {AccountService} from '../../../accounts/services/account.service'
import {EmployeePermission} from '../../../shared/model/employee'
import {ErrorService} from '../../../shared/service/error.service'
import {MatSelect} from '@angular/material/select'
@Component({
selector: 'cre-mix-editor',
@ -156,6 +155,37 @@ export class MixEditorComponent extends ErrorHandlingComponent {
return this.materials.filter(m => mixMaterial.materialId === m.id || this.mixMaterials.filter(mm => mm.materialId === m.id).length === 0)
}
materialDisplayName(material: Material): string {
if (material.materialType.prefix) {
return `[${material.materialType.prefix}] ${material.name}`
}
return material.name
}
sortedMaterials(materials: Material[]): Material[] {
return materials.sort((a, b) => {
const aPrefixName = a.materialType.prefix.toLowerCase()
const bPrefixName = b.materialType.prefix.toLowerCase()
if (aPrefixName < bPrefixName) {
return -1
} else if (aPrefixName > bPrefixName) {
return 1
} else {
const aName = a.name.toLowerCase()
const bName = b.name.toLowerCase()
if (aName < bName) {
return -1
} else if (aName > bName) {
return 1
} else {
return 0
}
}
})
}
get canDeleteMix() {
return this.accountService.hasPermission(EmployeePermission.REMOVE_RECIPES)
}

View File

@ -65,7 +65,8 @@ export class ListComponent extends ErrorHandlingComponent {
}
private recipeMatchesSearchQuery(recipe: Recipe) {
const matches = this.searchString(recipe.name) ||
const matches = this.searchString(recipe.company.name) ||
this.searchString(recipe.name) ||
this.searchString(recipe.description) ||
(recipe.sample && this.searchString(recipe.sample.toString()))
this.hiddenRecipes[recipe.id] = !matches

View File

@ -45,7 +45,7 @@ export class MaterialService {
const body = new FormData()
body.append('name', name)
body.append('inventoryQuantity', inventoryQuantity.toString())
body.append('materialType', materialType.toString())
body.append('materialTypeId', materialType.toString())
if (simdutFile && simdutFile.files) {
body.append('simdutFile', simdutFile.files[0])
}
@ -57,7 +57,7 @@ export class MaterialService {
body.append('id', id.toString())
body.append('name', name)
body.append('inventoryQuantity', inventoryQuantity.toString())
body.append('materialType', materialType.toString())
body.append('materialTypeId', materialType.toString())
if (simdutFile) {
body.append('simdutFile', simdutFile)
}