-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GMS-179 New reusable Angular component has been created to simplify m…
…essage displays
- Loading branch information
1 parent
93ab535
commit 3710101
Showing
11 changed files
with
115 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
code/gms-frontend/src/app/common/components/info-dialog/info-dialog.component.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...frontend/src/app/common/components/information-message/information-message.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div [ngClass]="styleClass"> | ||
<mat-icon class="v-bottom {{iconColor}}" aria-hidden="false">{{icon}}</mat-icon> | ||
<ng-content></ng-content> | ||
</div> |
13 changes: 13 additions & 0 deletions
13
...frontend/src/app/common/components/information-message/information-message.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@import '../../../../globals.scss'; | ||
|
||
.green { | ||
color: $success_dark; | ||
} | ||
|
||
.orange { | ||
color: $warning; | ||
} | ||
|
||
.blue { | ||
color: $information; | ||
} |
37 changes: 37 additions & 0 deletions
37
...ntend/src/app/common/components/information-message/information-message.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core"; | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { MatDialogModule } from "@angular/material/dialog"; | ||
import { TranslatorModule } from "../pipes/translator/translator.module"; | ||
import { InformationMessageComponent } from "./information-message.component"; | ||
|
||
/** | ||
* @author Peter Szrnka | ||
*/ | ||
describe('InformationMessageComponent', () => { | ||
let component : InformationMessageComponent; | ||
|
||
// Fixtures | ||
let fixture : ComponentFixture<InformationMessageComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports : [MatDialogModule, TranslatorModule ], | ||
declarations : [InformationMessageComponent], | ||
schemas : [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], | ||
providers: [ | ||
] | ||
}); | ||
}); | ||
|
||
it('onInit when component loaded then set parameters properly', () => { | ||
fixture = TestBed.createComponent(InformationMessageComponent); | ||
component = fixture.componentInstance; | ||
component.severity = 'information'; | ||
fixture.detectChanges(); | ||
|
||
expect(component).toBeTruthy(); | ||
expect(component.severity).toBe('information'); | ||
expect(component.icon).toBe('information'); | ||
expect(component.iconColor).toBe('blue'); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
...s-frontend/src/app/common/components/information-message/information-message.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
|
||
const SETTINGS_MAP: any = { | ||
'success': { icon: 'check_circle', iconColor: 'green', styleClass: 'success' }, | ||
'information': { icon: 'information', iconColor: 'blue', styleClass: 'information' }, | ||
'warning': { icon: 'warning', iconColor: 'orange', styleClass: 'warning' } | ||
}; | ||
|
||
/** | ||
* @author Peter Szrnka | ||
*/ | ||
@Component({ | ||
|
||
selector: 'information-message', | ||
templateUrl: './information-message.component.html', | ||
styleUrls: ['./information-message.component.scss'] | ||
}) | ||
export class InformationMessageComponent implements OnInit { | ||
|
||
@Input() severity: 'success' | 'information' | 'warning' = 'warning'; | ||
icon: string = ''; | ||
iconColor: string = ''; | ||
styleClass: string = ''; | ||
|
||
ngOnInit(): void { | ||
this.icon = SETTINGS_MAP[this.severity].icon; | ||
this.iconColor = SETTINGS_MAP[this.severity].iconColor; | ||
this.styleClass = SETTINGS_MAP[this.severity].styleClass; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,4 +190,8 @@ td { | |
padding: 5px; | ||
margin-left: 5px; | ||
color: white; | ||
} | ||
} | ||
|
||
.v-bottom { | ||
vertical-align: bottom !important; | ||
} |