Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2e42d491b3
@ -160,7 +160,7 @@ const mainRoutes: IqserRoutes = [
|
||||
{
|
||||
path: 'trash',
|
||||
loadChildren: () => import('./modules/trash/trash.module').then(m => m.TrashModule),
|
||||
canActivate: [CompositeRouteGuard, IqserPermissionsGuard, loadActiveDossiersGuard()],
|
||||
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
|
||||
data: {
|
||||
routeGuards: [IqserAuthGuard, RedRoleGuard, TrashGuard],
|
||||
permissions: {
|
||||
|
||||
@ -1,14 +1,32 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { CanActivate, CanActivateFn } from '@angular/router';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { TrashService } from '@services/entity-services/trash.service';
|
||||
import { SystemPreferencesService } from '@services/system-preferences.service';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { ACTIVE_DOSSIERS_SERVICE } from '../tokens';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class TrashGuard implements CanActivate {
|
||||
constructor(private readonly _trashService: TrashService) {}
|
||||
constructor(
|
||||
private readonly _trashService: TrashService,
|
||||
private readonly _systemPreferences: SystemPreferencesService,
|
||||
private readonly _activeDossierService: ActiveDossiersService,
|
||||
) {}
|
||||
|
||||
async canActivate(): Promise<boolean> {
|
||||
await this._systemPreferences.loadPreferencesIfNeeded();
|
||||
await firstValueFrom(this._activeDossierService.loadAll());
|
||||
await firstValueFrom(this._trashService.loadAll());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function trashGuard(): CanActivateFn {
|
||||
return async () => {
|
||||
await inject(SystemPreferencesService).loadPreferencesIfNeeded();
|
||||
await firstValueFrom(inject<ActiveDossiersService>(ACTIVE_DOSSIERS_SERVICE).loadAll());
|
||||
await firstValueFrom(inject(TrashService).loadAll());
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
@ -18,6 +18,12 @@ export class SystemPreferencesService extends GenericService<SystemPreferences>
|
||||
return this.values;
|
||||
}
|
||||
|
||||
async loadPreferencesIfNeeded() {
|
||||
if (!this.values) {
|
||||
await this.loadPreferences();
|
||||
}
|
||||
}
|
||||
|
||||
async update(value: SystemPreferences) {
|
||||
await firstValueFrom(this._post(value));
|
||||
return await this.loadPreferences();
|
||||
|
||||
@ -40,7 +40,11 @@ export const mainResolver: ResolveFn<void> = async () => {
|
||||
const generalConfig$ = inject(GeneralSettingsService).getGeneralConfigurations();
|
||||
const updatedDisplayName$ = generalConfig$.pipe(tap(config => configService.updateDisplayName(config.displayName)));
|
||||
|
||||
await Promise.all([systemPreferencesService.loadPreferences(), userPreferenceService.reload(), firstValueFrom(updatedDisplayName$)]);
|
||||
await Promise.all([
|
||||
systemPreferencesService.loadPreferencesIfNeeded(),
|
||||
userPreferenceService.reload(),
|
||||
firstValueFrom(updatedDisplayName$),
|
||||
]);
|
||||
|
||||
const lastDossierTemplate = userPreferenceService.getLastDossierTemplate();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user