equal
deleted
inserted
replaced
3 template "widget[@type='JsonTable']", mode="widget_class" |
3 template "widget[@type='JsonTable']", mode="widget_class" |
4 || |
4 || |
5 class JsonTableWidget extends Widget{ |
5 class JsonTableWidget extends Widget{ |
6 // arbitrary defaults to avoid missing entries in query |
6 // arbitrary defaults to avoid missing entries in query |
7 cache = [0,100,50]; |
7 cache = [0,100,50]; |
8 init() { |
8 init_common() { |
9 this.spread_json_data_bound = this.spread_json_data.bind(this); |
9 this.spread_json_data_bound = this.spread_json_data.bind(this); |
10 this.handle_http_response_bound = this.handle_http_response.bind(this); |
10 this.handle_http_response_bound = this.handle_http_response.bind(this); |
11 this.fetch_error_bound = this.fetch_error.bind(this); |
11 this.fetch_error_bound = this.fetch_error.bind(this); |
12 this.promised = false; |
12 this.promised = false; |
13 } |
13 } |
252 } |
252 } |
253 |
253 |
254 template "widget[@type='JsonTable']", mode="widget_defs" { |
254 template "widget[@type='JsonTable']", mode="widget_defs" { |
255 param "hmi_element"; |
255 param "hmi_element"; |
256 labels("data"); |
256 labels("data"); |
257 optional_labels("forward backward cursor"); |
|
258 const "data_elt", "$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"; |
257 const "data_elt", "$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"; |
259 | visible: «count($data_elt/*[@inkscape:label])», |
258 | visible: «count($data_elt/*[@inkscape:label])», |
260 | spread_json_data: function(janswer) { |
259 | spread_json_data: function(janswer) { |
261 | let [range,position,jdata] = janswer; |
260 | let [range,position,jdata] = janswer; |
262 | [[1, range], [2, position], [3, this.visible]].map(([i,v]) => { |
261 | [[1, range], [2, position], [3, this.visible]].map(([i,v]) => { |
265 | }); |
264 | }); |
266 apply "$data_elt", mode="json_table_render_except_comments" { |
265 apply "$data_elt", mode="json_table_render_except_comments" { |
267 with "expressions","$initexpr_ns"; |
266 with "expressions","$initexpr_ns"; |
268 with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; |
267 with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; |
269 } |
268 } |
|
269 | }, |
|
270 | init() { |
|
271 | this.init_common(); |
|
272 foreach "$hmi_element/*[starts-with(@inkscape:label,'action_')]" { |
|
273 | id("«@id»").onclick = this.make_on_click("«func:escape_quotes(@inkscape:label)»"); |
|
274 } |
270 | } |
275 | } |
271 } |
276 |
|
277 } |