Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Add support for advanced config values/multiple selections in settings #150

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 52 additions & 21 deletions html/templates/modalFrames/configFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,59 @@ <h5>{{plugin.screenName}}</h5>
<label class="control-label" title="{{plugin['elementConfig_meta'][config.name]['desc']}}">{% if plugin['config_meta'][config.name]['human'] %}{{ plugin['config_meta'][config.name]['human'] }}{% else %}{{ config.name.replace("_", " ") }}{% endif %}</label>
<div class="controls">
{% if 'select' in config.name %}
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}">
{% for k,v in plugin['_'+config.name]().items() %}
<option value="{{k}}" {% if config.value == k %}selected{% endif %}>{{v}}</option>
{% endfor %}
</select>
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}">
{% for k,v in plugin['_'+config.name]().items() %}
<option value="{{k}}" {% if config.value == k %}selected{% endif %}>{{v}}</option>
{% endfor %}
</select>
{% elif config.curType() == 'complex' %}
{% if config.value.use_checkboxes %}
{% if not config.required %}
<label class="checkbox{% if config.value.use_checkboxes == 'inline'%} inline{% endif %}"
style="display: none">
<input type="checkbox" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}"
value="__none__" disabled="disabled" />
--
</label>
{% endif %}
{% for v in config.value.options %}
<label class="checkbox{% if config.value.use_checkboxes == 'inline'%} inline{% endif %}"
style="text-transform: none">
<input type="checkbox" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}"
value="{{v}}"{% if v in config.value.selected %} checked="checked"{% endif %}
onclick="var ti = 'input[name=\''+$(this).attr('name')+'\']'; if ($(ti+':checked').length === 0) { $(ti).eq(0).prop('checked', true).prop('disabled', false); } else { $(ti).eq(0).prop('checked', false).prop('disabled', true); }"
/>
{{v}}
</label>
{% endfor %}
{% else %}
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}"{% if config.value.multiple %} multiple="multiple"{% endif %}
onclick="if ($(this).val() === null) { $(this).val('__none__'); $('[value=\'__none__\']', this).prop('disabled', false); } else { $('[value=\'__none__\']', this).prop('selected', false).prop('disabled', true); }">
{% if not config.required %}
<option value="__none__" disabled="disabled">--- none selected ---</option>
{% endif %}
{% for v in config.value.options %}
<option value="{{v}}" {% if v in config.value.selected %}selected{% endif %}>{{v}}</option>
{% endfor %}
</select>
{% endif %}
{% else %}
{% if config.curType() == 'int' and 'enable' not in config.name -%}
{% set inputType = 'number" step="any'%}
{% elif config.curType() == 'bool' or 'enable' in config.name%}
{% if config.value %}
{# this is a little dodgy. we append the checked attr with manipulating the string that is set for the input type#}
{% set inputType = 'checkbox" checked="checked'%}
{% else %}
{% set inputType = 'checkbox'%}
{% endif %}
<input name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" type="hidden" value="off"/>
{% elif 'password' in config.name %}
{% set inputType = 'password'%}
{% else %}
{% set inputType = 'text'%}
{%- endif %}
{% if config.curType() == 'int' and 'enable' not in config.name %}
{% set inputType = 'number" step="any'%}
{% elif config.curType() == 'bool' or 'enable' in config.name%}
{% if config.value %}

{# this is a little dodgy. we append the checked attr with manipulating the string that is set for the input type#}
{% set inputType = 'checkbox" checked="checked'%}
{% else %}
{% set inputType = 'checkbox'%}
{% endif %}
<input name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" type="hidden" value="off"/>
{% elif 'password' in config.name %}
{% set inputType = 'password'%}
{% else %}
{% set inputType = 'text'%}
{%- endif %}
<input data-belongsto="{{plugin.name|idSafe}}" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" data-configname="{{config.name}}" type="{{inputType}}" {% if config.value %} value="{{ config.value }}"{% endif %} {% if plugin['config_meta'][config.name]['placeholder'] %}placeholder="{{ plugin['config_meta'][config.name]['placeholder'] }}"{% endif %} onChange="{{onChange}}" title="{{plugin['config_meta'][config.name]['desc']}}"/>
{% endif %}
</div>
Expand Down
75 changes: 53 additions & 22 deletions html/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,60 @@ <h4>{{ plugin.screenName }}{% if plugin._type != 'MediaTypeManager'%} ({{ plugin
</label>
<div class="controls">
{% if 'select' in config.name %}
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}">
{% for k,v in plugin['_'+config.name]().items() %}
<option value="{{k}}" {% if config.value == k %}selected{% endif %}>{{v}}</option>
{% endfor %}
</select>
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}">
{% for k,v in plugin['_'+config.name]().items() %}
<option value="{{k}}" {% if config.value == k %}selected{% endif %}>{{v}}</option>
{% endfor %}
</select>
{% elif config.curType() == 'complex' %}
{% if config.value.use_checkboxes %}
{% if not config.required %}
<label class="checkbox{% if config.value.use_checkboxes == 'inline'%} inline{% endif %}"
style="display: none">
<input type="checkbox" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}"
value="__none__" disabled="disabled" />
--
</label>
{% endif %}
{% for v in config.value.options %}
<label class="checkbox{% if config.value.use_checkboxes == 'inline'%} inline{% endif %}"
style="text-transform: none">
<input type="checkbox" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}"
value="{{v}}"{% if v in config.value.selected %} checked="checked"{% endif %}
onclick="var ti = 'input[name=\''+$(this).attr('name')+'\']'; if ($(ti+':checked').length === 0) { $(ti).eq(0).prop('checked', true).prop('disabled', false); } else { $(ti).eq(0).prop('checked', false).prop('disabled', true); }"
/>
{{v}}
</label>
{% endfor %}
{% else %}
<select name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name }}-{{ config.curType() }}" data-configname="{{config.name}}" title="{{plugin['config_meta'][config.name]['desc']}}"{% if config.value.multiple %} multiple="multiple"{% endif %}"
onclick="if ($(this).val() === null) { $(this).val('__none__'); $('[value=\'__none__\']', this).prop('disabled', false); } else { $('[value=\'__none__\']', this).prop('selected', false).prop('disabled', true); }">
{% if not config.required %}
<option value="__none__" disabled="disabled">--- none selected ---</option>
{% endif %}
{% for v in config.value.options %}
<option value="{{v}}"{% if v in config.value.selected %} selected="selected"{% endif %}>{{v}}</option>
{% endfor %}
</select>
{% endif %}
{% else %}
{% if config.curType() == 'int' and 'enable' not in config.name -%}
{% set inputType = 'number" step="any'%}
{% elif config.curType() == 'bool' or 'enable' in config.name%}
{% if config.value %}
{# this is a little dodgy. we append the checked attr with manipulating the string that is set for the input type#}
{% set inputType = 'checkbox" checked="checked'%}
{% else %}
{% set inputType = 'checkbox'%}
{% endif %}
<input name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" type="hidden" value="off"/>
{% elif 'password' in config.name %}
{% set inputType = 'password'%}
{% else %}
{% set inputType = 'text'%}
{%- endif %}
<input data-belongsto="{{plugin.name|idSafe}}" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" data-configname="{{config.name}}" type="{{inputType}}" {% if config.value and config.value != "None" %} value="{{ config.value }}"{% endif %} {% if plugin['config_meta'][config.name]['placeholder'] %}placeholder="{{ plugin['config_meta'][config.name]['placeholder'] }}"{% endif %} onChange="{{onChange}}" title="{{plugin['config_meta'][config.name]['desc']}}"/>
{% if config.curType() == 'int' and 'enable' not in config.name -%}
{% set inputType = 'number" step="any'%}
{% elif config.curType() == 'bool' or 'enable' in config.name%}
{% if config.value %}

{# this is a little dodgy. we append the checked attr with manipulating the string that is set for the input type#}
{% set inputType = 'checkbox" checked="checked'%}
{% else %}
{% set inputType = 'checkbox'%}
{% endif %}
<input name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" type="hidden" value="off"/>
{% elif 'password' in config.name %}
{% set inputType = 'password'%}
{% else %}
{% set inputType = 'text'%}
{%- endif %}
<input data-belongsto="{{plugin.name|idSafe}}" name="{{ plugin.type }}-{{ plugin.instance }}-{{ config.name}}" data-configname="{{config.name}}" type="{{inputType}}" {% if config.value and config.value != "None" %} value="{{ config.value }}"{% endif %} {% if plugin['config_meta'][config.name]['placeholder'] %}placeholder="{{ plugin['config_meta'][config.name]['placeholder'] }}"{% endif %} onChange="{{onChange}}" title="{{plugin['config_meta'][config.name]['desc']}}"/>
{% endif %}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion xdm/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def rest(self, *args, **kwargs):
for name in p_function.args:
log('function %s needs %s' % (method, name))
if name in kwargs:
fn_args.append(convertV(kwargs[name]))
fn_args.append(convertV(kwargs[name], None)) #fixme: None correct?

try:
log("calling %s with %s" % (p_function, fn_args))
Expand Down
Loading