svghmi/widget_foreach.ysl2
branchsvghmi
changeset 2892 27dd409fba1d
parent 2891 8927ae8326b2
child 2893 d57a12b8f5db
--- a/svghmi/widget_foreach.ysl2	Fri Mar 20 10:46:15 2020 +0100
+++ b/svghmi/widget_foreach.ysl2	Mon Mar 23 10:16:38 2020 +0100
@@ -1,6 +1,7 @@
 
 template "widget[@type='ForEach']", mode="widget_defs" {
     param "hmi_element";
+    const "widgets", "func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]";
     |     frequency: 2,
     |     dispatch: function(value) {
     |                     // do something
@@ -14,15 +15,30 @@
     |                    });
     }
     |     },
+
+    |     widgets: [
+    const "labels_regex","concat('^',arg[1]/@value,':[0-9]+')";
+    foreach "$hmi_element/*[regexp:test(@inkscape:label, $labels_regex)]" {
+    |       [ /* «@inkscape:label» */
+        const "elt",".";
+        //foreach "$hmi_elements[ancestor::svg:*/@id = $_id]" {
+        foreach "func:refered_elements(.)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" {
+    |         hmi_widgets["«@id»"]`if "position()!=last()" > ,`
+        }
+    |       ]`if "position()!=last()" > ,`
+    }
+    |     ],
 }
 
 template "widget[@type='ForEach']", mode="widget_subscribe"{
     // param "hmi_element";
     |     sub: function(off){
-    |         subscribe.call(this,off)
+    |         subscribe.call(this,off);
+        /* TODO */
     |     },
 
     |     unsub: function(){
-    |         unsubscribe.call(this)
+    |         unsubscribe.call(this);
+        /* TODO */
     |     },
 }