diff --git a/src/app/admin-view/grades/grades.component.html b/src/app/admin-view/grades/grades.component.html index b6128ee..c0f32d7 100644 --- a/src/app/admin-view/grades/grades.component.html +++ b/src/app/admin-view/grades/grades.component.html @@ -2,7 +2,7 @@

Czystość pokoju {{room}} na {{_date.toFormat("cccc, D")}}

-

Ocena: {{grade}}

+

Ocena: {{grade}}

@@ -31,4 +31,4 @@ Dodatkowe uwagi - \ No newline at end of file + diff --git a/src/app/app-view/personal/clean/clean.component.html b/src/app/app-view/personal/clean/clean.component.html index b792069..57fd27d 100644 --- a/src/app/app-view/personal/clean/clean.component.html +++ b/src/app/app-view/personal/clean/clean.component.html @@ -1,7 +1,7 @@

Czystość

@if (grade) { -

Twoja ocena: {{grade}}

+

Twoja ocena: {{grade}}

} @else {

Nie oceniono

@@ -21,4 +21,4 @@
- \ No newline at end of file + diff --git a/src/app/app-view/personal/clean/clean.component.ts b/src/app/app-view/personal/clean/clean.component.ts index 8eea445..a5fbc2a 100644 --- a/src/app/app-view/personal/clean/clean.component.ts +++ b/src/app/app-view/personal/clean/clean.component.ts @@ -38,23 +38,4 @@ export class CleanComponent implements OnInit { } }) } - - protected gradeColor() { - switch (this.grade) { - case 1: - return { color: 'red' } - case 2: - return { color: 'darkorange' } - case 3: - return { color: 'orange' } - case 4: - return { color: 'olive' } - case 5: - return { color: 'green' } - case 6: - return { color: 'springgreen' } - default: - return { color: 'inherit' } - } - } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 80ca0a5..0819b2f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -87,6 +87,7 @@ import { UserSearchComponent } from './commonComponents/user-search/user-search. import { StartAdminComponent } from './admin-view/start/start.component' import { provideLuxonDateAdapter } from '@angular/material-luxon-adapter'; import { LoadShadeComponent } from './commonComponents/load-shade/load-shade.component' +import { GradeColorDirective } from './grade-color.directive' @NgModule({ declarations: [ @@ -139,6 +140,7 @@ import { LoadShadeComponent } from './commonComponents/load-shade/load-shade.com UserSearchComponent, StartAdminComponent, LoadShadeComponent, + GradeColorDirective, ], bootstrap: [AppComponent], imports: [ diff --git a/src/app/grade-color.directive.spec.ts b/src/app/grade-color.directive.spec.ts new file mode 100644 index 0000000..2d59b3e --- /dev/null +++ b/src/app/grade-color.directive.spec.ts @@ -0,0 +1,8 @@ +import { GradeColorDirective } from './grade-color.directive'; + +describe('GradeColorDirective', () => { + it('should create an instance', () => { + const directive = new GradeColorDirective(); + expect(directive).toBeTruthy(); + }); +}); diff --git a/src/app/grade-color.directive.ts b/src/app/grade-color.directive.ts new file mode 100644 index 0000000..6c36929 --- /dev/null +++ b/src/app/grade-color.directive.ts @@ -0,0 +1,33 @@ +import { Directive, HostBinding, input } from '@angular/core'; + +@Directive({ + selector: 'span[appGradeColor]', + standalone: false +}) +export class GradeColorDirective { + + appGradeColor = input() + + constructor() { } + + @HostBinding("style") + get gc() { + switch (this.appGradeColor()) { + case 1: + return { color: 'red' } + case 2: + return { color: 'darkorange' } + case 3: + return { color: 'orange' } + case 4: + return { color: 'olive' } + case 5: + return { color: 'green' } + case 6: + return { color: 'springgreen' } + default: + return { color: 'inherit' } + } + } + +}