@@ -23,12 +23,53 @@ function setupTooltips() {
2323function validateInputs ( ) {
2424 // Check for any empty non-VMH input fields
2525 let allInputsValid = true ;
26+
27+ // Clear previous validation states
28+ document . querySelectorAll ( '.ws-input-error' ) . forEach ( el => {
29+ el . classList . remove ( 'ws-input-error' ) ;
30+ } ) ;
31+
32+ // Check substrate and product name inputs
2633 document . querySelectorAll ( '.sub-name-input, .prod-name-input' ) . forEach ( ( input ) => {
2734 if ( input . value . trim ( ) === '' ) {
2835 allInputsValid = false ;
36+ input . classList . add ( 'ws-input-error' ) ;
2937 }
3038 } ) ;
3139
40+ // Also check inputs in workspace detail panel
41+ const detailPanel = document . getElementById ( 'wsAvailableReactionDetails' ) ;
42+ if ( detailPanel ) {
43+ // Check name inputs that aren't readonly (new metabolites need names)
44+ detailPanel . querySelectorAll ( 'input[name="subsNameInput"]:not([readonly]), input[name="prodsNameInput"]:not([readonly])' ) . forEach ( ( input ) => {
45+ if ( input . value . trim ( ) === '' ) {
46+ allInputsValid = false ;
47+ input . classList . add ( 'ws-input-error' ) ;
48+ // Highlight the row
49+ const row = input . closest ( 'tr' ) ;
50+ if ( row ) row . classList . add ( 'ws-row-error' ) ;
51+ }
52+ } ) ;
53+
54+ // Check abbreviation inputs that aren't readonly
55+ detailPanel . querySelectorAll ( 'input[name="subsAbbrInput"]:not([readonly]), input[name="prodsAbbrInput"]:not([readonly])' ) . forEach ( ( input ) => {
56+ if ( input . value . trim ( ) === '' ) {
57+ allInputsValid = false ;
58+ input . classList . add ( 'ws-input-error' ) ;
59+ // Highlight the row
60+ const row = input . closest ( 'tr' ) ;
61+ if ( row ) row . classList . add ( 'ws-row-error' ) ;
62+ }
63+ } ) ;
64+
65+ // Check reaction abbreviation
66+ const reactionAbbrInput = detailPanel . querySelector ( '.reaction-abbreviation-input' ) ;
67+ if ( reactionAbbrInput && reactionAbbrInput . value . trim ( ) === '' ) {
68+ allInputsValid = false ;
69+ reactionAbbrInput . classList . add ( 'ws-input-error' ) ;
70+ }
71+ }
72+
3273 return allInputsValid ;
3374}
3475
0 commit comments