svghmi/widget_jsontable.ysl2
branchsvghmi
changeset 3081 9e55061c87fa
parent 3080 e5fa1f49f0b9
child 3149 d32e6246cd59
equal deleted inserted replaced
3080:e5fa1f49f0b9 3081:9e55061c87fa
    40         dispatch(value, oldval, index) {
    40         dispatch(value, oldval, index) {
    41             this.cache[index] = value;
    41             this.cache[index] = value;
    42             this.do_http_request();
    42             this.do_http_request();
    43         }
    43         }
    44         make_on_click(...options){
    44         make_on_click(...options){
       
    45             let that = this;
    45             return function(evt){
    46             return function(evt){
    46                 this.do_http_request(...options);
    47                 that.do_http_request(...options);
    47             }
    48             }
    48         }
    49         }
    49         // on_click(evt, ...options) {
    50         // on_click(evt, ...options) {
    50         //     this.do_http_request(...options);
    51         //     this.do_http_request(...options);
    51         // }
    52         // }
   115     const "targetid", "substring-after(@xlink:href,'#')";
   116     const "targetid", "substring-after(@xlink:href,'#')";
   116     const "from_list", "$hmi_lists[(@id | */@id) = $targetid]";
   117     const "from_list", "$hmi_lists[(@id | */@id) = $targetid]";
   117 
   118 
   118     choose {
   119     choose {
   119         when "count($from_list) > 0" {
   120         when "count($from_list) > 0" {
   120             |         id("«@id»").setAttribute("xlink:href", 
   121             |         id("«@id»").setAttribute("xlink:href",
   121             // obtain new target id from HMI:List widget
   122             // obtain new target id from HMI:List widget
   122             |             "#"+hmi_widgets["«$from_list/@id»"].items[«$expressions/expression[1]/@content»]);
   123             |             "#"+hmi_widgets["«$from_list/@id»"].items[«$expressions/expression[1]/@content»]);
   123         }
   124         }
   124         otherwise
   125         otherwise
   125             warning > Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or item. Reference "«@xlink:href»" is not valid and will not be updated.
   126             warning > Clones (svg:use) in JsonTable Widget must point to a valid HMI:List widget or item. Reference "«@xlink:href»" is not valid and will not be updated.
   183 
   184 
   184     const "new_expressions", "func:json_expressions($expressions, $label)";
   185     const "new_expressions", "func:json_expressions($expressions, $label)";
   185 
   186 
   186     const "elt",".";
   187     const "elt",".";
   187     foreach "$new_expressions/expression[position() > 1][starts-with(@name,'onClick')]"
   188     foreach "$new_expressions/expression[position() > 1][starts-with(@name,'onClick')]"
   188     //|         id("«$elt/@id»").setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt, '«@name»', '"+«@content»+"')");
   189     |         id("«$elt/@id»").onclick = this.make_on_click('«@name»', «@content»);
   189     |         id("«$elt/@id»").onclick = this.make_on_click('«@name»', '"+«@content»+"');
       
   190 
   190 
   191     apply ".", mode="json_table_elt_render"
   191     apply ".", mode="json_table_elt_render"
   192         with "expressions", "$new_expressions";
   192         with "expressions", "$new_expressions";
   193 }
   193 }
   194 
   194 
   215         copy "@name";
   215         copy "@name";
   216         attrib "content" > «$varprefix»«position()»
   216         attrib "content" > «$varprefix»«position()»
   217     }
   217     }
   218 
   218 
   219     // revert hiding in case it did happen before
   219     // revert hiding in case it did happen before
   220     // |           id("«@id»").setAttribute("style", "«@style»");
       
   221     |           id("«@id»").style = "«@style»";
   220     |           id("«@id»").style = "«@style»";
   222 
   221 
   223     apply "*", mode="json_table_render_except_comments" {
   222     apply "*", mode="json_table_render_except_comments" {
   224         with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)";
   223         with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)";
   225         with "widget_elts", "$widget_elts";
   224         with "widget_elts", "$widget_elts";
   226     }
   225     }
   227     |         } catch(err) {
   226     |         } catch(err) {
   228     // |           id("«$gid»").setAttribute("style", "display:none");
       
   229     |           id("«$gid»").style = "display:none";
   227     |           id("«$gid»").style = "display:none";
   230     |         }
   228     |         }
   231 }
   229 }
   232 
   230 
   233 template "widget[@type='JsonTable']", mode="widget_defs" {
   231 template "widget[@type='JsonTable']", mode="widget_defs" {