svghmi/widget_foreach.ysl2
branchsvghmi
changeset 2892 27dd409fba1d
parent 2891 8927ae8326b2
child 2893 d57a12b8f5db
equal deleted inserted replaced
2891:8927ae8326b2 2892:27dd409fba1d
     1 
     1 
     2 template "widget[@type='ForEach']", mode="widget_defs" {
     2 template "widget[@type='ForEach']", mode="widget_defs" {
     3     param "hmi_element";
     3     param "hmi_element";
       
     4     const "widgets", "func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]";
     4     |     frequency: 2,
     5     |     frequency: 2,
     5     |     dispatch: function(value) {
     6     |     dispatch: function(value) {
     6     |                     // do something
     7     |                     // do something
     7     |     },
     8     |     },
     8     |     init: function() {
     9     |     init: function() {
    12     |             evt => {let new_val = "«func:escape_quotes(@inkscape:label)»");
    13     |             evt => {let new_val = "«func:escape_quotes(@inkscape:label)»");
    13     |                     // do something with new_val
    14     |                     // do something with new_val
    14     |                    });
    15     |                    });
    15     }
    16     }
    16     |     },
    17     |     },
       
    18 
       
    19     |     widgets: [
       
    20     const "labels_regex","concat('^',arg[1]/@value,':[0-9]+')";
       
    21     foreach "$hmi_element/*[regexp:test(@inkscape:label, $labels_regex)]" {
       
    22     |       [ /* «@inkscape:label» */
       
    23         const "elt",".";
       
    24         //foreach "$hmi_elements[ancestor::svg:*/@id = $_id]" {
       
    25         foreach "func:refered_elements(.)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" {
       
    26     |         hmi_widgets["«@id»"]`if "position()!=last()" > ,`
       
    27         }
       
    28     |       ]`if "position()!=last()" > ,`
       
    29     }
       
    30     |     ],
    17 }
    31 }
    18 
    32 
    19 template "widget[@type='ForEach']", mode="widget_subscribe"{
    33 template "widget[@type='ForEach']", mode="widget_subscribe"{
    20     // param "hmi_element";
    34     // param "hmi_element";
    21     |     sub: function(off){
    35     |     sub: function(off){
    22     |         subscribe.call(this,off)
    36     |         subscribe.call(this,off);
       
    37         /* TODO */
    23     |     },
    38     |     },
    24 
    39 
    25     |     unsub: function(){
    40     |     unsub: function(){
    26     |         unsubscribe.call(this)
    41     |         unsubscribe.call(this);
       
    42         /* TODO */
    27     |     },
    43     |     },
    28 }
    44 }