Corrections recipeApprobationExpired

This commit is contained in:
FyloZ 2021-04-12 10:10:19 -04:00
parent 75f6e3f0b9
commit a046572724
5 changed files with 18 additions and 4 deletions

View File

@ -16,6 +16,10 @@
<p>Non approuvée</p>
<mat-icon svgIcon="alert" class="color-warning"></mat-icon>
</div>
<div *ngIf="isApprobationExpired" class="recipe-not-approved-wrapper d-flex flex-row" title="Cette recette a été approuvée il y a plus de 4 ans">
<p>Approbation expirée</p>
<mat-icon svgIcon="clock-alert" class="color-warning"></mat-icon>
</div>
<p>{{recipe.remark}}</p>
</div>
<div class="recipe-description">

View File

@ -1,5 +1,5 @@
import {AfterViewInit, Component, Input} from '@angular/core'
import {getRecipeLuma, Recipe} from '../../../shared/model/recipe.model'
import {getRecipeLuma, recipeApprobationExpired, Recipe} from '../../../shared/model/recipe.model'
@Component({
selector: 'cre-recipe-info',
@ -17,6 +17,10 @@ export class RecipeInfoComponent implements AfterViewInit {
this.isBPacExtensionInstalled = document.querySelectorAll('.bpac-extension-installed').length > 0
}
get isApprobationExpired(): boolean {
return recipeApprobationExpired(this.recipe)
}
get isDarkColor(): boolean {
return getRecipeLuma(this.recipe) < 100
}

View File

@ -2,7 +2,7 @@ import {Component} from '@angular/core'
import {RecipeService} from '../../services/recipe.service'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {MixMaterialDto, Recipe, recipeMixCount, recipeNoteForGroupId, recipeStepCount} from '../../../shared/model/recipe.model'
import {MixMaterialDto, Recipe, recipeMixCount, recipeNoteForGroupId, recipeStepCount, recipeApprobationExpired} from '../../../shared/model/recipe.model'
import {Observable, Subject} from 'rxjs'
import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
import {AlertService} from '../../../shared/service/alert.service'

View File

@ -3,7 +3,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {RecipeService} from '../../services/recipe.service'
import {EmployeePermission} from '../../../shared/model/employee'
import {AccountService} from '../../../accounts/services/account.service'
import {getRecipeLuma, isRecipeApprobationExpired, Recipe} from '../../../shared/model/recipe.model'
import {getRecipeLuma, recipeApprobationExpired, Recipe} from '../../../shared/model/recipe.model'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorModel, ErrorService} from '../../../shared/service/error.service'
@ -53,7 +53,7 @@ export class ListComponent extends ErrorHandlingComponent {
}
isRecipeApprobationExpired(recipe: Recipe): boolean {
return isRecipeApprobationExpired(recipe)
return recipeApprobationExpired(recipe)
}
isCompanyHidden(companyRecipes: Recipe[]): boolean {

View File

@ -124,3 +124,9 @@ export function getRecipeLuma(recipe: Recipe): number {
return 0.2126 * r + 0.7152 * g + 0.0722 * b // per ITU-R BT.709
}
// TODO hard-coded for prototype
export function recipeApprobationExpired(recipe: Recipe): boolean {
// @ts-ignore
return recipe.approbationDate && LocalDate.parse(recipe.approbationDate).year() < new Date().getFullYear() - 4
}