Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Fix/show model errors in library (#400)
Browse files Browse the repository at this point in the history
* Extracting short error message display to component

* Removing unnecessary css class
  • Loading branch information
sebeder authored and junkerm committed Mar 7, 2019
1 parent 1bd59af commit 8f1f45f
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 27 deletions.
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>&nbsp;{{'ModelHasErrors' | translate}}&nbsp;</span>
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);
}
}
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 { }
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
.model-error {
color: red;
}
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>&nbsp;{{'ModelHasErrors'|translate}}&nbsp;</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>&nbsp;{{'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>&nbsp;{{'testspec.generate' | translate}}</button>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h5 class="card-header">{{'Cause-EffectModels' | translate}}</h5>
<span class="text-muted">{{element.description | truncate: 60}}</span>
</td>
<td style="text-align:right">
<short-model-error-message-display [model]="element"></short-model-error-message-display>
<test-specification-generator-button *ngIf="canGenerateTestSpecification" id="{{element.name + '-generate-testspec-button'}}"
[model]="element"></test-specification-generator-button>
<button id="{{'requirement-' + element.name + '-copy-button'}}" title="{{'copy' | translate}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h5 class="card-header">{{'ProcessModels' | translate}}</h5>
<span class="text-muted">{{element.description | truncate: 60}}</span>
</td>
<td style="text-align:right">
<short-model-error-message-display [model]="element"></short-model-error-message-display>
<test-specification-generator-button *ngIf="canGenerateTestSpecification" id="{{element.name + '-generate-testspec-button'}}"
[model]="element"></test-specification-generator-button>
<button id="{{'requirement-' + element.name + '-copyprocess-button'}}" title="{{'copy' | translate}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NavigatorModule } from '../../../../../navigation/modules/navigator/navigator.module';
import { TruncateModule } from '../../../../../common/modules/truncate/truncate.module';
import { TestSpecificationGeneratorButtonModule } from
'../../../../../actions/modules/test-specification-generator-button/test-specification-generator-button.module';
// tslint:disable-next-line:max-line-length
import { TestSpecificationGeneratorButtonModule } from '../../../../../actions/modules/test-specification-generator-button/test-specification-generator-button.module';
import { IconsModule } from '../../../../../common/modules/icons/icons.module';
import { TranslateModule } from '@ngx-translate/core';
import { CEGModelContainer } from './components/ceg-model-container.component';
import { ProcessModelContainer } from './components/process-model-container.component';
import { TestSpecificationContainer } from './components/test-specification-container.component';
import { RelatedRequirementsContainer } from './components/related-requirements-container.component';
import { FolderContainer } from './components/folder-container.component';
// tslint:disable-next-line:max-line-length
import { ShortModelErrorDisplayModule } from '../../../../../actions/modules/short-error-message-display/short-model-error-message-display.module';

@NgModule({
imports: [
BrowserModule,
NavigatorModule,
TruncateModule,
TestSpecificationGeneratorButtonModule,
ShortModelErrorDisplayModule,
IconsModule,
TranslateModule
],
Expand Down
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>&nbsp;{{'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>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { ValidationResult } from '../../../../../../validation/validation-result';
import { ValidationService } from '../../../../../forms/modules/validation/services/validation.service';
import { AdditionalInformationService } from '../../links-actions/services/additional-information.service';
import { IContainer } from '../../../../../../model/IContainer';


@Component({
Expand All @@ -23,6 +24,9 @@ export class ErrorsWarings {
return this._isCollapsed;
}

public get model(): IContainer {
return this.additionalInformationService.element;
}

public visible = true;
constructor(private validationService: ValidationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { ErrorsWarings } from './components/errors-warnings.component';
import { Warning } from './components/warning.component';
// tslint:disable-next-line:max-line-length
import { ShortModelErrorDisplayModule } from '../../../../actions/modules/short-error-message-display/short-model-error-message-display.module';

@NgModule({
imports: [
// MODULE IMPORTS
BrowserModule,
NavigatorModule,
NgbModule.forRoot(),
TranslateModule
TranslateModule,
ShortModelErrorDisplayModule
],
declarations: [
// COMPONENTS IN THIS MODULE
Expand Down

0 comments on commit 8f1f45f

Please sign in to comment.