Added error status icoin to submission's sections

This commit is contained in:
Giuseppe
2018-10-12 15:31:06 +02:00
parent eddd3fa9c9
commit df101c0413
3 changed files with 20 additions and 10 deletions

View File

@@ -32,7 +32,6 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) { if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
console.log(request);
const dataDefinition = this.process<IntegrationModel,IntegrationType>(data.payload, request.href); const dataDefinition = this.process<IntegrationModel,IntegrationType>(data.payload, request.href);
return new IntegrationSuccessResponse(dataDefinition[Object.keys(dataDefinition)[0]], data.statusCode, data.statusText, this.processPageInfo(data.payload)); return new IntegrationSuccessResponse(dataDefinition[Object.keys(dataDefinition)[0]], data.statusCode, data.statusText, this.processPageInfo(data.payload));
} else { } else {

View File

@@ -13,7 +13,9 @@
<ng-template ngbPanelTitle> <ng-template ngbPanelTitle>
<span>{{ 'submission.sections.'+sectionData.header | translate }}</span> <span>{{ 'submission.sections.'+sectionData.header | translate }}</span>
<div class="d-inline-block float-right"> <div class="d-inline-block float-right">
<i *ngIf="!(sectionRef.isValid() | async)" class="fa fa-exclamation-circle text-warning mr-3" <i *ngIf="!(sectionRef.isValid() | async) && !(sectionRef.hasErrors())" class="fa fa-exclamation-circle text-warning mr-3"
aria-hidden="true"></i>
<i *ngIf="(sectionRef.hasErrors())" class="fa fa-exclamation-circle text-danger mr-3"
aria-hidden="true"></i> aria-hidden="true"></i>
<i *ngIf="(sectionRef.isValid() | async)" class="fa fa-check-circle text-success mr-3" <i *ngIf="(sectionRef.isValid() | async)" class="fa fa-check-circle text-success mr-3"
aria-hidden="true"></i> aria-hidden="true"></i>
@@ -30,7 +32,7 @@
</div> </div>
</ng-template> </ng-template>
<ng-template ngbPanelContent> <ng-template ngbPanelContent>
<div *ngIf="sectionRef.hasErrors()"> <div *ngIf="sectionRef.hasGenericErrors()">
<ds-alert *ngFor="let error of sectionRef.getErrors(); let i = index" <ds-alert *ngFor="let error of sectionRef.getErrors(); let i = index"
[content]="error" [content]="error"
[dismissible]="true" [dismissible]="true"

View File

@@ -18,7 +18,8 @@ export class SectionsDirective implements OnDestroy, OnInit {
@Input() mandatory = true; @Input() mandatory = true;
@Input() sectionId; @Input() sectionId;
@Input() submissionId; @Input() submissionId;
public sectionErrors: string[] = []; public genericSectionErrors: string[] = [];
public allSectionErrors: string[] = [];
private active = true; private active = true;
private animation = !this.mandatory; private animation = !this.mandatory;
private enabled: Observable<boolean>; private enabled: Observable<boolean>;
@@ -50,7 +51,9 @@ export class SectionsDirective implements OnDestroy, OnInit {
parsedErrors.forEach((error: SectionErrorPath) => { parsedErrors.forEach((error: SectionErrorPath) => {
if (!error.fieldId) { if (!error.fieldId) {
this.sectionErrors = uniq(this.sectionErrors.concat(errorItem.message)); this.genericSectionErrors = uniq(this.genericSectionErrors.concat(errorItem.message));
} else {
this.allSectionErrors.push(errorItem.message);
} }
}); });
}); });
@@ -113,12 +116,17 @@ export class SectionsDirective implements OnDestroy, OnInit {
this.sectionService.removeSection(submissionId, sectionId) this.sectionService.removeSection(submissionId, sectionId)
} }
public hasGenericErrors() {
return this.genericSectionErrors && this.genericSectionErrors.length > 0
}
public hasErrors() { public hasErrors() {
return this.sectionErrors && this.sectionErrors.length > 0 return (this.genericSectionErrors && this.genericSectionErrors.length > 0) ||
(this.allSectionErrors && this.allSectionErrors.length > 0)
} }
public getErrors() { public getErrors() {
return this.sectionErrors; return this.genericSectionErrors;
} }
public setFocus(event) { public setFocus(event) {
@@ -128,14 +136,15 @@ export class SectionsDirective implements OnDestroy, OnInit {
} }
public removeError(index) { public removeError(index) {
this.sectionErrors.splice(index); this.genericSectionErrors.splice(index);
} }
public resetErrors() { public resetErrors() {
if (isNotEmpty(this.sectionErrors)) { if (isNotEmpty(this.genericSectionErrors)) {
this.sectionService.dispatchRemoveSectionErrors(this.submissionId, this.sectionId); this.sectionService.dispatchRemoveSectionErrors(this.submissionId, this.sectionId);
} }
this.sectionErrors = []; this.genericSectionErrors = [];
this.allSectionErrors = [];
} }
} }