This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/show model errors in library (#400)
* Extracting short error message display to component * Removing unnecessary css class
- Loading branch information
Showing
12 changed files
with
125 additions
and
27 deletions.
There are no files selected for viewing
Empty file.
2 changes: 2 additions & 0 deletions
2
...s/short-error-message-display/components/short-model-error-message-display.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,2 @@ | ||
<span *ngIf="hasErrors" class="text-danger"><i aria-hidden="true" | ||
class="fa fa-exclamation-triangle"></i> {{'ModelHasErrors' | translate}} </span> |
55 changes: 55 additions & 0 deletions
55
...les/short-error-message-display/components/short-model-error-message-display.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,55 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { Config } from '../../../../../config/config'; | ||
import { ElementFactoryBase } from '../../../../../factory/element-factory-base'; | ||
import { CEGModel } from '../../../../../model/CEGModel'; | ||
import { IContainer } from '../../../../../model/IContainer'; | ||
import { Process } from '../../../../../model/Process'; | ||
import { TestSpecification } from '../../../../../model/TestSpecification'; | ||
import { Id } from '../../../../../util/id'; | ||
import { Url } from '../../../../../util/url'; | ||
import { ValidationResult } from '../../../../../validation/validation-result'; | ||
import { SpecmateDataService } from '../../../../data/modules/data-service/services/specmate-data.service'; | ||
import { ValidationService } from '../../../../forms/modules/validation/services/validation.service'; | ||
import { NavigatorService } from '../../../../navigation/modules/navigator/services/navigator.service'; | ||
import { ConfirmationModal } from '../../../../notification/modules/modals/services/confirmation-modal.service'; | ||
import { LoggingService } from '../../../../views/side/modules/log-list/services/logging.service'; | ||
|
||
@Component({ | ||
moduleId: module.id.toString(), | ||
selector: 'short-model-error-message-display', | ||
templateUrl: 'short-model-error-message-display.component.html', | ||
styleUrls: ['short-model-error-message-display.component.css'] | ||
}) | ||
|
||
export class ShortModelErrorMessageDisplay { | ||
|
||
private contents: IContainer[]; | ||
|
||
private _model: CEGModel | Process; | ||
|
||
public get model(): CEGModel | Process { | ||
return this._model; | ||
} | ||
|
||
@Input() | ||
public set model(model: CEGModel | Process) { | ||
if (!model) { | ||
return; | ||
} | ||
this._model = model; | ||
this.dataService.readContents(model.url).then((contents: IContainer[]) => { | ||
this.contents = contents; | ||
}); | ||
} | ||
|
||
constructor(private dataService: SpecmateDataService, | ||
private validator: ValidationService) { } | ||
|
||
public get hasErrors(): boolean { | ||
if (this.model === undefined) { | ||
return false; | ||
} | ||
return !this.validator.isValid(this.model, this.contents); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...s/actions/modules/short-error-message-display/short-model-error-message-display.module.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,28 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ShortModelErrorMessageDisplay } from './components/short-model-error-message-display.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
// MODULE IMPORTS | ||
BrowserModule, | ||
TranslateModule | ||
], | ||
declarations: [ | ||
// COMPONENTS IN THIS MODULE | ||
ShortModelErrorMessageDisplay | ||
], | ||
exports: [ | ||
// THE COMPONENTS VISIBLE TO THE OUTSIDE | ||
ShortModelErrorMessageDisplay | ||
], | ||
providers: [ | ||
// SERVICES | ||
], | ||
bootstrap: [ | ||
// COMPONENTS THAT ARE BOOTSTRAPPED HERE | ||
] | ||
}) | ||
|
||
export class ShortModelErrorDisplayModule { } |
3 changes: 0 additions & 3 deletions
3
...ecification-generator-button/components/test-specification-generator-button.component.css
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
.model-error { | ||
color: red; | ||
} | ||
3 changes: 1 addition & 2 deletions
3
...cification-generator-button/components/test-specification-generator-button.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 |
---|---|---|
@@ -1,2 +1 @@ | ||
<span *ngIf="!enabled" class="model-error"><i aria-hidden="true" class="fa fa-exclamation-triangle"></i> {{'ModelHasErrors'|translate}} </span> | ||
<button *ngIf="enabled" id="generatetestspec-button" title="{{'testspec.generate' | translate}}" (click)="generate()" class="btn btn-sm btn-outline-primary"><i class="fa fa-indent" aria-hidden="true"></i> {{'testspec.generate' | translate}}</button> | ||
<button id="generatetestspec-button" title="{{'testspec.generate' | translate}}" (click)="generate()" class="btn btn-sm btn-outline-primary" [attr.disabled]="!enabled ? '' : null"><i class="fa fa-indent" aria-hidden="true"></i> {{'testspec.generate' | translate}}</button> |
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
43 changes: 24 additions & 19 deletions
43
.../app/modules/views/side/modules/errors-warnings/components/errors-warnings.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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
<div *ngIf="visible" class="card"> | ||
<h5 class="card-header"> | ||
{{'ErrorsandWarnings' | translate}} | ||
<button id="linksactions-expand-button" type="button" class="btn btn-sm btn-secondary pull-right" (click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample"><i *ngIf="isCollapsed" class="fa fa-angle-double-down"></i><i *ngIf="!isCollapsed" class="fa fa-angle-double-up"></i></button> | ||
<button id="linksactions-expand-button" type="button" class="btn btn-sm btn-secondary pull-right" | ||
(click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample"><i | ||
*ngIf="isCollapsed" class="fa fa-angle-double-down"></i><i *ngIf="!isCollapsed" | ||
class="fa fa-angle-double-up"></i></button> | ||
</h5> | ||
<div class="card-body" *ngIf="!isCollapsed"> | ||
<table *ngIf="warnings.length > 0" class="table"> | ||
<colgroup> | ||
<col width="50%"/> | ||
<col width="50%"/> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th>Elements</th> | ||
<th>Message</th> | ||
</tr> | ||
</thead> | ||
<tbody *ngFor="let warningList of warnings" warning [warnElements]="warningList"></tbody> | ||
</table> | ||
<span *ngIf="warnings.length == 0"> | ||
{{'NoWarnings'|translate}}. | ||
</span> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
<short-model-error-message-display [model]="model"></short-model-error-message-display> | ||
<span *ngIf="warnings && warnings.length == 0" class="text-success"> | ||
<i aria-hidden="true" class="fa fa-check"></i> {{'NoWarnings' | translate}}. | ||
</span> | ||
</p> | ||
</div> | ||
|
||
<table *ngIf="warnings && warnings.length > 0" class="table"> | ||
<colgroup> | ||
<col width="50%" /> | ||
<col width="50%" /> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th>Elements</th> | ||
<th>Message</th> | ||
</tr> | ||
</thead> | ||
<tbody *ngFor="let warningList of warnings" warning [warnElements]="warningList"></tbody> | ||
</table> | ||
</div> |
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