From 37f0170ff7b1dcb6a08a6b8be46ebd9d21f220a8 Mon Sep 17 00:00:00 2001 From: audrey Date: Mon, 29 Oct 2018 10:50:50 -0400 Subject: [PATCH] feat(#204): Removed unused code --- .../report-configuration.component.html | 3 +- .../report-configuration.component.ts | 35 +++++------------- .../report-configuration.module.ts | 14 +++++--- .../select-template.component.html | 36 ++++--------------- .../select-template.component.spec.ts | 3 -- .../select-template.component.ts | 30 ++++++---------- .../services/report-template.service.ts | 1 - 7 files changed, 34 insertions(+), 88 deletions(-) diff --git a/src/app/report-configuration/report-configuration.component.html b/src/app/report-configuration/report-configuration.component.html index 49ce8d2a..0a5bf170 100644 --- a/src/app/report-configuration/report-configuration.component.html +++ b/src/app/report-configuration/report-configuration.component.html @@ -5,8 +5,7 @@

{{selectedTemplate.name == null ? ('newDocument' | translate) id="textEditor" [(documentContent)]="selectedTemplate.data" [(placeholders)]="placeholders" - (loadDataEvent)="openDialog()" + (loadDataEvent)="loadTemplate()" (saveDataEvent)="saveTemplate()"> - diff --git a/src/app/report-configuration/report-configuration.component.ts b/src/app/report-configuration/report-configuration.component.ts index 5b030e92..ec8e6296 100644 --- a/src/app/report-configuration/report-configuration.component.ts +++ b/src/app/report-configuration/report-configuration.component.ts @@ -1,10 +1,8 @@ -import {ChangeDetectorRef, Component, NgZone, OnInit} from '@angular/core'; - +import {ChangeDetectorRef, Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; import {ReportTemplateService} from '../shared/services/report-template.service'; import {TranslateService} from '@ngx-translate/core'; import {ConfigurationTemplate} from '../shared/models/configuration-template.model'; -import {MatDialog, MatDialogConfig} from '@angular/material'; -import {SelectTemplateComponent} from './select-template/select-template.component'; import {PlaceholderGroup} from './shared/models/placeholder-group'; @@ -12,7 +10,7 @@ import {PlaceholderGroup} from './shared/models/placeholder-group'; selector: 'app-report-configuration', templateUrl: './report-configuration.component.html', styleUrls: ['./report-configuration.component.scss'], - providers: [/* ReportTemplateService */] + providers: [] }) export class ReportConfigurationComponent implements OnInit { selectedTemplate: ConfigurationTemplate; @@ -24,8 +22,8 @@ export class ReportConfigurationComponent implements OnInit { private translateService: TranslateService, private reportConfigurationService: ReportTemplateService, private changeDetectorRef: ChangeDetectorRef, - private ngZone: NgZone, - ) { } + ) { + } ngOnInit() { this.reportConfigurationService.getPlaceholderList().subscribe(res => { @@ -68,26 +66,9 @@ export class ReportConfigurationComponent implements OnInit { }); } - /* openDialog() { - // Needs tp be run inside the NgZone because the function is sometimes called as an emit from CKEditor - this.ngZone.run(() => { - const dialogConfig = new MatDialogConfig(); - - dialogConfig.disableClose = true; - dialogConfig.autoFocus = true; - - dialogConfig.data = { - id: 1, - templateIdentifiers: this.templateIdentifiers - }; - - const dialogRef = this.dialog.open(SelectTemplateComponent, dialogConfig); - - dialogRef.afterClosed().subscribe(result => { - this.selectOrCreateTemplate(result); - }); - }); - } */ + loadTemplate(): void { + this.fetchTemplateData(); + } selectOrCreateTemplate(template: ConfigurationTemplate) { if (template == null) { diff --git a/src/app/report-configuration/report-configuration.module.ts b/src/app/report-configuration/report-configuration.module.ts index 2fc50233..cf3b4f1e 100644 --- a/src/app/report-configuration/report-configuration.module.ts +++ b/src/app/report-configuration/report-configuration.module.ts @@ -1,11 +1,12 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; +import {DxDataGridModule} from 'devextreme-angular'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {MatFormFieldModule, MatButtonToggleModule, MatDialogModule, MatSelectModule, MatOptionModule, MatInputModule, MatListModule} from '@angular/material'; import {ReportConfigurationComponent} from './report-configuration.component'; import {TranslateModule} from '@ngx-translate/core'; import {SelectTemplateComponent} from './select-template/select-template.component'; -import {MatFormFieldModule, MatDialogModule, MatSelectModule, MatOptionModule, MatInputModule, MatListModule} from '@angular/material'; import {TextEditorModule} from 'cause-report-configuration'; import {ReportTemplateService} from '../shared/services/report-template.service'; @@ -21,7 +22,9 @@ import {ReportTemplateService} from '../shared/services/report-template.service' MatInputModule, MatListModule, ReactiveFormsModule, - TranslateModule + TranslateModule, + DxDataGridModule, + MatButtonToggleModule, ], declarations: [ ReportConfigurationComponent, @@ -29,5 +32,6 @@ import {ReportTemplateService} from '../shared/services/report-template.service' ], providers: [ ReportTemplateService, + ] }) export class ReportConfigurationModule { } diff --git a/src/app/report-configuration/select-template/select-template.component.html b/src/app/report-configuration/select-template/select-template.component.html index afa21e81..d942c2ae 100644 --- a/src/app/report-configuration/select-template/select-template.component.html +++ b/src/app/report-configuration/select-template/select-template.component.html @@ -2,7 +2,6 @@ [dataSource]="dataSource" [hoverStateEnabled]="true" [rowAlternationEnabled]="true" - (onInitNewRow)="onInitNewRow($event)" (onRowInserted)="onRowInserted($event)" (onRowUpdated)="onRowUpdated($event)" (onRowRemoved)="onRowRemoved($event)"> @@ -14,36 +13,13 @@ sortOrder="desc"> - - -
-
- - - + +
+
+ +
-
- - + diff --git a/src/app/report-configuration/select-template/select-template.component.spec.ts b/src/app/report-configuration/select-template/select-template.component.spec.ts index e5e72356..15b144fc 100644 --- a/src/app/report-configuration/select-template/select-template.component.spec.ts +++ b/src/app/report-configuration/select-template/select-template.component.spec.ts @@ -1,6 +1,4 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; - -//import {TestModule} from '../../../test.module.spec'; import {SelectTemplateComponent} from './select-template.component'; @@ -10,7 +8,6 @@ describe('SlideshowComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - //imports: [TestModule], declarations: [] }) .compileComponents(); diff --git a/src/app/report-configuration/select-template/select-template.component.ts b/src/app/report-configuration/select-template/select-template.component.ts index c7466f42..f8575407 100644 --- a/src/app/report-configuration/select-template/select-template.component.ts +++ b/src/app/report-configuration/select-template/select-template.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, AfterViewInit} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {Router} from '@angular/router'; import {FormBuilder, FormGroup} from '@angular/forms'; import {TranslateService} from '@ngx-translate/core'; @@ -8,10 +8,9 @@ import {ReportTemplateService} from '../../shared/services/report-template.servi @Component({ selector: 'app-template-selection', templateUrl: './select-template.component.html', - styleUrls: ['./select-template.component.css'], - providers: [/* ReportTemplateService */] + styleUrls: ['./select-template.component.css'] }) -export class SelectTemplateComponent implements OnInit, AfterViewInit { +export class SelectTemplateComponent implements OnInit { form: FormGroup; dataSource: any = {}; @@ -41,41 +40,32 @@ export class SelectTemplateComponent implements OnInit, AfterViewInit { this.isOpenDisabled = true; this.translateService.get(['edit']).subscribe(labels => { - 'edit' - ]).subscribe(labels => { this.labels = labels; this.checkLoadedElement(); - }); - } - - ngAfterViewInit() { - + }); } private checkLoadedElement(): boolean { if (this.angularIsLoaded && this.labels !== {}) { - return true; + return true; } return false; } - openExistingTemplate(template: ConfigurationTemplate) { - //this.dialogRef.close(template); - } - textAreaEmpty(name: string) { this.isOpenDisabled = name.trim().length === 0; } - create(name: string) { + + onRowInserted(e){ const template = new ConfigurationTemplate(); - template.name = name; + template.name = e.data.name; template.data = ''; - //this.dialogRef.close(template); + this.saveTemplate(template); } onRowUpdated(e){ - console.log('updated'); + this.saveTemplate(e.data); } onRowRemoved(e){ diff --git a/src/app/shared/services/report-template.service.ts b/src/app/shared/services/report-template.service.ts index c546df11..1b08f14a 100644 --- a/src/app/shared/services/report-template.service.ts +++ b/src/app/shared/services/report-template.service.ts @@ -12,7 +12,6 @@ import {PlaceholderGroup} from '../../report-configuration/shared/models/placeho @Injectable() export class ReportTemplateService extends RequestService { - currentReport = null; constructor(http: HttpClient, injector: Injector) { super(injector);