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
|
<cre-entity-list
|
||||||
[entities$]="companies$"
|
[entities$]="companies$"
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
|
|
|
@ -5,6 +5,8 @@ import {Permission} from '../../../shared/model/user'
|
||||||
import {ActivatedRoute, Router} from '@angular/router'
|
import {ActivatedRoute, Router} from '@angular/router'
|
||||||
import {ErrorService} from '../../../shared/service/error.service'
|
import {ErrorService} from '../../../shared/service/error.service'
|
||||||
import {AppState} from '../../../shared/app-state'
|
import {AppState} from '../../../shared/app-state'
|
||||||
|
import {map, tap} from "rxjs/operators";
|
||||||
|
import {AccountService} from "../../../accounts/services/account.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'cre-list',
|
selector: 'cre-list',
|
||||||
|
@ -22,8 +24,11 @@ export class ListComponent extends ErrorHandlingComponent {
|
||||||
permission: Permission.EDIT_COMPANIES
|
permission: Permission.EDIT_COMPANIES
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
companiesEmpty = false
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private companyService: CompanyService,
|
private companyService: CompanyService,
|
||||||
|
private accountService: AccountService,
|
||||||
private appState: AppState,
|
private appState: AppState,
|
||||||
errorService: ErrorService,
|
errorService: ErrorService,
|
||||||
router: Router,
|
router: Router,
|
||||||
|
@ -31,5 +36,11 @@ export class ListComponent extends ErrorHandlingComponent {
|
||||||
) {
|
) {
|
||||||
super(errorService, activatedRoute, router)
|
super(errorService, activatedRoute, router)
|
||||||
this.appState.title = 'Bannières'
|
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>
|
||||||
</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
|
<table
|
||||||
|
*ngIf="materials.length > 0"
|
||||||
mat-table
|
mat-table
|
||||||
matSort
|
matSort
|
||||||
class="mx-auto"
|
class="mx-auto"
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {AppState} from '../../../shared/app-state'
|
||||||
export class InventoryComponent extends ErrorHandlingComponent {
|
export class InventoryComponent extends ErrorHandlingComponent {
|
||||||
@ViewChild(MatSort) sort: MatSort
|
@ViewChild(MatSort) sort: MatSort
|
||||||
|
|
||||||
materials: Material[] | null
|
materials: Material[] | null = []
|
||||||
materialTypes$ = this.materialTypeService.all
|
materialTypes$ = this.materialTypeService.all
|
||||||
dataSource: MatTableDataSource<Material>
|
dataSource: MatTableDataSource<Material>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue