NGRP / node-red-contrib-viseo

Node-RED nodes OpenSourced by VISEO Technologies
Apache License 2.0
227 stars 83 forks source link

Add text button marker prefix #152

Closed siyaod closed 4 years ago

siyaod commented 4 years ago

Hello @TothiViseo ,

Here is the Issue I found: A prefix 'FindSku_' is hard-coded in the function buildAdaptiveCardJson.

Description: This function buildAdaptiveCardJson creates containers in the card for each Markdown section. Each section composes one title, and several Markdown line items.

Within one section/block, all the line items could be displayed as plain texts or buttons.

In case of buttons, this prefix will be added in front of the orginal text, this combined text will be button's value attribute when text gets clicked. For example, all the 'recommended accessories' in the photo below are all clickable buttons, by clicking which a new message will be send with a prefix 'FindSku_'. image


Here is a Fix: Extract button value prefix to configuration. Also, a 'clickable text marker' added to configuration. This new parameter textButtonMarker is an identifier from which we know if displaying one line items as clickable button:

Within one section/block, all the line items could be displayed as plain texts or buttons, according to the value of field textButtonMarker.

The criteria whether a line item is displayed as clickable button is:

In case of buttons, line item is clickable and its value attribute will be set to its text by default. The value attribute could also have a customized prefix via the field textButtonPrefix. When the field textButtonPrefix is set, the value attribute of each line item will be the combination of textButtonPrefix and its original text, When a line item gets clicked.