@@ -109,7 +109,7 @@ function FeaturesV1({
109
109
{ value : 'HRS' , label : 'HRS' }
110
110
] ;
111
111
112
- const operationOptions = [ '+' , '-' , '*' , '/' ] ;
112
+ const operationOptions = [ '+' , '-' , '*' , '/' , 'Number' , 'String' ] ;
113
113
const conditionOptions = [ '==' , '>' , '<' , '<>' ] ;
114
114
const typeOptions = [ 'PARAM ID' , 'NUMBER' , 'TEXT' ] ;
115
115
@@ -145,9 +145,9 @@ function FeaturesV1({
145
145
errors [ `${ rowPath } .paramId` ] = 'Param ID is required' ;
146
146
}
147
147
148
- // Validate Module Description
148
+ // Validate Comment
149
149
if ( ! row . moduleDesc || row . moduleDesc . trim ( ) === '' ) {
150
- errors [ `${ rowPath } .moduleDesc` ] = 'Module Description is required' ;
150
+ errors [ `${ rowPath } .moduleDesc` ] = 'Comment is required' ;
151
151
}
152
152
153
153
// Enhanced: Check condition type instead of ifChecked
@@ -161,10 +161,29 @@ function FeaturesV1({
161
161
if ( row . standardMH === null || row . standardMH === undefined || row . standardMH === '' ) {
162
162
errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM is required' ;
163
163
} else {
164
- // Validate that it only contains allowed mathematical characters
165
- const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] + $ / ;
166
- if ( ! mathRegex . test ( row . standardMH ) ) {
167
- errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM must contain only numbers and math operators (+, -, *, /, ., (, ))' ;
164
+ // Enhanced validation based on operation type
165
+ const operation = row . operation ;
166
+ if ( operation === 'Number' ) {
167
+ // Validate mathematical characters
168
+ const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] + $ / ;
169
+ if ( ! mathRegex . test ( row . standardMH ) ) {
170
+ errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM must contain only numbers and math operators (+, -, *, /, ., (, ))' ;
171
+ }
172
+ } else if ( operation === 'String' ) {
173
+ // Validate string characters (A-Z, a-z, _, -, single space)
174
+ const stringRegex = / ^ [ A - Z a - z _ \- ] + $ / ;
175
+ const hasMultipleSpaces = / \s { 2 , } / . test ( row . standardMH ) ;
176
+ if ( ! stringRegex . test ( row . standardMH ) ) {
177
+ errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM must contain only letters, underscore, dash, and single spaces' ;
178
+ } else if ( hasMultipleSpaces ) {
179
+ errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM cannot contain multiple consecutive spaces' ;
180
+ }
181
+ } else {
182
+ // For +, -, *, / operations - validate mathematical characters
183
+ const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] + $ / ;
184
+ if ( ! mathRegex . test ( row . standardMH ) ) {
185
+ errors [ `${ rowPath } .standardMH` ] = 'Standard MH/UOM must contain only numbers and math operators (+, -, *, /, ., (, ))' ;
186
+ }
168
187
}
169
188
}
170
189
} else {
@@ -524,15 +543,22 @@ function FeaturesV1({
524
543
const paramDisplay = row . paramId ? `[${ row . paramId } ]` : '[PARAM]' ;
525
544
// Convert to string and handle both string and number types
526
545
const standardMH = String ( row . standardMH || '' ) ;
546
+ const operation = row . operation || '*' ;
527
547
528
- // If Standard MH/UOM is empty, show just Param ID
529
- if ( ! standardMH || standardMH . trim ( ) === '' || standardMH === '0' ) {
530
- return paramDisplay ;
548
+ // Special handling for Number and String operations
549
+ if ( operation === 'Number' || operation === 'String' ) {
550
+ // For Number and String operations, show only Standard MH/UOM value
551
+ if ( ! standardMH || standardMH . trim ( ) === '' ) {
552
+ return operation === 'Number' ? '0' : 'EMPTY_STRING' ;
553
+ }
554
+ return standardMH ;
555
+ } else {
556
+ // For math operations (+, -, *, /), show full format
557
+ if ( ! standardMH || standardMH . trim ( ) === '' || standardMH === '0' ) {
558
+ return paramDisplay ;
559
+ }
560
+ return `${ paramDisplay } ${ operation } ${ standardMH } ` ;
531
561
}
532
-
533
- // Otherwise show full format: Param ID + Operation + Standard MH/UOM
534
- const operation = row . operation || '*' ;
535
- return `${ paramDisplay } ${ operation } ${ standardMH } ` ;
536
562
} else {
537
563
const leftVal = row . leftValue || 'LEFT' ;
538
564
const condition = row . condition || '==' ;
@@ -929,18 +955,6 @@ function FeaturesV1({
929
955
/>
930
956
</ div >
931
957
932
- { /* Module Description */ }
933
- < div className = 'col-block w200' >
934
- < TextField
935
- label = "Module Description"
936
- value = { row . moduleDesc }
937
- onChange = { ( e ) => updateRow ( row . id , 'moduleDesc' , e . target . value ) }
938
- variant = "outlined"
939
- size = "small"
940
- error = { hasFieldError ( row , 'moduleDesc' ) }
941
- />
942
- </ div >
943
-
944
958
{ /* UOM - Disabled when IF checked */ }
945
959
< div className = 'col-block' >
946
960
< FormControl
@@ -987,25 +1001,48 @@ function FeaturesV1({
987
1001
</ FormControl >
988
1002
</ div >
989
1003
990
- { /* Standard MH/UOM - String input with math validation */ }
1004
+ { /* Standard MH/UOM - Dynamic validation based on operation */ }
991
1005
< div className = 'col-block' >
992
1006
< TextField
993
1007
label = "Standard MH/UOM"
994
1008
type = "text"
995
1009
value = { String ( row . standardMH || '' ) }
996
1010
onChange = { ( e ) => {
997
1011
const value = e . target . value ;
998
- // Only allow numbers, +, -, *, /, ., (, )
999
- const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] * $ / ;
1000
- if ( mathRegex . test ( value ) ) {
1001
- updateRow ( row . id , 'standardMH' , value ) ;
1012
+ const operation = row . operation ;
1013
+
1014
+ // Different validation based on operation type
1015
+ if ( operation === 'Number' ) {
1016
+ // Only allow numbers, +, -, *, /, ., (, )
1017
+ const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] * $ / ;
1018
+ if ( mathRegex . test ( value ) ) {
1019
+ updateRow ( row . id , 'standardMH' , value ) ;
1020
+ }
1021
+ } else if ( operation === 'String' ) {
1022
+ // Allow A-Z, a-z, _, -, and single space
1023
+ const stringRegex = / ^ [ A - Z a - z _ \- ] * $ / ;
1024
+ // Check for single space (no multiple consecutive spaces)
1025
+ const hasMultipleSpaces = / \s { 2 , } / . test ( value ) ;
1026
+ if ( stringRegex . test ( value ) && ! hasMultipleSpaces ) {
1027
+ updateRow ( row . id , 'standardMH' , value ) ;
1028
+ }
1029
+ } else {
1030
+ // For +, -, *, / operations - math validation
1031
+ const mathRegex = / ^ [ 0 - 9 + \- * / . ( ) ] * $ / ;
1032
+ if ( mathRegex . test ( value ) ) {
1033
+ updateRow ( row . id , 'standardMH' , value ) ;
1034
+ }
1002
1035
}
1003
1036
} }
1004
1037
variant = "outlined"
1005
1038
size = "small"
1006
1039
disabled = { row . conditionType !== 'None' }
1007
1040
error = { hasFieldError ( row , 'standardMH' ) }
1008
- placeholder = "e.g. 10, (2+3)*4, 15.5"
1041
+ placeholder = {
1042
+ row . operation === 'Number' ? "e.g. 10, (2+3)*4, 15.5" :
1043
+ row . operation === 'String' ? "e.g. Product_Name, Test-Case" :
1044
+ "e.g. 10, (2+3)*4, 15.5"
1045
+ }
1009
1046
/>
1010
1047
</ div >
1011
1048
@@ -1113,6 +1150,18 @@ function FeaturesV1({
1113
1150
< span > { generateFormula ( row ) } </ span >
1114
1151
</ div >
1115
1152
1153
+ { /* Comment */ }
1154
+ < div className = 'col-block w200' >
1155
+ < TextField
1156
+ label = "Comment"
1157
+ value = { row . moduleDesc }
1158
+ onChange = { ( e ) => updateRow ( row . id , 'moduleDesc' , e . target . value ) }
1159
+ variant = "outlined"
1160
+ size = "small"
1161
+ error = { hasFieldError ( row , 'moduleDesc' ) }
1162
+ />
1163
+ </ div >
1164
+
1116
1165
{ /* Delete Button - Only show for main rows, not for TRUE/FALSE child rows */ }
1117
1166
{ ! isChild && (
1118
1167
< div className = 'col-block w60' >
0 commit comments