2022-09-13 13:14:49 +00:00
|
|
|
{% extends 'manage/general/master.twig' %}
|
|
|
|
{% from 'macros.twig' import container_title %}
|
|
|
|
{% from '_layout/input.twig' import input_csrf, input_text, input_checkbox, input_file, input_select, input_colour %}
|
|
|
|
|
2023-07-18 21:48:44 +00:00
|
|
|
{% set title = config_new ? 'Adding a new setting' : ((config_new ? 'Adding ' : 'Editing ') ~ ' setting ' ~ config_name) %}
|
2022-09-13 13:14:49 +00:00
|
|
|
|
|
|
|
{% block manage_content %}
|
|
|
|
<div class="container manage-settings">
|
|
|
|
{{ container_title('<i class="fas fa-cogs fa-fw"></i> ' ~ title) }}
|
|
|
|
|
2023-07-18 21:48:44 +00:00
|
|
|
<form method="post" action="{{ url('manage-general-setting', {'name': config_name|default()}) }}" class="manage-setting" id="-msz-manage-setting-form">
|
2022-09-13 13:14:49 +00:00
|
|
|
{{ input_csrf() }}
|
|
|
|
|
2023-07-18 21:48:44 +00:00
|
|
|
{% if config_new %}
|
2022-09-13 13:14:49 +00:00
|
|
|
<label class="manage-setting-field">
|
|
|
|
<div class="manage-setting-field-name">Name</div>
|
2023-07-18 21:48:44 +00:00
|
|
|
{{ input_text('conf_name', 'manage__emote__field__value', config_name|default(), 'text', null, false, {'id': '-msz-manage-setting-name'}) }}
|
2022-09-13 13:14:49 +00:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label class="manage-setting-field">
|
|
|
|
<div class="manage-setting-field-name">Type</div>
|
|
|
|
{{ input_select(
|
|
|
|
'conf_type',
|
2023-07-18 21:48:44 +00:00
|
|
|
['', 'string', 'int', 'bool', 'float', 'array'],
|
|
|
|
config_type, null, null, true, 'manage__emote__field__value',
|
2022-09-13 13:14:49 +00:00
|
|
|
{'onchange': ('location.assign("' ~ url('manage-general-setting', {'name': '-name-', 'type': '-type-'}) ~ '".replace("-name-", document.getElementById("-msz-manage-setting-name").value).replace("-type-", this.value))')}
|
|
|
|
) }}
|
|
|
|
</label>
|
|
|
|
{% endif %}
|
|
|
|
|
2023-07-18 21:48:44 +00:00
|
|
|
{% if config_type is not empty %}
|
2022-09-13 13:14:49 +00:00
|
|
|
<label class="manage-setting-field">
|
|
|
|
<div class="manage-setting-field-name">Value</div>
|
|
|
|
|
2023-07-18 21:48:44 +00:00
|
|
|
{% if config_type == 'array' %}
|
2022-09-13 13:14:49 +00:00
|
|
|
<div class="manage-setting-array">
|
|
|
|
<div class="manage-setting-array-warning">
|
|
|
|
<noscript><div class="warning"><div class="warning__content">Touching this without Javascript will destroy everything.</div></div></noscript>
|
|
|
|
</div>
|
|
|
|
<div class="manage-setting-array-select">
|
|
|
|
<select class="input__select" multiple id="-msz-manage-setting-array" name="conf_value[]">
|
2023-07-18 21:48:44 +00:00
|
|
|
{% for entry in config_value %}
|
2022-09-13 13:14:49 +00:00
|
|
|
<option>{{ entry }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="manage-setting-array-remove">
|
|
|
|
<button type="button" id="-msz-manage-setting-array-delete" class="input__button input__button--destroy">Remove</button>
|
|
|
|
</div>
|
|
|
|
<div class="manage-setting-array-add">
|
2023-07-17 14:37:39 +00:00
|
|
|
<input type="text" id="-msz-manage-setting-array-input" class="input__text">
|
2022-09-13 13:14:49 +00:00
|
|
|
<button type="button" id="-msz-manage-setting-array-enter" class="input__button input__button--save">Add</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var mszMSF = document.getElementById('-msz-manage-setting-form'),
|
|
|
|
mszMSA = document.getElementById('-msz-manage-setting-array'),
|
|
|
|
mszMSAD = document.getElementById('-msz-manage-setting-array-delete'),
|
|
|
|
mszMSAI = document.getElementById('-msz-manage-setting-array-input'),
|
|
|
|
mszMSAE = document.getElementById('-msz-manage-setting-array-enter');
|
|
|
|
|
|
|
|
mszMSF.addEventListener('submit', function() {
|
|
|
|
for(var i = 0; i < mszMSA.options.length; ++i)
|
|
|
|
mszMSA.options[i].selected = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
mszMSAD.addEventListener('click', function() {
|
|
|
|
var opts = Array.from(mszMSA.selectedOptions);
|
|
|
|
while(opts.length > 0)
|
|
|
|
mszMSA.removeChild(opts.pop());
|
|
|
|
});
|
|
|
|
|
|
|
|
mszMSAE.addEventListener('click', function() {
|
|
|
|
var text = mszMSAI.value,
|
|
|
|
opt = document.createElement('option');
|
|
|
|
opt.textContent = text;
|
|
|
|
mszMSA.appendChild(opt);
|
|
|
|
});
|
|
|
|
|
|
|
|
mszMSAI.addEventListener('keydown', function(ev) {
|
|
|
|
if(ev.key === 'Enter') {
|
|
|
|
ev.preventDefault();
|
|
|
|
mszMSAE.click();
|
|
|
|
this.value = '';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2023-07-18 21:48:44 +00:00
|
|
|
{% elseif config_type == 'string' %}
|
|
|
|
{{ input_text('conf_value', 'manage-setting-field-value', config_value, 'text') }}
|
|
|
|
{% elseif config_type == 'int' %}
|
|
|
|
{{ input_text('conf_value', 'manage-setting-field-value', config_value, 'number') }}
|
|
|
|
{% elseif config_type == 'float' %}
|
|
|
|
{{ input_text('conf_value', 'manage-setting-field-value', config_value, 'number', '', false, {'step':'0.01'}) }}
|
|
|
|
{% elseif config_type == 'bool' %}
|
|
|
|
{{ input_checkbox('conf_value', 'Enabled', config_value) }}
|
2022-09-13 13:14:49 +00:00
|
|
|
{% endif %}
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<div class="manage-setting-actions">
|
|
|
|
<button class="input__button">Save</button>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|