SVGHMI: JsonTable now updates range and position variables so that slider widget can update. svghmi
authorEdouard Tisserant
Wed, 26 Aug 2020 14:27:54 +0200
branchsvghmi
changeset 3041 de4503de2f8c
parent 3040 acecaeadf20d
child 3042 ed43facc7137
SVGHMI: JsonTable now updates range and position variables so that slider widget can update.
svghmi/gen_index_xhtml.xslt
svghmi/widget_jsontable.ysl2
tests/svghmi/svghmi_0@svghmi/svghmi.svg
--- a/svghmi/gen_index_xhtml.xslt	Wed Aug 26 14:24:43 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt	Wed Aug 26 14:27:54 2020 +0200
@@ -1241,7 +1241,7 @@
 </xsl:text>
     <xsl:text>    apply_hmi_value(index, new_val) {
 </xsl:text>
-    <xsl:text>        return apply_hmi_value(this.get_variable_index(0), new_val);
+    <xsl:text>        return apply_hmi_value(this.get_variable_index(index), new_val);
 </xsl:text>
     <xsl:text>    }
 </xsl:text>
@@ -3403,7 +3403,9 @@
 </xsl:text>
     <xsl:text>            .then(res =&gt; res.json())
 </xsl:text>
-    <xsl:text>            .then(this.spread_json_data);
+    <xsl:text>            .then(function(res){console.log(res);return res;})
+</xsl:text>
+    <xsl:text>            .then(this.spread_json_data.bind(this));
 </xsl:text>
     <xsl:text>
 </xsl:text>
@@ -3694,6 +3696,10 @@
 </xsl:text>
     <xsl:text>        let [range,position,jdata] = janswer;
 </xsl:text>
+    <xsl:text>        this.apply_hmi_value(1, range);
+</xsl:text>
+    <xsl:text>        this.apply_hmi_value(2, position);
+</xsl:text>
     <xsl:text>        console.log(range,position,jdata);
 </xsl:text>
     <xsl:apply-templates mode="json_table_render" select="$data_elt/*">
--- a/svghmi/widget_jsontable.ysl2	Wed Aug 26 14:24:43 2020 +0200
+++ b/svghmi/widget_jsontable.ysl2	Wed Aug 26 14:27:54 2020 +0200
@@ -19,7 +19,7 @@
 
             fetch(this.args[0], options)
                 .then(res => res.json())
-                .then(this.spread_json_data);
+                .then(this.spread_json_data.bind(this));
 
         }
         dispatch(value, oldval, index) {
@@ -197,6 +197,8 @@
     |     visible: «count($data_elt/*[@inkscape:label])»,
     |     spread_json_data: function(janswer) {
     |         let [range,position,jdata] = janswer;
+    |         this.apply_hmi_value(1, range);
+    |         this.apply_hmi_value(2, position);
     |         console.log(range,position,jdata);
     apply "$data_elt/*", mode="json_table_render" {
         with "expressions","$initexpr_ns";
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Wed Aug 26 14:24:43 2020 +0200
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg	Wed Aug 26 14:27:54 2020 +0200
@@ -182,11 +182,11 @@
      inkscape:pageopacity="0"
      inkscape:pageshadow="2"
      inkscape:document-units="px"
-     inkscape:current-layer="g1887"
+     inkscape:current-layer="hmi0"
      showgrid="false"
      units="px"
      inkscape:zoom="2.1826319"
-     inkscape:cx="845.38352"
+     inkscape:cx="771.61936"
      inkscape:cy="510.70061"
      inkscape:window-width="1800"
      inkscape:window-height="836"
@@ -2640,7 +2640,7 @@
   </g>
   <g
      id="g1289"
-     inkscape:label="HMI:JsonTable:/alarms@/ALARMNOTIFY@.position@.range"
+     inkscape:label="HMI:JsonTable:/alarms@/ALARMNOTIFY@.range@.position"
      transform="matrix(0.5,0,0,0.5,515.30409,71.500438)">
     <g
        id="g5231"