@@ -10,10 +10,34 @@ import {
10
10
useApiStaticInputsListQuery ,
11
11
} from "services/api/endpoints" ;
12
12
import type {
13
+ Attribute ,
13
14
SQLInput ,
14
15
StaticInput ,
15
16
} from "services/api/generated/api.generated" ;
16
17
18
+ /**
19
+ * Tests if node is a direct parent of attribute and if node kind is choice
20
+ *
21
+ * ie: returns true if
22
+ * Node path => `Observation.effective[x]` & attribute path => `Observation.effectiveBoolean`
23
+ * @param attribute The attribute that has an input
24
+ * @param node The current node to be tested as the attribute ancestor
25
+ * @returns True if node kind is "choice" and node is a parent of attribute
26
+ */
27
+ const isAttributeChoiceOfNode = (
28
+ attribute : Attribute ,
29
+ node : ElementNode
30
+ ) : boolean => {
31
+ // Node kind has to be "choice"
32
+ if ( node . kind !== "choice" ) return false ;
33
+
34
+ const isNodeParentOfAttribute = node . children . some (
35
+ ( { path } ) => path === attribute . path
36
+ ) ;
37
+
38
+ return isNodeParentOfAttribute ;
39
+ } ;
40
+
17
41
const useIsNodePending = ( node : ElementNode ) : boolean => {
18
42
const { mappingId } = useParams < { mappingId ?: string } > ( ) ;
19
43
@@ -66,7 +90,9 @@ const useIsNodePending = (node: ElementNode): boolean => {
66
90
attributesWithInputs !== undefined &&
67
91
attributesWithInputs . some (
68
92
( attribute ) =>
69
- attribute . path === node . path || attribute . path . startsWith ( node . path )
93
+ attribute . path === node . path ||
94
+ attribute . path . startsWith ( node . path ) ||
95
+ isAttributeChoiceOfNode ( attribute , node )
70
96
)
71
97
) ;
72
98
} ;
0 commit comments