Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions projects/components/error-card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// export what ./public_api exports so we can import with the lib name like this:
// import { ModuleA } from 'libname'
export * from './public_api';
7 changes: 7 additions & 0 deletions projects/components/error-card/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ngPackage": {
"lib": {
"entryFile": "index.ts"
}
}
}
2 changes: 2 additions & 0 deletions projects/components/error-card/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { PsErrorCardComponent } from './src/error-card.component';
export { PsErrorCardModule } from './src/error-card.module';
37 changes: 37 additions & 0 deletions projects/components/error-card/src/error-card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'ps-error-card',
template: `
<mat-card class="ps-error-card" [class.ps-error-card--center]="center">
<mat-icon *ngIf="showIcon" class="ps-error-card__icon">sentiment_very_dissatisfied</mat-icon>
<span>{{ errorMessage }}</span>
</mat-card>
`,
styles: [
`
.ps-error-card {
color: var(--ps-error);
}

.ps-error-card--center {
display: grid;
justify-items: center;
}

.ps-error-card__icon {
color: var(--ps-error);
font-size: 72px;
height: 72px;
width: 72px;
}
`,
],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class PsErrorCardComponent {
@Input() public showIcon = true;
@Input() public errorMessage: string;
@Input() public center = false;
}
12 changes: 12 additions & 0 deletions projects/components/error-card/src/error-card.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { PsErrorCardComponent } from './error-card.component';

@NgModule({
declarations: [PsErrorCardComponent],
imports: [CommonModule, MatCardModule, MatIconModule],
exports: [PsErrorCardComponent],
})
export class PsErrorCardModule {}
30 changes: 6 additions & 24 deletions projects/components/form/src/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ export class PsFormCancelEvent extends PsFormEvent {}
<ng-content></ng-content>
</ps-block-ui>

<mat-card *ngIf="hasLoadError" class="ps-form__error-container ps-form__error-container--center">
<mat-icon class="ps-form__error-icon">sentiment_very_dissatisfied</mat-icon>
<span>{{ errorMessage }}</span>
</mat-card>

<mat-card *ngIf="hasSaveError" class="ps-form__error-container">
<span>{{ errorMessage }}</span>
</mat-card>
<ps-error-card
*ngIf="hasLoadError || hasSaveError"
[errorMessage]="errorMessage"
[showIcon]="hasLoadError"
[center]="hasLoadError"
></ps-error-card>

<mat-card *ngIf="hasLoadError" class="ps-form__error-actions">
<button mat-stroked-button type="button" (click)="onCancel()">
Expand All @@ -87,22 +85,6 @@ export class PsFormCancelEvent extends PsFormEvent {}
grid-gap: 1em;
}

.ps-form__error-container {
color: var(--ps-error);
}

.ps-form__error-container--center {
display: grid;
justify-items: center;
}

.ps-form__error-icon {
color: var(--ps-error);
font-size: 72px;
height: 72px;
width: 72px;
}

.ps-form__error-actions {
text-align: right;
}
Expand Down
2 changes: 2 additions & 0 deletions projects/components/form/src/form.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { RouterModule } from '@angular/router';
import { PsBlockUiModule } from '@prosoft/components/block-ui';
import { PsErrorCardModule } from '@prosoft/components/error-card';
import { PsSavebarModule } from '@prosoft/components/savebar';
import { PsFormActionService } from './form-action.service';
import { PsFormComponent } from './form.component';
Expand All @@ -23,6 +24,7 @@ import { PsFormComponent } from './form.component';

PsBlockUiModule,
PsSavebarModule,
PsErrorCardModule,
],
exports: [PsFormComponent],
})
Expand Down