SVGHMI: Fix disapearing elements in case of nested detachable elements. svghmi
authorEdouard Tisserant
Thu, 05 Mar 2020 13:54:29 +0100
branchsvghmi
changeset 2858 39c8d6079f0f
parent 2857 a5c781b2f8f9
child 2859 517583e21bfd
SVGHMI: Fix disapearing elements in case of nested detachable elements.
svghmi/gen_index_xhtml.xslt
svghmi/gen_index_xhtml.ysl2
--- a/svghmi/gen_index_xhtml.xslt	Thu Mar 05 10:23:03 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Thu Mar 05 13:54:29 2020 +0100
@@ -145,7 +145,8 @@
       </xsl:otherwise>
     </xsl:choose>
   </func:function>
-  <xsl:variable name="detachable_elements" select="func:detachable_elements($hmi_pages)"/>
+  <xsl:variable name="_detachable_elements" select="func:detachable_elements($hmi_pages)"/>
+  <xsl:variable name="detachable_elements" select="$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"/>
   <xsl:template mode="index" match="*">
     <xsl:param name="index" select="0"/>
     <xsl:param name="parentpath" select="''"/>
@@ -548,7 +549,7 @@
       <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
       <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
       <xsl:variable name="all_page_ids" select="$page_all_elements[@id = $hmi_elements/@id and @id != $page/@id]/@id"/>
-      <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)"/>
+      <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/&#10;                   ancestor-or-self::*[@id = $detachable_elements/@id]"/>
       <xsl:text>  "</xsl:text>
       <xsl:value-of select="$desc/arg[1]/@value"/>
       <xsl:text>": {
--- a/svghmi/gen_index_xhtml.ysl2	Thu Mar 05 10:23:03 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Thu Mar 05 13:54:29 2020 +0100
@@ -260,9 +260,9 @@
         }
     }
 
-    const "detachable_elements", "func:detachable_elements($hmi_pages)";
-
-
+    // Avoid nested detachables
+    const "_detachable_elements", "func:detachable_elements($hmi_pages)";
+    const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
 
     //////////////// HMI Tree Index
 
@@ -591,7 +591,11 @@
 
             const "all_page_ids","$page_all_elements[@id = $hmi_elements/@id and @id != $page/@id]/@id";
 
-            const "required_detachables", "func:sumarized_elements($page_all_elements)";
+            // Take closest ancestor in detachable_elements
+            // since nested detachable elements are filtered out
+            const "required_detachables", 
+                """func:sumarized_elements($page_all_elements)/
+                   ancestor-or-self::*[@id = $detachable_elements/@id]""";
 
             |   "«$desc/arg[1]/@value»": {
             |     widget: hmi_widgets["«@id»"],