@@ -13,16 +13,18 @@ import { ROOM, THING, TUPLE } from '../../../../Constants/ThingTypes';
1313import { ThingActionsDialogTAG } from '../../../../Constants/Tags' ;
1414import {
1515 THING_QUERY ,
16+ TYPE_INFO_CHILD_ARRAY_QUERY ,
1617 TYPE_INFO_CHILD_THING_QUERY ,
17- TYPE_INFO_ELSE_QUERY ,
18+ TYPE_INFO_PARENT_ARRAY_QUERY ,
1819 TYPE_INFO_PARENT_THING_QUERY ,
1920 TYPE_INFO_ROOT_THING_QUERY ,
2021} from '../../../../TiQueries/Queries' ;
2122import {
23+ ID_ARGS ,
24+ TYPE_INFO_CHILD_ARRAY_ARGS ,
2225 TYPE_INFO_CHILD_THING_ARGS ,
23- TYPE_INFO_ELSE_ARGS ,
26+ TYPE_INFO_PARENT_ARRAY_ARGS ,
2427 TYPE_INFO_PARENT_THING_ARGS ,
25- ID_ARGS ,
2628} from '../../../../TiQueries/Arguments' ;
2729
2830import DialogButtons from './DialogButtons' ;
@@ -59,17 +61,21 @@ const ThingActionsDialog = ({onClose, child, parent, thing, scope, isRoot}) => {
5961 let query = '' ;
6062 let jsonArgs = null ;
6163 if ( parent . id == null ) {
62- query = TYPE_INFO_ROOT_THING_QUERY ; // check if custom type
64+ query = TYPE_INFO_ROOT_THING_QUERY ;
6365 jsonArgs = ID_ARGS ( child . id ) ;
6466 } else if ( parent . type == THING ) {
65- query = TYPE_INFO_PARENT_THING_QUERY ; // check if custom type
67+ query = TYPE_INFO_PARENT_THING_QUERY ;
6668 jsonArgs = TYPE_INFO_PARENT_THING_ARGS ( parent . id , child . name ) ;
6769 } else if ( child . type == THING ) {
6870 query = TYPE_INFO_CHILD_THING_QUERY ; // in case parent is set than indexing is not supported. Therefore we need to check child type by id.
6971 jsonArgs = TYPE_INFO_CHILD_THING_ARGS ( child . id , parent . id , parent . name ) ;
72+ } else if ( parent . index == null ) {
73+ query = TYPE_INFO_CHILD_ARRAY_QUERY ;
74+ jsonArgs = TYPE_INFO_CHILD_ARRAY_ARGS ( parent . id , parent . pname , child . index ) ;
7075 } else {
71- query = TYPE_INFO_ELSE_QUERY ; // check if custom type
72- jsonArgs = TYPE_INFO_ELSE_ARGS ( parent . id , parent . name , child . name ) ;
76+ query = TYPE_INFO_PARENT_ARRAY_QUERY ;
77+ // pname is the property name without any index indication; so `arr` instead of `arr[2]`
78+ jsonArgs = TYPE_INFO_PARENT_ARRAY_ARGS ( parent . id , parent . index , parent . pname , child . index ) ;
7379 }
7480 TypeActions . getType ( query , scope , jsonArgs , tag , setType ) ;
7581 EnumActions . getEnums ( scope , tag , setEnums ) ;
@@ -205,14 +211,16 @@ ThingActionsDialog.propTypes = {
205211 parent : PropTypes . shape ( {
206212 id : PropTypes . number ,
207213 index : PropTypes . number ,
214+ isTuple : PropTypes . bool ,
208215 name : PropTypes . string ,
216+ pname : PropTypes . string ,
209217 type : PropTypes . string ,
210- isTuple : PropTypes . bool ,
211218 } ) . isRequired ,
212219 child : PropTypes . shape ( {
213220 id : PropTypes . number ,
214221 index : PropTypes . number ,
215222 name : PropTypes . string ,
223+ pname : PropTypes . string ,
216224 type : PropTypes . string ,
217225 val : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
218226 } ) . isRequired ,
0 commit comments