pd report template creation on template module - kdk
This commit is contained in:
parent
6fe58aa23c
commit
1952004498
3599
ng6-seed/package-lock.json
generated
3599
ng6-seed/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,7 @@
|
||||
"moment": "^2.15.0",
|
||||
"ng-pick-datetime": "^6.0.16",
|
||||
"ng2-charts": "1.6.0",
|
||||
"ng2-ckeditor": "^1.2.2",
|
||||
"ng2-dragula": "1.3.1",
|
||||
"ng2-file-upload": "1.2.1",
|
||||
"ng2-toastr": "^4.1.2",
|
||||
|
||||
@ -6,6 +6,7 @@ import { FormsModule } from '@angular/forms';
|
||||
import { HttpModule, Http } from '@angular/http';
|
||||
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS} from '@angular/common/http';
|
||||
|
||||
|
||||
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
|
||||
|
||||
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
|
||||
|
||||
@ -136,5 +136,15 @@ export class TemplatesService {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfCategories");
|
||||
}
|
||||
|
||||
addPDReportModelTemplate(Records : any): Observable<any> {
|
||||
Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record
|
||||
// Records.createdon = currentdate;//to get Current date and Time for when the Record is created
|
||||
return this._http.post<any[]>(this.apiUrl + "savePDReportTemplate", {'records': Records });
|
||||
}
|
||||
|
||||
getPDReportModelTemplate(template_id: number): Observable<any> {
|
||||
return this._http.post<any[]>(this.apiUrl + "getPDReportTemplate", { "records": {"fk_template_id": template_id }});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { CKEditorModule } from 'ng2-ckeditor';
|
||||
import {
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
@ -37,6 +37,7 @@ import { MastersService } from './service/masters/masters.service';
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CKEditorModule,
|
||||
RouterModule.forChild(TemplateRoutes),
|
||||
TemplatesModule,
|
||||
QuestionsModule,
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
<div style="margin: 12px;">
|
||||
<form *ngIf="showEditor" role="form" [formGroup]="ngForm" accept-charset="UTF-8" novalidate>
|
||||
<div class="form-group has-feedback" >
|
||||
<ckeditor formControlName="content"
|
||||
name="myckeditor"
|
||||
required
|
||||
[config]="ckeConfig"
|
||||
debounce="500"
|
||||
(change)="onChange($event)">
|
||||
</ckeditor>
|
||||
<!--<div *ngIf="myckeditor.invalid && myckeditor.touched" class="help-block">Required field.</div>-->
|
||||
</div>
|
||||
<button [disabled]="ngForm.invalid" class="btn btn-primary" (click)="myClick()">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--<div [innerHTML]="mycontent | safeHtml"></div>-->
|
||||
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ReportTemplateComponent } from './report-template.component';
|
||||
|
||||
describe('ReportTemplateComponent', () => {
|
||||
let component: ReportTemplateComponent;
|
||||
let fixture: ComponentFixture<ReportTemplateComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ReportTemplateComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ReportTemplateComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,92 @@
|
||||
import { Component, OnInit, ViewChild , Input} from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { TemplatesService } from './../../../../service/templates/templates.service';
|
||||
import { NotifierService } from "angular-notifier";
|
||||
|
||||
@Component({
|
||||
selector: 'app-report-template',
|
||||
templateUrl: './report-template.component.html',
|
||||
styleUrls: ['./report-template.component.scss']
|
||||
})
|
||||
export class ReportTemplateComponent implements OnInit {
|
||||
|
||||
@Input() questionId: number;
|
||||
ngForm: FormGroup;
|
||||
name = 'ng2-ckeditor';
|
||||
ckeConfig: any;
|
||||
recordData: any;
|
||||
log = '';
|
||||
showEditor= false;
|
||||
@ViewChild('myckeditor') ckeditor: any;
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
constructor( private _formBuilder: FormBuilder,
|
||||
private templatesService: TemplatesService,
|
||||
notifier: NotifierService ) {
|
||||
this.notifier = notifier;
|
||||
// this.ngForm = this._formBuilder.group({
|
||||
// report_template_id: [],
|
||||
// fk_template_id: [],
|
||||
// content: [null, Validators.compose([Validators.required])],
|
||||
// isactive:[1]
|
||||
// })
|
||||
// this.mycontent = `<p>My html content</p>`;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
// this.ngForm.controls['content'].setValue('<h1>Home<h1>');
|
||||
this.templatesService.getPDReportModelTemplate(this.questionId).subscribe(data => {
|
||||
if(data.dataStatus){
|
||||
this.recordData = data.records[0];
|
||||
|
||||
this.ngForm = this._formBuilder.group({
|
||||
report_template_id: [this.recordData.report_template_id],
|
||||
fk_template_id: [this.recordData.fk_template_id],
|
||||
content: [this.recordData.content, Validators.compose([Validators.required])],
|
||||
isactive:[this.recordData.isactive]
|
||||
})
|
||||
this.showEditor = true;
|
||||
} else {
|
||||
this.recordData = data.records;
|
||||
this.ngForm = this._formBuilder.group({
|
||||
report_template_id: [null],
|
||||
fk_template_id: [this.questionId],
|
||||
content: [null, Validators.compose([Validators.required])],
|
||||
isactive:[1]
|
||||
})
|
||||
this.showEditor = true;
|
||||
}
|
||||
},err => {
|
||||
|
||||
});
|
||||
this.ckeConfig = {
|
||||
allowedContent: false,
|
||||
extraPlugins: 'divarea',
|
||||
forcePasteAsPlainText: true
|
||||
};
|
||||
}
|
||||
|
||||
onChange($event: any): void {
|
||||
console.log('onChange');
|
||||
// this.log += new Date() + "<br />";
|
||||
}
|
||||
|
||||
myClick(): void {
|
||||
// let template = this.ngForm.controls['mycontent'].value;
|
||||
// let data = {
|
||||
// template: template,
|
||||
// template_id: this.questionId
|
||||
// }
|
||||
var formValues = this.ngForm.value;
|
||||
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
|
||||
|
||||
this.templatesService.addPDReportModelTemplate(formValues).subscribe(data=>{
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
}, err => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -45,6 +45,12 @@
|
||||
</app-template-edit-question-answer>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
<mat-tab label="Report Template">
|
||||
<ng-template matTabContent>
|
||||
<app-report-template [questionId]="question_id">
|
||||
</app-report-template>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</mat-card>
|
||||
</mat-card>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CKEditorModule } from 'ng2-ckeditor';
|
||||
|
||||
import { NotifierModule, NotifierOptions } from 'angular-notifier';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
@ -35,6 +36,7 @@ import { TemplatesService } from './../service/templates/templates.service';
|
||||
import { CategoryQuestionAnswerComponent } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component';
|
||||
import { DialogOverviewExampleDialog } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component';
|
||||
import { TemplatesAddComponent } from './templates-list/templates-add/templates-add.component';
|
||||
import { ReportTemplateComponent } from './templates-list/edit/report-template/report-template.component';
|
||||
|
||||
/*
|
||||
* Question Master Module details
|
||||
@ -87,6 +89,7 @@ const customNotifierOptions: NotifierOptions = {
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CKEditorModule,
|
||||
NotifierModule.withConfig(customNotifierOptions),
|
||||
FlexLayoutModule,
|
||||
MatCardModule,
|
||||
@ -115,7 +118,8 @@ const customNotifierOptions: NotifierOptions = {
|
||||
EditQuestionAnswerComponent,
|
||||
CategoryQuestionAnswerComponent,
|
||||
DialogOverviewExampleDialog,
|
||||
TemplatesAddComponent
|
||||
TemplatesAddComponent,
|
||||
ReportTemplateComponent
|
||||
],
|
||||
entryComponents: [
|
||||
DialogOverviewExampleDialog,
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
<head>
|
||||
<base href="./">
|
||||
<script src="https://cdn.ckeditor.com/4.9.2/full-all/ckeditor.js"></script>
|
||||
<script> CKEDITOR.config.forcePasteAsPlainText = true; </script>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user