77 inject ,
88 input ,
99 linkedSignal ,
10+ OnInit ,
1011 signal ,
1112 viewChild ,
1213} from '@angular/core' ;
@@ -56,7 +57,7 @@ import { MatCardModule } from '@angular/material/card';
5657 templateUrl : './form.component.html' ,
5758 styleUrl : './form.component.scss' ,
5859} )
59- export class FormComponent {
60+ export class FormComponent implements OnInit {
6061 versionsService = inject ( VersionsService ) ;
6162 browseService = input . required < BrowseService > ( ) ;
6263 version = this . versionsService . versionReadOnly ( ) ;
@@ -83,7 +84,7 @@ export class FormComponent {
8384 Validators . min ( 0 ) ,
8485 Validators . max ( 100 ) ,
8586 ] ) ,
86- minDegree : new FormControl < number > ( 1 , [
87+ minDegree : new FormControl < number > ( 0 , [
8788 Validators . min ( 0 ) ,
8889 Validators . max ( 100 ) ,
8990 ] ) ,
@@ -114,6 +115,17 @@ export class FormComponent {
114115
115116 protected readonly capitalize = _ . capitalize ;
116117
118+ ngOnInit ( ) {
119+ // if specific defaults are set (eg spongeffects)
120+ this . formGroup . patchValue ( {
121+ minDegree : this . defaultMinDegree ( ) ,
122+ minBetweenness : this . defaultMinBetweenness ( ) ?? 0.05 ,
123+ minEigen : this . defaultMinEigen ( ) ?? 0.1 ,
124+ maxPValue : this . defaultMaxPValue ( ) ?? 0.05 ,
125+ minMscor : this . defaultMinMscor ( ) ?? 0.1 ,
126+ } ) ;
127+ }
128+
117129 constructor ( private cdr : ChangeDetectorRef ) {
118130 const formSignal = signal ( this . formGroup . value ) ;
119131 this . formGroup . valueChanges . subscribe ( ( val ) => {
@@ -153,24 +165,6 @@ export class FormComponent {
153165 this . infoService . renderMscorEquation ( this . mscorEquation$ ( ) ! ) ;
154166 } ) ;
155167 }
156- ngOnInit ( ) {
157- // Always set the form control values from the inputs
158- if ( this . defaultMinBetweenness ( ) !== undefined ) {
159- this . formGroup . get ( 'minBetweenness' ) ?. setValue ( this . defaultMinBetweenness ( ) ?? null ) ;
160- }
161- if ( this . defaultMinDegree ( ) !== undefined ) {
162- this . formGroup . get ( 'minDegree' ) ?. setValue ( this . defaultMinDegree ( ) ?? null ) ;
163- }
164- if ( this . defaultMinEigen ( ) !== undefined ) {
165- this . formGroup . get ( 'minEigen' ) ?. setValue ( this . defaultMinEigen ( ) ?? null ) ;
166- }
167- if ( this . defaultMaxPValue ( ) !== undefined ) {
168- this . formGroup . get ( 'maxPValue' ) ?. setValue ( this . defaultMaxPValue ( ) ?? null ) ;
169- }
170- if ( this . defaultMinMscor ( ) !== undefined ) {
171- this . formGroup . get ( 'minMscor' ) ?. setValue ( this . defaultMinMscor ( ) ?? null ) ;
172- }
173- }
174168
175169 getKeys ( enumType : any ) : string [ ] {
176170 return Object . keys ( enumType ) ;
0 commit comments