Product Group renamed to Menu Category

Extracted Product Group -> Group_type to a a new object called Sale Category.
Moved tax from product to Sale Category for uniform taxes on types of sales.
This commit is contained in:
Amritanshu
2019-06-20 13:15:23 +05:30
parent 16455fdcac
commit 05f8058a15
74 changed files with 1400 additions and 646 deletions

View File

@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { AuthService } from './auth.service';
import { Observable } from 'rxjs/internal/Observable';
import { map } from 'rxjs/operators';
import { AuthService } from './auth.service';
import { ToasterService } from '../core/toaster.service';
import { User } from '../core/user';
@ -14,28 +14,28 @@ export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private router: Router, private toaster: ToasterService) {
}
static checkUser(permission: string, user: User, router: Router, state: RouterStateSnapshot, toaster: ToasterService): boolean {
checkUser(permission: string, user: User, state: RouterStateSnapshot): boolean {
if (!user.isAuthenticated) {
router.navigate(['login'], {queryParams: {returnUrl: state.url}});
toaster.show('Danger', 'User is not authenticated');
this.router.navigate(['login'], {queryParams: {returnUrl: state.url}});
this.toaster.show('Danger', 'User is not authenticated');
return false;
}
const hasPermission = permission === undefined || user.perms.indexOf(permission) !== -1;
if (!hasPermission) {
toaster.show('Danger', 'You do not have the permission to access this area.');
this.toaster.show('Danger', 'You do not have the permission to access this area.');
}
return hasPermission;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
if (this.auth.user === undefined) {
return this.auth.userObservable
.pipe(
map<User, boolean>((value: User) => AuthGuard.checkUser(
route.data['permission'], value, this.router, state, this.toaster
map<User, boolean>((value: User) => this.checkUser(
next.data['permission'], value, state
))
);
}
return AuthGuard.checkUser(route.data['permission'], this.auth.user, this.router, state, this.toaster);
return this.checkUser(next.data['permission'], this.auth.user, state);
}
}