# HG changeset patch # User Edouard Tisserant # Date 1615400989 -3600 # Node ID 50d0fef791d5aa6b73d1bb78a7d19d876f5ddd8c # Parent c059026d8626ef790f4fab28c582fdaf1944965b SVGHMI: Add generic action buttons to JSON table, with an example in tests/svghmi: wipe alar list. diff -r c059026d8626 -r 50d0fef791d5 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Wed Mar 10 19:27:41 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Wed Mar 10 19:29:49 2021 +0100 @@ -1,6 +1,6 @@ - - + + @@ -1693,7 +1693,7 @@ - + @@ -4535,7 +4535,7 @@ cache = [0,100,50]; - init() { + init_common() { this.spread_json_data_bound = this.spread_json_data.bind(this); @@ -4940,13 +4940,6 @@ data - - - - forward backward cursor - - - visible: @@ -4968,6 +4961,20 @@ + }, + + init() { + + this.init_common(); + + + id(" + + ").onclick = this.make_on_click(" + + "); + + } @@ -6801,7 +6808,7 @@ - + diff -r c059026d8626 -r 50d0fef791d5 svghmi/widget_jsontable.ysl2 --- a/svghmi/widget_jsontable.ysl2 Wed Mar 10 19:27:41 2021 +0100 +++ b/svghmi/widget_jsontable.ysl2 Wed Mar 10 19:29:49 2021 +0100 @@ -5,7 +5,7 @@ class JsonTableWidget extends Widget{ // arbitrary defaults to avoid missing entries in query cache = [0,100,50]; - init() { + init_common() { this.spread_json_data_bound = this.spread_json_data.bind(this); this.handle_http_response_bound = this.handle_http_response.bind(this); this.fetch_error_bound = this.fetch_error.bind(this); @@ -254,7 +254,6 @@ template "widget[@type='JsonTable']", mode="widget_defs" { param "hmi_element"; labels("data"); - optional_labels("forward backward cursor"); const "data_elt", "$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"; | visible: «count($data_elt/*[@inkscape:label])», | spread_json_data: function(janswer) { @@ -267,5 +266,12 @@ with "expressions","$initexpr_ns"; with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; } + | }, + | init() { + | this.init_common(); + foreach "$hmi_element/*[starts-with(@inkscape:label,'action_')]" { + | id("«@id»").onclick = this.make_on_click("«func:escape_quotes(@inkscape:label)»"); + } | } -} + +} diff -r c059026d8626 -r 50d0fef791d5 tests/svghmi/py_ext_0@py_ext/pyfile.xml --- a/tests/svghmi/py_ext_0@py_ext/pyfile.xml Wed Mar 10 19:27:41 2021 +0100 +++ b/tests/svghmi/py_ext_0@py_ext/pyfile.xml Wed Mar 10 19:29:49 2021 +0100 @@ -37,7 +37,12 @@ extra = newdata[u'extra'] options = newdata[u'options'] - if len(options) == 2 : + if len(options) == 1 : + action, = options + if action == "action_reset": + del Alarms[:] + AlarmIndex.clear() + elif len(options) == 2 : action, alarmid = options if action == "onClick[acknowledge]": AlarmIndex[int(alarmid)][2] = "ack" diff -r c059026d8626 -r 50d0fef791d5 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Mar 10 19:27:41 2021 +0100 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Mar 10 19:29:49 2021 +0100 @@ -128,12 +128,12 @@ inkscape:current-layer="hmi0" showgrid="false" units="px" - inkscape:zoom="0.42177816" - inkscape:cx="-871.66754" - inkscape:cy="136.19693" - inkscape:window-width="1600" - inkscape:window-height="836" - inkscape:window-x="0" + inkscape:zoom="1.6871126" + inkscape:cx="-820.55411" + inkscape:cy="162.70697" + inkscape:window-width="3840" + inkscape:window-height="2096" + inkscape:window-x="1600" inkscape:window-y="27" inkscape:window-maximized="1" showguides="true" @@ -5214,6 +5214,44 @@ transform="translate(0,-377.48864)" inkscape:label="[0]" /> + + + + + + reset + +