Skip to content

Commit

Permalink
feat(#204): Loading different reports
Browse files Browse the repository at this point in the history
  • Loading branch information
AudreyLR committed Nov 22, 2018
1 parent 2ee554c commit 27a123f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const appRoutes: Routes = [{
path: 'report-configuration',
component: SelectTemplateComponent,
}, {
path: 'report-edition',
path: 'report-edition/:idReport',
component: ReportConfigurationComponent,
}, {
path: '**',
Expand Down
20 changes: 13 additions & 7 deletions src/app/report-configuration/report-configuration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ReportConfigurationComponent implements OnInit {
placeholders: PlaceholderGroup[];

constructor(
private dialog: MatDialog,
private activeRoute: ActivatedRoute,
private translateService: TranslateService,
private reportConfigurationService: ReportTemplateService,
private changeDetectorRef: ChangeDetectorRef,
Expand All @@ -32,17 +32,23 @@ export class ReportConfigurationComponent implements OnInit {
this.placeholders = res;
});
this.templateIdentifiers = [];
this.fetchTemplateIdentifiers();
//this.selectedTemplate = new ConfigurationTemplate();
this.selectedTemplate = this.reportConfigurationService.currentReport;
}
this.fetchRequiredData();

this.selectedTemplate = new ConfigurationTemplate();
}

fetchTemplateIdentifiers(): void {
fetchRequiredData(): void {
this.reportConfigurationService.getTemplateList().subscribe(data => {
data.forEach((templateIdentifier) => {
this.templateIdentifiers.push(templateIdentifier);
});
//this.openDialog();

this.activeRoute.params.subscribe(param => {
this.reportConfigurationService.getTemplate(param.idReport).subscribe(data => {
this.selectedTemplate = data;
this.fetchTemplateData();
});
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class SelectTemplateComponent implements OnInit, AfterViewInit {
this.form = this.formBuilder.group([]);
this.isOpenDisabled = true;

this.translateService.get([
this.translateService.get(['edit']).subscribe(labels => {
'edit'
]).subscribe(labels => {
this.labels = labels;
Expand Down Expand Up @@ -84,14 +84,8 @@ export class SelectTemplateComponent implements OnInit, AfterViewInit {
this.saveTemplate(selectedTemplate);
}

editReport(id){
console.log(id);
let configurationToEdit = this.dataSource.filter(function(item){
return item.id === id;
});
console.log(configurationToEdit[0]);
this.reportConfigurationService.currentReport = configurationToEdit[0];
this.router.navigate(['report-edition']);
editReport(report){
this.router.navigate(['/report-edition', report.id.toString()]);
}

saveTemplate(selectedTemplate: ConfigurationTemplate): void {
Expand Down

0 comments on commit 27a123f

Please sign in to comment.