фикс некорректного ограничения центральной частоты
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
{# https://ru.stackoverflow.com/questions/1241064 #}
|
||||
{% macro build_widget_number(param_group, widget) %}<label{% if widget.v_show %} v-show="{{ widget.v_show }}"{% endif %}><span>{{ widget.label }}</span><input type="number" v-model="param{{ param_group | title }}.{{ widget.name }}"{% if widget['min'] %} min="{{ widget['min'] }}"{% endif %}{% if widget['max'] %} max="{{ widget['max'] }}"{% endif %}{% if widget['step'] %} step="{{ widget['step'] }}"{% endif %}/></label>{% endmacro %}
|
||||
|
||||
{% macro js_build_number_int_validator(widget) %}{{ '{' }}{% if widget['min'] %}min:{{ widget['min'] }},{% endif %}{% if widget['max'] %}max:{{ widget['max'] }}{% endif %}{{ '}' }}{% endmacro %}
|
||||
{% macro js_build_number_number_validator(widget) %}{{ '{' }}{% if widget['min'] %}min:{{ widget['min'] }},{% endif %}{% if widget['max'] %}max:{{ widget['max'] }},{% endif %}{% if widget['step'] %}step:{{ widget['step'] }}{% endif %}{{ '}' }}{% endmacro %}
|
||||
|
||||
{% macro build_widget_number_int(param_group, widget) %}<label{% if widget.v_show %} v-show="{{ widget.v_show }}"{% endif %}>
|
||||
<span>{{ widget.label }}</span>
|
||||
<input type="text" v-model.lazy="param{{ param_group | title }}.{{ widget.name }}" @change="e => {{ build_setter(param_group, widget, "inputFormatInt(e.target.value, " ~ js_build_number_int_validator(widget) ~ ")") }}"/>
|
||||
<input type="text" v-model.lazy="param{{ param_group | title }}.{{ widget.name }}" @change="e => {{ build_setter(param_group, widget, "inputFormatNumber(e.target.value, " ~ js_build_number_number_validator(widget) ~ ")") }}"/>
|
||||
</label>{% endmacro %}
|
||||
|
||||
|
||||
@@ -79,15 +79,15 @@
|
||||
|
||||
{% macro build_getter_js(param_group, widget) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}this.param{{ param_group | title }}.{{ widget.name }}{%
|
||||
elif widget.widget == 'number-int' %}parseInt(this.param{{ param_group | title }}.{{ widget.name }}.replace(/[^0-9]/g, '')){%
|
||||
elif widget.widget == 'number-int' %}parseFloat(this.param{{ param_group | title }}.{{ widget.name }}.replace(/[^0-9,.]/g, '').replace(',', '.')){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
||||
{% macro build_setter_js(param_group, widget, expr) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}this.param{{ param_group | title }}.{{ widget.name }} = {{ expr }}{%
|
||||
elif widget.widget == 'number-int' %}this.param{{ param_group | title }}.{{ widget.name }} = this.inputFormatInt({{ expr }}, {{ js_build_number_int_validator(widget) }}){%
|
||||
elif widget.widget == 'number-int' %}this.param{{ param_group | title }}.{{ widget.name }} = this.inputFormatNumber({{ expr }}, {{ js_build_number_number_validator(widget) }}){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
||||
{% macro build_setter(param_group, widget, expr) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}param{{ param_group | title }}.{{ widget.name }} = {{ expr }}{%
|
||||
elif widget.widget == 'number-int' %}param{{ param_group | title }}.{{ widget.name }} = ({{ expr }}).toString(){%
|
||||
elif widget.widget == 'number-int' %}param{{ param_group | title }}.{{ widget.name }} = inputFormatNumber({{ expr }}, {{ js_build_number_number_validator(widget) }}){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
@@ -153,10 +153,12 @@
|
||||
return []
|
||||
}
|
||||
},
|
||||
inputFormatInt(src, validation) {
|
||||
inputFormatNumber(src, validation) {
|
||||
if (validation === null || validation === undefined) { validation = {} }
|
||||
const rawVal = src.toString().replace(/[^0-9]/g, '')
|
||||
let result = rawVal === '' ? 0 : parseInt(rawVal)
|
||||
const rawVal = src.toString().replace(/[^0-9.,]/g, '').replace(',', '.')
|
||||
let result = rawVal === '' ? 0 : parseFloat(rawVal)
|
||||
const step = 'step' in validation ? validation['step']: 1.0
|
||||
result = Math.round(result / step) * step
|
||||
if ('min' in validation) { if (result <= validation['min']) { result = validation['min'] } }
|
||||
if ('max' in validation) { if (result >= validation['max']) { result = validation['max'] } }
|
||||
return result.toLocaleString()
|
||||
|
Reference in New Issue
Block a user