Skip to content
Snippets Groups Projects
Commit 20bcf1e3 authored by Pierre Ecarlat's avatar Pierre Ecarlat
Browse files

Merge branch 'fix/print/close-structure-detail' into 'dev'

fix(print): Close the structure detail panel when printing a structure

See merge request !798
parents 963b2294 5e4a4a8a
Branches
Tags
2 merge requests!805V3.0.1,!798fix(print): Close the structure detail panel when printing a structure
......@@ -37,10 +37,7 @@ const routes: Routes = [
{
path: 'print',
outlet: 'print',
children: [
{ path: 'structure', component: StructureDetailsComponent },
{ path: 'structures-search', component: StructureListSearchPrintComponent },
],
children: [{ path: 'structures-search', component: StructureListSearchPrintComponent }],
},
{
path: 'acteurs',
......
......@@ -6,27 +6,11 @@ import { Structure } from '../../models/structure.model';
providedIn: 'root',
})
export class PrintService {
public isPrinting = false;
public structure: Structure;
public structures: Structure[];
constructor(private router: Router) {}
public printDocument(documentName: string, structure: Structure): void {
this.isPrinting = true;
this.structure = structure;
this.router.navigate([
'/',
{
outlets: {
print: ['print', documentName],
},
},
]);
}
public printDocuments(documentName: string, structures: Structure[]): void {
this.isPrinting = true;
this.structures = structures;
this.router.navigate([
'/',
......@@ -41,7 +25,6 @@ export class PrintService {
public onDataReady(): void {
setTimeout(() => {
window.print();
this.isPrinting = false;
this.router.navigate([{ outlets: { print: null } }]);
}, 1500);
}
......
......@@ -21,7 +21,7 @@
[clickable]="false"
/>
</div>
<app-svg-icon [folder]="'ico'" [icon]="'cross'" [iconColor]="'grey-1'" (click)="close()" />
<app-svg-icon tabindex="0" [folder]="'ico'" [icon]="'cross'" [iconColor]="'grey-1'" (click)="close()" (keyup.enter)="close()" />
</section>
<section *ngIf="showButtons" class="actions hide-on-print">
......
import { animate, style, transition, trigger } from '@angular/animations';
import { Location } from '@angular/common';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import * as _ from 'lodash';
......@@ -12,7 +11,6 @@ import { AuthService } from '../../../services/auth.service';
import { StructureService } from '../../../services/structure.service';
import { TclService } from '../../../services/tcl.service';
import { UserService } from '../../../services/user.service';
import { PrintService } from '../../../shared/service/print.service';
import { FreeWorkshop } from '../../../structure/enums/freeWorkshop.enum';
import { Utils } from '../../../utils/utils';
import { AccessModality } from '../../enum/access-modality.enum';
......@@ -60,35 +58,26 @@ export class StructureDetailsComponent implements OnInit {
public FreeWorkshop = FreeWorkshop;
constructor(
private printService: PrintService,
private searchService: SearchService,
private structureService: StructureService,
private tclService: TclService,
public profileService: ProfileService,
private authService: AuthService,
private route: ActivatedRoute,
private location: Location,
private router: Router,
private utils: Utils,
private usersService: UserService,
) {
this.route.url.subscribe((url) => {
if (url.length > 0 && url[0].path === 'structure') {
this.structure = new Structure(this.printService.structure);
this.printMode = true;
this.initForm();
}
});
}
) {}
async ngOnInit(): Promise<void> {
this.route.queryParams.subscribe((queryParams) => {
if (queryParams.id) {
this.structureService.getStructure(queryParams.id).subscribe((structure) => {
this.structure = new Structure(structure);
this.isLoading = true;
this.initForm();
});
} else if (!this.printMode) {
} else {
this.structure = null;
}
this.showButtons = !history.state.isOrientation;
......@@ -114,9 +103,6 @@ export class StructureDetailsComponent implements OnInit {
this.searchService.getCategories().subscribe((categories) => {
this.categories = categories;
this.setServiceCategories();
if (this.printMode) {
this.printService.onDataReady();
}
this.isLoading = false;
});
}
......@@ -141,28 +127,13 @@ export class StructureDetailsComponent implements OnInit {
}
public close(): void {
if (this.router.url.startsWith('/acteurs')) {
this.router.navigateByUrl('/acteurs');
return;
}
this.route.url.subscribe((urls) => {
if (urls.length > 0 && urls[0].path !== 'orientation') {
this.router.navigate(['/acteurs'], {
relativeTo: this.route,
queryParams: {
id: null,
},
queryParamsHandling: 'merge',
});
} else {
this.isLoading = true;
this.location.back();
}
});
this.router.navigate([]);
}
public print(): void {
this.printService.printDocument('structure', this.structure);
setTimeout(() => {
window.print();
}, 1500);
}
public toggleDeleteModal(): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment