Add no entity warning for companies and inventory
This commit is contained in:
parent
e332fee3ba
commit
a0d15b57fb
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue