#14 Add messages in the color list

This commit is contained in:
William Nolin 2021-09-10 07:55:24 -04:00
parent 951f9fcb87
commit 73bb2c3bce
7 changed files with 48 additions and 6 deletions

View File

@ -20,9 +20,15 @@
</div> </div>
</div> </div>
<div *ngIf="recipes.size === 0" class="alert alert-warning w-50 m-auto text-center"> <div *ngIf="!loading">
<p>Il n'y a actuellement aucune recette enregistrée dans le système.</p> <cre-warning-alert *ngIf="companies.length === 0">
<p *ngIf="hasEditPermission">Vous pouvez en créer une <b><a routerLink="/color/add">ici</a></b>.</p> <p>Il n'y a actuellement aucune bannière enregistrée dans le système.</p>
<p *ngIf="hasCompanyEditPermission">Vous pouvez en créer une <b><a routerLink="/catalog/company/add">ici</a></b>.</p>
</cre-warning-alert>
<cre-warning-alert *ngIf="recipes.size === 0">
<p>Il n'y a actuellement aucune recette enregistrée dans le système.</p>
<p *ngIf="hasEditPermission">Vous pouvez en créer une <b><a routerLink="/color/add">ici</a></b>.</p>
</cre-warning-alert>
</div> </div>
<mat-expansion-panel <mat-expansion-panel

View File

@ -53,8 +53,8 @@ export class ListComponent extends ErrorHandlingComponent {
} }
) )
this.fetchCompanies() //this.fetchCompanies()
// this.fetchRecipes() this.fetchRecipes()
} }
private fetchCompanies() { private fetchCompanies() {
@ -98,6 +98,10 @@ export class ListComponent extends ErrorHandlingComponent {
return this.accountService.hasPermission(Permission.EDIT_RECIPES) return this.accountService.hasPermission(Permission.EDIT_RECIPES)
} }
get hasCompanyEditPermission(): boolean {
return this.accountService.hasPermission(Permission.EDIT_COMPANIES)
}
private recipeMatchesSearchQuery(recipe: Recipe) { private recipeMatchesSearchQuery(recipe: Recipe) {
const matches = this.searchString(recipe.company.name) || const matches = this.searchString(recipe.company.name) ||
this.searchString(recipe.name) || this.searchString(recipe.name) ||

View File

@ -0,0 +1,3 @@
<div class="alert alert-warning w-50 m-auto text-center">
<ng-content></ng-content>
</div>

View File

@ -0,0 +1,14 @@
import {NgModule} from '@angular/core';
import {WarningAlert} from './alerts';
@NgModule({
declarations: [
WarningAlert
],
exports: [
WarningAlert
],
imports: []
})
export class CreAlertsModule {
}

View File

@ -0,0 +1,9 @@
import {Component} from '@angular/core';
@Component({
selector: 'cre-warning-alert',
templateUrl: 'alerts.html'
})
export class WarningAlert {
}

View File

@ -11,6 +11,8 @@ export abstract class SubscribingComponent implements OnInit, OnDestroy {
protected subscribers$ = [] protected subscribers$ = []
protected destroy$ = new Subject<boolean>() protected destroy$ = new Subject<boolean>()
loading = false
protected constructor( protected constructor(
protected errorService: ErrorService, protected errorService: ErrorService,
protected activatedRoute: ActivatedRoute, protected activatedRoute: ActivatedRoute,
@ -74,12 +76,14 @@ export abstract class SubscribingComponent implements OnInit, OnDestroy {
protected showLoadingWheel(shouldShowWheel) { protected showLoadingWheel(shouldShowWheel) {
if (shouldShowWheel) { if (shouldShowWheel) {
this.loading = true
globalLoadingWheel.show() globalLoadingWheel.show()
} }
} }
protected hideLoadingWheel(shouldShowWheel) { protected hideLoadingWheel(shouldShowWheel) {
if (shouldShowWheel) { if (shouldShowWheel) {
this.loading = false
globalLoadingWheel.hide() globalLoadingWheel.hide()
} }
} }

View File

@ -37,6 +37,7 @@ import {CreFormsModule} from './components/forms/forms.module'
import {VarDirective} from './directives/var.directive' import {VarDirective} from './directives/var.directive'
import {CreColorPreview} from './components/color-preview/color-preview' import {CreColorPreview} from './components/color-preview/color-preview'
import {CreDialogsModule} from './components/dialogs/dialogs.module' import {CreDialogsModule} from './components/dialogs/dialogs.module'
import {CreAlertsModule} from './components/alerts/alerts.module';
@NgModule({ @NgModule({
declarations: [VarDirective, HeaderComponent, UserMenuComponent, LabeledIconComponent, ConfirmBoxComponent, PermissionsListComponent, PermissionsFieldComponent, NavComponent, EntityListComponent, EntityAddComponent, EntityEditComponent, FileButtonComponent, GlobalAlertHandlerComponent, SliderFieldComponent, LoadingWheelComponent, CreColorPreview], declarations: [VarDirective, HeaderComponent, UserMenuComponent, LabeledIconComponent, ConfirmBoxComponent, PermissionsListComponent, PermissionsFieldComponent, NavComponent, EntityListComponent, EntityAddComponent, EntityEditComponent, FileButtonComponent, GlobalAlertHandlerComponent, SliderFieldComponent, LoadingWheelComponent, CreColorPreview],
@ -73,7 +74,8 @@ import {CreDialogsModule} from './components/dialogs/dialogs.module'
CreFormsModule, CreFormsModule,
VarDirective, VarDirective,
CreColorPreview, CreColorPreview,
CreDialogsModule CreDialogsModule,
CreAlertsModule
], ],
imports: [ imports: [
MatTabsModule, MatTabsModule,