glueckm / smartvisu

Automatically exported from code.google.com/p/smartvisu
GNU General Public License v3.0
0 stars 0 forks source link

min and max without function on basic.shifter() #36

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. {{ basic.shifter(id~'battery', '', gad_battery, 'icon.battery', '2', '5') }}

What is the expected output? 
<svg id="room_wohnzimmer-123battery" data-widget="icon.battery" 
data-item="WZ_rtr_battery, " data-min="2" data-max="5" class="icon icon0" 
xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
        <g>
            <rect x="44" y="21" width="12" height="3"></rect>
            <rect rx="3" x="35" y="25" width="30" height="45" fill="none"></rect>
        </g>
    </svg>

What do you see instead?
<svg id="room_wohnzimmer-123battery" data-widget="icon.battery" 
data-item="WZ_rtr_battery, " data-min="0" data-max="255" class="icon icon0" 
xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
        <g>
            <rect x="44" y="21" width="12" height="3"></rect>
            <rect rx="3" x="35" y="25" width="30" height="45" fill="none"></rect>
        </g>
    </svg>

What version of the product are you using? On what operating system?
2.7 with lighttpd on raspian

Please provide any additional information below.
data-min and data-max were not taken correctly from widget definition.

Original issue reported on code.google.com by bernd.ge...@gmail.com on 11 Dec 2014 at 10:29

GoogleCodeExporter commented 9 years ago
Here the correction:
{% macro shifter(id, gad_switch, gad_value, pic_on, pic_off, minval, maxval) %}

        {% import "icon.html" as icon %}

        {% if pic_on|slice(0, 5) == 'icon.' %}
                {{ attribute(icon, pic_on|slice(5), [id, gad_switch, gad_value, '', minval, maxval]) }}
        {% else %}
                <span id="{{ uid(page, id) }}" data-widget="basic.shifter" data-item="{{ gad_value }}, {{ gad_switch }}"
                        {% set pic_on = pic_on|default(icon1~'light_light_dim_00.png') %}
                        data-pic-on="{{ pic_on }}" data-pic-off="{{ pic_off |default(icon0~pic_on|slice(icon1|length)) }}"
                        data-min="{{ minval|default('0') }}" data-max="{{ maxval|default('255') }}"
                        class="switch"><a><img class="icon" src="{{ pic_off|default(icon0~'light_light_dim_00.png') }}" /></a>
        </span>
        {% endif %}

{% endmacro %}

Original comment by bernd.ge...@gmail.com on 11 Dec 2014 at 10:37