@@ -12,12 +12,14 @@ import {
1212import { MatFormFieldModule } from '@angular/material/form-field' ;
1313import { MatSelectModule } from '@angular/material/select' ;
1414import { MatExpansionModule } from '@angular/material/expansion' ;
15- import { FormControl , FormGroup , ReactiveFormsModule , Validators } from '@angular/forms' ;
16- import { MatInputModule } from '@angular/material/input' ;
1715import {
18- BrowseQuery ,
19- InteractionSorting ,
20- } from '../../../interfaces' ;
16+ FormControl ,
17+ FormGroup ,
18+ ReactiveFormsModule ,
19+ Validators ,
20+ } from '@angular/forms' ;
21+ import { MatInputModule } from '@angular/material/input' ;
22+ import { BrowseQuery , InteractionSorting } from '../../../interfaces' ;
2123import { BrowseService } from '../../../services/browse.service' ;
2224import { VersionsService } from '../../../services/versions.service' ;
2325import _ from 'lodash' ;
@@ -48,7 +50,7 @@ import { MatCardModule } from '@angular/material/card';
4850 MatCardModule ,
4951 InfoComponent ,
5052 MatButtonModule ,
51- CommonModule
53+ CommonModule ,
5254 ] ,
5355 templateUrl : './form.component.html' ,
5456 styleUrl : './form.component.scss' ,
@@ -69,16 +71,37 @@ export class FormComponent {
6971 sortingBetweenness : new FormControl < boolean > ( true ) ,
7072 sortingDegree : new FormControl < boolean > ( false ) ,
7173 sortingEigenvector : new FormControl < boolean > ( false ) ,
72- maxNodes : new FormControl < number > ( 10 , [ Validators . min ( 0 ) , Validators . max ( 100 ) ] ) ,
73- minDegree : new FormControl < number > ( 1 , [ Validators . min ( 0 ) , Validators . max ( 100 ) ] ) ,
74- minBetweenness : new FormControl < number > ( 0.05 , [ Validators . min ( 0 ) , Validators . max ( 1 ) ] ) ,
75- minEigen : new FormControl < number > ( 0.1 , [ Validators . min ( 0 ) , Validators . max ( 1 ) ] ) ,
74+ maxNodes : new FormControl < number > ( 10 , [
75+ Validators . min ( 0 ) ,
76+ Validators . max ( 100 ) ,
77+ ] ) ,
78+ minDegree : new FormControl < number > ( 1 , [
79+ Validators . min ( 0 ) ,
80+ Validators . max ( 100 ) ,
81+ ] ) ,
82+ minBetweenness : new FormControl < number > ( 0.05 , [
83+ Validators . min ( 0 ) ,
84+ Validators . max ( 1 ) ,
85+ ] ) ,
86+ minEigen : new FormControl < number > ( 0.1 , [
87+ Validators . min ( 0 ) ,
88+ Validators . max ( 1 ) ,
89+ ] ) ,
7690 interactionSorting : new FormControl < string > (
7791 this . getKeys ( this . interactionSortings ) [ 0 ]
7892 ) ,
79- maxInteractions : new FormControl < number > ( 100 , [ Validators . min ( 0 ) , Validators . max ( 1000 ) ] ) ,
80- maxPValue : new FormControl < number > ( 0.05 , [ Validators . min ( 0.025 ) , Validators . max ( 0.2 ) ] ) ,
81- minMscor : new FormControl < number > ( 0.1 , [ Validators . min ( 0.1 ) , Validators . max ( 1 ) ] ) ,
93+ maxInteractions : new FormControl < number > ( 100 , [
94+ Validators . min ( 0 ) ,
95+ Validators . max ( 1000 ) ,
96+ ] ) ,
97+ maxPValue : new FormControl < number > ( 0.05 , [
98+ Validators . min ( 0.025 ) ,
99+ Validators . max ( 0.2 ) ,
100+ ] ) ,
101+ minMscor : new FormControl < number > ( 0.1 , [
102+ Validators . min ( 0.1 ) ,
103+ Validators . max ( 1 ) ,
104+ ] ) ,
82105 } ) ;
83106
84107 protected readonly capitalize = _ . capitalize ;
@@ -88,21 +111,27 @@ export class FormComponent {
88111 this . formGroup . valueChanges . subscribe ( ( val ) => {
89112 formSignal . set ( val ) ;
90113 // Mark all controls as touched to show validation messages
91- Object . keys ( this . formGroup . controls ) . forEach ( key => {
114+ Object . keys ( this . formGroup . controls ) . forEach ( ( key ) => {
92115 this . formGroup . get ( key ) ?. markAsTouched ( ) ;
93116 } ) ;
94117 } ) ;
95118
96119 this . formGroup . valueChanges . subscribe ( ( config ) => {
97- if ( ! config . sortingDegree && ! config . sortingBetweenness && ! config . sortingEigenvector ) {
98- this . formGroup . get ( 'sortingBetweenness' ) ?. setValue ( true , { emitEvent : false } ) ;
120+ if (
121+ ! config . sortingDegree &&
122+ ! config . sortingBetweenness &&
123+ ! config . sortingEigenvector
124+ ) {
125+ this . formGroup
126+ . get ( 'sortingBetweenness' )
127+ ?. setValue ( true , { emitEvent : false } ) ;
99128 this . cdr . detectChanges ( ) ;
100129 config . sortingBetweenness = true ;
101130 }
102131 } ) ;
103132
104133 effect ( ( ) => {
105- const config = formSignal ( ) ;
134+ const config = formSignal ( ) ;
106135 const dataset = this . activeDataset ( ) ;
107136 if ( dataset === undefined ) return ;
108137 if ( ! this . formGroup . valid ) return ;
@@ -119,14 +148,17 @@ export class FormComponent {
119148 }
120149
121150 getKeys ( enumType : any ) : string [ ] {
122- return Object . keys ( enumType )
151+ return Object . keys ( enumType ) ;
123152 }
124153
125154 getEntries ( enumType : any ) : {
126155 key : string ;
127156 value : string ;
128- } [ ] {
129- return Object . entries ( enumType ) . map ( ( [ key , value ] ) => ( { key, value : value as string } ) ) ;
157+ } [ ] {
158+ return Object . entries ( enumType ) . map ( ( [ key , value ] ) => ( {
159+ key,
160+ value : value as string ,
161+ } ) ) ;
130162 }
131163
132164 trackByKey ( item : any ) : string {
0 commit comments