{% load i18n material_frontend viewflow viewflow_frontend %}
{% flows_start_actions view.flows request.user as start_actions %}

{% if start_actions %}
<div class="fixed-action-btn">
    <a class="btn-floating btn-large waves-effect waves-light red z-depth-2 modal-trigger" href="#start_actions">
        <i class="large material-icons">add</i>
    </a>
</div>


<dmc-modal><div id="start_actions" class="modal bottom-sheet">
    <div class="modal-content">
        <h4>{% trans 'New process' %}</h4>

        <table>
            <tbody>
                {% for flow_class, actions in start_actions.items %}
                {% if actions %}
                <tr>
                    <td>
                        <div class="left">
                            <h5>{{ flow_class.process_title }}</h5>
                            {{ flow_class.process_description|default:"" }}
                        </div>
                        <div class="right">
                            {% for action in actions %}
                            <a class="btn waves-effect waves-light" href="{% flowurl flow_class action.name ns=request.resolver_match.namespace ns_map=view.ns_map %}?{{ request|query_back:'here' }}">
                                <i class="left material-icons">add</i>{{ action.task_title|default:action.name|title }}
                            </a><br/>
                            {% endfor %}
                        </div>
                    </td>
                </tr>
                {% endif %}
                {% endfor %}
            </tbody>
        </table>
    </div>
</div></dmc-modal>
{% endif %}
