{% load inventree_extras %}
{% load i18n %}

{% if user_setting %}
    {% setting_object key user=request.user as setting %}
{% else %}
    {% setting_object key as setting %}
{% endif %}

<tr>
    <td>
        {% if icon %}
        <span class='fas {{ icon }}'></span>
        {% endif %}
    </td>
    <td><strong>{% trans setting.name %}</strong></td>
    <td>
        {% if setting.is_bool %}
        <div class='form-check form-switch'>
            <input class='form-check-input' fieldname='{{ setting.key.upper }}' id='setting-value-{{ setting.key.upper }}' type='checkbox' disabled='' {% if setting.as_bool %}checked=''{% endif %}>
        </div>
        {% else %}
        <div id='setting-{{ setting.pk }}'>
            <span id='setting-value-{{ setting.key.upper }}' fieldname='{{ setting.key.upper }}'>
                {% if setting.value %}
                <strong>{{ setting.value }}</strong>
                {% else %}
                <em style='color: #855;'>{% trans "No value set" %}</em>
                {% endif %}
            </span>
            {{ setting.units }}
        </div>
        {% endif %}
    <td>
        {% trans setting.description %}
    </td>
    <td>
        <div class='btn-group float-right'>
            <button class='btn btn-outline-secondary btn-small btn-edit-setting' pk='{{ setting.pk }}' setting='{{ setting.key.upper }}' title='{% trans "Edit setting" %}' {% if user_setting %}user='{{request.user.id}}'{% endif %}>
                <span class='fas fa-edit icon-green'></span>
            </button>
        </div>
    </td>
</tr>