1
+ import { settingsNodeColors as nodeColors } from "./settings_node_colors.js"
2
+
3
+ export var storeAttribute = {
4
+ templateName : "storeAttribute" ,
5
+ name : "Store Attribute" ,
6
+ style :{
7
+ headerColor :nodeColors . inputObject ,
8
+ } ,
9
+ category :"attribute" ,
10
+
11
+ props :[
12
+ { id :"output" , expect :"data" , label :"output" , type :"hidden" , editable :false , socket :"output" , value :"output" } ,
13
+ // {id:"paramName", expect:"text", label:"Param Name", type:"text", editable:true, socket:"input", value:"...."},
14
+ // {id:"paramIndex", expect:"text", label:"Param Name", type:"text", editable:true, socket:"input", value:"...."},
15
+ { id :"a" , expect :"data" , label :"Data" , type :"text" , editable :true , socket :"input" , value :"0" } ,
16
+ // {id:"selection", expect:"array", label:"Selection", type:"hidden", editable:false, socket:"input", value:"...."},
17
+ { id :"attributeName" , expect :"text" , label :"Name" , type :"text" , editable :true , socket :"input" , value :"Attribue" } ,
18
+ { id :"attribute" , expect :"array" , label :"Attribute" , type :"hidden" , editable :false , socket :"input" , value :"...." } ,
19
+ ] ,
20
+ methods :{
21
+ } ,
22
+ event :{
23
+ onEvaluate :( props , globals ) => {
24
+
25
+ if ( Array . isArray ( props . a . get ( ) ) && props . a . get ( ) [ 0 ] && props . a . get ( ) [ 0 ] . attributes . type ) {
26
+ var oldDataSet = props . a . get ( )
27
+ var newDataSet = [ ]
28
+ for ( let i = 0 ; i < oldDataSet . length ; i ++ ) {
29
+ const element = oldDataSet [ i ] ;
30
+ // var condition = props.selection.get(element) //TODO read condition
31
+ // console.log(condition);
32
+ // // alert("eee")
33
+ // if (condition == 1) {
34
+ // newDataSet.push(element)
35
+ // }
36
+ if ( Array . isArray ( props . attribute . get ( ) ) && props . attribute . get ( ) [ i ] ) { //if is an array
37
+ if ( props . attribute . get ( ) [ i ] . relations ) { //if field is type relation
38
+ element . attributes [ props . attributeName . get ( ) ] = props . attribute . get ( ) [ i ] . relations
39
+ } else {
40
+ element . attributes [ props . attributeName . get ( ) ] = props . attribute . get ( ) [ i ]
41
+ }
42
+
43
+ }
44
+
45
+ newDataSet . push ( element )
46
+ }
47
+ props . output . set ( newDataSet )
48
+ }
49
+ } ,
50
+ // onInit:(props) =>{
51
+ // },
52
+ } ,
53
+ }
0 commit comments