Add no entity warning for companies and inventory

This commit is contained in:
William Nolin 2021-11-23 12:04:10 -05:00
parent e332fee3ba
commit a0d15b57fb
4 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,8 @@
<cre-warning-alert *ngIf="companiesEmpty">
<p>Il n'y a actuellement aucune bannière enregistrée dans le système.</p>
<p *ngIf="hasEditPermission">Vous pouvez en créer une <b><a routerLink="/catalog/company/add">ici</a></b>.</p>
</cre-warning-alert>
<cre-entity-list
[entities$]="companies$"
[columns]="columns"

View File

@ -5,6 +5,8 @@ import {Permission} from '../../../shared/model/user'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
import {map, tap} from "rxjs/operators";
import {AccountService} from "../../../accounts/services/account.service";
@Component({
selector: 'cre-list',
@ -22,8 +24,11 @@ export class ListComponent extends ErrorHandlingComponent {
permission: Permission.EDIT_COMPANIES
}]
companiesEmpty = false
constructor(
private companyService: CompanyService,
private accountService: AccountService,
private appState: AppState,
errorService: ErrorService,
router: Router,
@ -31,5 +36,11 @@ export class ListComponent extends ErrorHandlingComponent {
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Bannières'
this.companies$.pipe(tap(companies => this.companiesEmpty = companies.length <= 0))
}
get hasEditPermission(): boolean {
return this.accountService.hasPermission(Permission.EDIT_COMPANIES)
}
}

View File

@ -45,7 +45,14 @@
</div>
</div>
<cre-warning-alert *ngIf="!loading && materials.length === 0">
<p>Il n'y a actuellement aucun produit enregistré dans le système.</p>
<p *ngIf="canEditMaterial">Vous pouvez en créer un <b><a routerLink="/catalog/material/add">ici</a></b>.
</p>
</cre-warning-alert>
<table
*ngIf="materials.length > 0"
mat-table
matSort
class="mx-auto"

View File

@ -21,7 +21,7 @@ import {AppState} from '../../../shared/app-state'
export class InventoryComponent extends ErrorHandlingComponent {
@ViewChild(MatSort) sort: MatSort
materials: Material[] | null
materials: Material[] | null = []
materialTypes$ = this.materialTypeService.all
dataSource: MatTableDataSource<Material>