@@ -2,34 +2,35 @@ import { observer } from "mobx-react";
2
2
import { types , getParent } from "mobx-state-tree" ;
3
3
4
4
import NormalizationMixin from "../../mixins/Normalization" ;
5
+ import { AreaMixin } from "../../mixins/AreaMixin" ;
5
6
import RegionsMixin from "../../mixins/Regions" ;
6
7
import { guidGenerator } from "../../core/Helpers" ;
7
8
8
9
import { HtxTextBox } from "../../components/HtxTextBox/HtxTextBox" ;
9
10
import { cn } from "../../utils/bem" ;
11
+ import { CustomInterfaceModel } from "./Custom" ;
12
+ import { IconGrid } from "@humansignal/icons" ;
10
13
11
14
const Model = types
12
15
. model ( "CustomRegionModel" , {
13
- id : types . optional ( types . identifier , guidGenerator ) ,
14
- pid : types . optional ( types . string , guidGenerator ) ,
15
- type : "customregion" ,
16
+ type : "custominterface" ,
17
+ object : types . late ( ( ) => types . reference ( CustomInterfaceModel ) ) ,
16
18
17
19
// Main payload for this region; matches result type name
18
20
custominterface : types . frozen ( ) ,
19
21
20
22
_value : types . frozen ( ) ,
21
23
// states: types.array(types.union(ChoicesModel)),
22
24
} )
23
- . volatile ( ( ) => ( {
24
- classification : true ,
25
- perRegionTags : [ ] ,
26
- results : [ ] ,
27
- selected : false ,
28
- } ) )
29
25
. views ( ( self ) => ( {
30
26
get parent ( ) {
31
27
return getParent ( self ) ;
32
28
} ,
29
+
30
+ get noLabelView ( ) {
31
+ return "Custom region" ;
32
+ } ,
33
+
33
34
getRegionElement ( ) {
34
35
return document . querySelector ( `#CustomRegion-${ self . id } ` ) ;
35
36
} ,
@@ -58,17 +59,9 @@ const Model = types
58
59
deleteRegion ( ) {
59
60
self . parent . remove ( self ) ;
60
61
} ,
61
-
62
- selectRegion ( ) {
63
- self . selected = true ;
64
- } ,
65
-
66
- afterUnselectRegion ( ) {
67
- self . selected = false ;
68
- } ,
69
62
} ) ) ;
70
63
71
- const CustomRegionModel = types . compose ( "CustomRegionModel" , RegionsMixin , NormalizationMixin , Model ) ;
64
+ const CustomRegionModel = types . compose ( "CustomRegionModel" , RegionsMixin , AreaMixin , NormalizationMixin , Model ) ;
72
65
73
66
const HtxCustomRegionView = ( { item, onFocus } ) => {
74
67
const classes = [ styles . mark ] ;
@@ -139,6 +132,17 @@ const HtxCustomRegionView = ({ item, onFocus }) => {
139
132
140
133
const HtxCustomRegion = observer ( HtxCustomRegionView ) ;
141
134
135
+ // required for NodeViews
136
+ CustomRegionModel . nodeView = {
137
+ name : "CustomRegion" ,
138
+ icon : IconGrid ,
139
+ fullContent : ( node ) => (
140
+ < span style = { { color : "#5a5a5a" } } >
141
+ { JSON . stringify ( node . custominterface ) }
142
+ </ span >
143
+ ) ,
144
+ } ;
145
+
142
146
export { CustomRegionModel , HtxCustomRegion } ;
143
147
144
148
0 commit comments