работающая генерация базовых полей (числа, select, checkbox) + законченные настройки для TDMA
This commit is contained in:
29
front-generator/template/common/all-params-methods.js.j2
Normal file
29
front-generator/template/common/all-params-methods.js.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
{% for g in paramGroups %}
|
||||
settingsSubmit{{ g['group'] | title }}() {
|
||||
if (this.submitStatus.{{ g['group'] }}) { return }
|
||||
{% if g['group'] in dangerousParamGroups %}
|
||||
{ if (!confirm("{{ dangerousParamGroups[g['group']] }}")) return }
|
||||
{% endif %}
|
||||
|
||||
let query = {
|
||||
{% for p in g['params'] %}
|
||||
"{{ p['name'] }}": this.param{{ g['group'] | title }}.{{ p['name'] }},
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
this.submitStatus.{{ g['group'] }} = true
|
||||
fetch('/api/set/{{ g["group"] }}', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(query) })
|
||||
.then(async (resp) => { this.update{{ g['group'] | title }}Settings(await resp.json()) })
|
||||
.catch((reason) => { alert(`Ошибка при применении настроек: ${reason}`) })
|
||||
.finally(() => { this.submitStatus.{{ g['group'] }} = false })
|
||||
},
|
||||
{% endfor %}
|
||||
|
||||
{% for g in paramGroups %}
|
||||
update{{ g['group'] | title }}Settings(vals) {
|
||||
this.submitStatus.{{ g['group'] }} = false
|
||||
{% for p in g['params'] %}
|
||||
this.param{{ g['group'] | title }}.{{ p['name'] }} = vals["settings"]["{{ p['name'] }}"]
|
||||
{% endfor %}
|
||||
},
|
||||
{% endfor %}
|
Reference in New Issue
Block a user