Ajout de la génération de kits de retouche

This commit is contained in:
FyloZ 2021-05-01 20:44:34 -04:00
parent bca45efa9a
commit 2d235f93cd
11 changed files with 112 additions and 49 deletions

View File

@ -2,6 +2,8 @@ import {NgModule} from '@angular/core'
import {Routes, RouterModule} from '@angular/router'
import {CatalogComponent} from './pages/catalog/catalog.component'
import {AdministrationComponent} from './pages/administration/administration.component'
import {MiscComponent} from './pages/others/misc.component'
import {TouchupkitComponent} from './pages/others/touchupkit/touchupkit.component'
const routes: Routes = [{
@ -44,8 +46,16 @@ const routes: Routes = [{
}
]
}, {
path: 'material',
loadChildren: () => import('./modules/material/material.module').then(m => m.MaterialModule)
path: 'misc',
component: MiscComponent,
children: [{
path: 'touchupkit',
component: TouchupkitComponent
}, {
path: '',
pathMatch: 'full',
redirectTo: 'touchupkit'
}]
}]
@NgModule({

View File

@ -9,12 +9,16 @@ import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import {CatalogComponent} from './pages/catalog/catalog.component';
import {CompanyModule} from './modules/company/company.module';
import { AdministrationComponent } from './pages/administration/administration.component';
import { MiscComponent } from './pages/others/misc.component';
import { TouchupkitComponent } from './pages/others/touchupkit/touchupkit.component';
@NgModule({
declarations: [
AppComponent,
CatalogComponent,
AdministrationComponent
AdministrationComponent,
MiscComponent,
TouchupkitComponent
],
imports: [
AppRoutingModule,

View File

@ -1,38 +1,38 @@
import {NgModule} from '@angular/core';
import {NgModule} from '@angular/core'
import {ColorsRoutingModule} from './colors-routing.module';
import {SharedModule} from "../shared/shared.module";
import {ListComponent} from './pages/list/list.component';
import {AddComponent} from './pages/add/add.component';
import {EditComponent} from './pages/edit/edit.component';
import {MatExpansionModule} from "@angular/material/expansion";
import {FormsModule} from "@angular/forms";
import {ExploreComponent} from './pages/explore/explore.component';
import {RecipeInfoComponent} from './components/recipe-info/recipe-info.component';
import {MixTableComponent} from './components/mix-table/mix-table.component';
import {StepListComponent} from './components/step-list/step-list.component';
import {StepTableComponent} from './components/step-table/step-table.component';
import {MixEditorComponent} from './components/mix-editor/mix-editor.component';
import {UnitSelectorComponent} from './components/unit-selector/unit-selector.component';
import {MixAddComponent} from './pages/mix/mix-add/mix-add.component';
import {MixEditComponent} from './pages/mix/mix-edit/mix-edit.component';
import { ImagesEditorComponent } from './components/images-editor/images-editor.component';
import { MixesCardComponent } from './components/mixes-card/mixes-card.component';
import {ColorsRoutingModule} from './colors-routing.module'
import {SharedModule} from '../shared/shared.module'
import {ListComponent} from './pages/list/list.component'
import {AddComponent} from './pages/add/add.component'
import {EditComponent} from './pages/edit/edit.component'
import {MatExpansionModule} from '@angular/material/expansion'
import {FormsModule} from '@angular/forms'
import {ExploreComponent} from './pages/explore/explore.component'
import {RecipeInfoComponent} from './components/recipe-info/recipe-info.component'
import {MixTableComponent} from './components/mix-table/mix-table.component'
import {StepListComponent} from './components/step-list/step-list.component'
import {StepTableComponent} from './components/step-table/step-table.component'
import {MixEditorComponent} from './components/mix-editor/mix-editor.component'
import {UnitSelectorComponent} from './components/unit-selector/unit-selector.component'
import {MixAddComponent} from './pages/mix/mix-add/mix-add.component'
import {MixEditComponent} from './pages/mix/mix-edit/mix-edit.component'
import {ImagesEditorComponent} from './components/images-editor/images-editor.component'
import {MixesCardComponent} from './components/mixes-card/mixes-card.component'
import {MatSortModule} from '@angular/material/sort'
@NgModule({
declarations: [ListComponent, AddComponent, EditComponent, ExploreComponent, RecipeInfoComponent, MixTableComponent, StepListComponent, StepTableComponent, MixEditorComponent, UnitSelectorComponent, MixAddComponent, MixEditComponent, ImagesEditorComponent, MixesCardComponent],
exports: [
UnitSelectorComponent
],
imports: [
ColorsRoutingModule,
SharedModule,
MatExpansionModule,
FormsModule,
MatSortModule
]
declarations: [ListComponent, AddComponent, EditComponent, ExploreComponent, RecipeInfoComponent, MixTableComponent, StepListComponent, StepTableComponent, MixEditorComponent, UnitSelectorComponent, MixAddComponent, MixEditComponent, ImagesEditorComponent, MixesCardComponent],
exports: [
UnitSelectorComponent
],
imports: [
ColorsRoutingModule,
SharedModule,
MatExpansionModule,
FormsModule,
MatSortModule
]
})
export class ColorsModule {
}

View File

@ -22,7 +22,7 @@
<button
*ngIf="!authenticated && !employeeInGroup"
routerLink="/account/logout">
(click)="openLogout()">
Connexion
</button>
@ -31,14 +31,14 @@
*ngIf="!authenticated && employeeInGroup"
mat-list-item
class="employee-menu-item-login"
routerLink="/account/login">
(click)="openLogin()">
Connexion
</button>
<button
*ngIf="authenticated"
mat-list-item
class="employee-menu-item-logout"
routerLink="/account/logout">
(click)="openLogout()">
Déconnexion
</button>
</mat-action-list>

View File

@ -1,8 +1,10 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {AppState} from "../../app-state";
import {Employee} from "../../model/employee";
import {Subject} from "rxjs";
import {takeUntil} from "rxjs/operators";
import {Component, OnDestroy, OnInit} from '@angular/core'
import {AppState} from '../../app-state'
import {Employee} from '../../model/employee'
import {Subject} from 'rxjs'
import {takeUntil} from 'rxjs/operators'
import {UrlUtils} from '../../utils/url.utils'
import {ActivatedRoute, Router} from '@angular/router'
@Component({
selector: 'cre-employee-menu',
@ -16,10 +18,14 @@ export class EmployeeMenuComponent implements OnInit, OnDestroy {
menuEnabled = false
private destroy$ = new Subject<boolean>()
private urlUtils: UrlUtils
constructor(
public appState: AppState
private appState: AppState,
private router: Router,
private activatedRoute: ActivatedRoute
) {
this.urlUtils = new UrlUtils(activatedRoute, router)
}
ngOnInit(): void {
@ -36,6 +42,16 @@ export class EmployeeMenuComponent implements OnInit, OnDestroy {
this.destroy$.complete()
}
openLogin() {
this.urlUtils.navigateTo('/account/login')
this.menuEnabled = false
}
openLogout() {
this.urlUtils.navigateTo('/account/logout')
this.menuEnabled = false
}
private authenticationState(authenticated: boolean, employee: Employee) {
this.authenticated = authenticated
this.employee = employee

View File

@ -15,7 +15,8 @@ export class HeaderComponent extends SubscribingComponent {
links: HeaderLink[] = [
{route: '/color', title: 'Couleurs', requiredPermission: EmployeePermission.VIEW_RECIPES},
{route: '/catalog', title: 'Catalogue', requiredPermission: EmployeePermission.VIEW_CATALOG},
{route: '/admin', title: 'Administration', requiredPermission: EmployeePermission.VIEW_USERS}
{route: '/misc', title: 'Autres', enabled: true},
{route: '/admin', title: 'Administration', requiredPermission: EmployeePermission.VIEW_USERS},
]
_activeLink = this.links[0].route
@ -46,10 +47,10 @@ export class HeaderComponent extends SubscribingComponent {
)
// Auth status
this.updateEnabledLinks(this.appState.authenticatedEmployee)
this.updateEnabledLinks()
this.subscribe(
this.appState.authenticatedUser$,
authentication => this.updateEnabledLinks(authentication.authenticatedUser)
() => this.updateEnabledLinks()
)
}
@ -70,10 +71,14 @@ export class HeaderComponent extends SubscribingComponent {
return this._activeLink
}
private updateEnabledLinks(employee: Employee) {
private updateEnabledLinks() {
this.links.forEach(l => {
if (l.requiredPermission) {
l.enabled = employee && employee.permissions.indexOf(l.requiredPermission) >= 0
l.enabled = this.accountService.hasPermission(l.requiredPermission)
}
if (l.route === '/misc') {
l.enabled = this.accountService.hasPermission(EmployeePermission.GENERATE_TOUCH_UP_KIT)
}
})
}

View File

@ -25,8 +25,6 @@ export enum EmployeePermission {
VIEW_USERS = 'VIEW_USERS',
VIEW_CATALOG = 'VIEW_CATALOG',
PRINT_MIXES = 'PRINT_MIXES',
EDIT_RECIPES_PUBLIC_DATA = 'EDIT_RECIPES_PUBLIC_DATA',
EDIT_RECIPES = 'EDIT_RECIPES',
EDIT_MATERIALS = 'EDIT_MATERIALS',
@ -42,8 +40,10 @@ export enum EmployeePermission {
REMOVE_USERS = 'REMOVE_USERS',
REMOVE_CATALOG = 'REMOVE_CATALOG',
PRINT_MIXES = 'PRINT_MIXES',
ADD_TO_INVENTORY = 'ADD_TO_INVENTORY',
DEDUCT_FROM_INVENTORY = 'DEDUCT_FROM_INVENTORY',
GENERATE_TOUCH_UP_KIT = 'GENERATE_TOUCH_UP_KIT',
ADMIN = 'ADMIN'
}

View File

@ -0,0 +1,11 @@
import {Injectable} from '@angular/core'
import {environment} from '../../../../environments/environment'
@Injectable({
providedIn: 'root'
})
export class TouchupkitService {
generateJobPdfDocument(job: string) {
window.open(`${environment.apiUrl}/touchup?job=${job}`, '_blank')
}
}

View File

@ -0,0 +1,2 @@
<cre-nav [links]="links"></cre-nav>
<router-outlet></router-outlet>

View File

View File

@ -0,0 +1,15 @@
import {Component} from '@angular/core'
import {SubMenuComponent} from '../../modules/shared/components/sub-menu/sub-menu.component'
import {NavLink} from '../../modules/shared/components/nav/nav.component'
import {EmployeePermission} from '../../modules/shared/model/employee'
@Component({
selector: 'cre-others',
templateUrl: './misc.component.html',
styleUrls: ['./misc.component.sass']
})
export class MiscComponent extends SubMenuComponent{
links: NavLink[] = [
{route: '/misc/touchupkit', title: 'Kits de retouche', permission: EmployeePermission.GENERATE_TOUCH_UP_KIT}
]
}