@@ -12,6 +12,7 @@ import {
1212} from '@angular / core ';
1313import {
1414 FormBuilder ,
15+ FormControl ,
1516 FormGroup ,
1617 FormsModule ,
1718 NgModel ,
@@ -67,15 +68,27 @@ export class AddPostComponent implements OnInit {
6768 @Input ( ) postId ?: string ;
6869 quill = viewChild . required < QuillEditorComponent > ( 'quill' ) ;
6970
70- blogForm : FormGroup < PostForm > ;
71- range : Range | null = null ;
72-
7371 viewContainerRef = inject ( ViewContainerRef ) ;
7472 dialogService = inject ( DynamicDialogService < AddImageForm > ) ;
7573
76- private fb = inject ( FormBuilder ) ;
74+ blogForm : FormGroup < PostForm > = new FormGroup < PostForm > ( {
75+ title : new FormControl ( '' , {
76+ validators : [ Validators . required ] ,
77+ nonNullable : true ,
78+ } ) ,
79+ content : new FormControl ( '' , {
80+ validators : [ Validators . required ] ,
81+ nonNullable : true ,
82+ } ) ,
83+ date : new FormControl < Date | null > ( null ) ,
84+ description : new FormControl < string | null > ( null ) ,
85+ isDraft : new FormControl ( false , { nonNullable : true } ) ,
86+ } ) ;
87+ range : Range | null = null ;
88+
7789 private apiService = inject ( AdminApiService ) ;
7890
91+ < << << << HEAD
7992 constructor ( ) {
8093 this . blogForm = this . fb . group ( {
8194 title : [ '' , [ Validators . required ] ] ,
@@ -92,17 +105,21 @@ export class AddPostComponent implements OnInit {
92105=== === =
93106 } ) ;
94107>>> >>> > ab739b9 ( nothing special )
108+ = === ===
109+ ngOnInit ( ) : void {
110+ this . loadPostIfIdExists ( ) ;
111+ this . initializeQuill ( ) ;
112+ >>> >>> > cbcd61c ( fix lame code )
95113 }
96114
97- ngOnInit ( ) : void {
115+ private loadPostIfIdExists ( ) : void {
98116 if ( this . postId ) {
99117 this . apiService . getPostById ( this . postId ) . subscribe ( ( post ) => {
100118 if ( post ) {
101119 this . blogForm . patchValue ( post ) ;
102120 }
103121 } ) ;
104122 }
105- this . initializeQuill ( ) ;
106123 }
107124
108125 async initializeQuill ( ) {
0 commit comments