{% extends 'ClarolineCoreBundle:Workspace:layout.html.twig' %}

{% block title %}{{ parent() ~ ' - configure' | trans({}, "platform") | striptags | raw }}{% endblock %}

{% block breadcrumb %}
    {{
        macros.workspaceBreadcrumbs(
            model.getWorkspace(),
            [
                {
                    'name': 'parameters'|trans({}, 'platform'),
                    'href': path('claro_workspace_open_tool', {'workspaceId': model.getWorkspace().getId(), 'toolName': 'parameters'})
                },
                {
                    'name': 'models'|trans({}, 'platform'),
                    'href': path('claro_workspace_model_index', {'workspace': model.getWorkspace().getId()})
                },
                {
                    'name': model.getName(),
                    'href': ''
                }
            ]
        )
    }}
{% endblock %}

{% block section_content %}
    <div class="panel-heading">
        <h3 class="panel-title">{{ model.getName() }}</h3>
    </div>
    <div class="panel-body">
        <ul class="nav nav-tabs" role="tablist">
            <li class="active">
                <a href="#share" role="tab" data-toggle="tab">{{ 'share'|trans({}, 'platform') }}</a>
            </li>
            <li><a href="#links" role="tab" data-toggle="tab">{{ 'links'|trans({}, 'platform') }}</a></li>
            <li><a href="#copies" role="tab" data-toggle="tab">{{ 'copies'|trans({}, 'platform') }}</a></li>
            <li><a href="#tabs" role="tab" data-toggle="tab">{{ 'tabs'|trans({}, 'platform') }}</a></li>
        </ul>

        <div class="tab-content">
            <div class="tab-pane active" id="share">
                <div id="shared-list" class="row">
                    <div class="col-md-7">
                        <h4> {{ 'users'|trans({}, 'platform') }}</h4>
                        <button id="add-user-btn" class="btn btn-primary margin-bottom-md">{{ 'add_user'|trans({}, 'platform') }}</button>
                        <table class="table table-striped table-bordered table-condensed">
                            <thead>
                            <th>{{ 'username'|trans({}, 'platform') }}</th>
                            <th>{{ 'delete'|trans({}, 'platform') }}</th>
                            </thead>
                            <tbody id="table-user-body">
                            {% for user in model.getUsers() %}
                                {% include "ClarolineCoreBundle:Tool\\workspace\\parameters\\model:userRow.html.twig" with {'user': user, 'model': model} %}
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-5">
                        <h4> {{ 'groups'|trans({}, 'platform') }}</h4>
                        <button id="add-group-btn" class="btn btn-primary margin-bottom-md">{{ 'add_group'|trans({}, 'platform') }}</button>
                        <table class="table table-striped table-bordered table-condensed">
                            <thead>
                            <th>{{ 'name'|trans({}, 'platform') }}</th>
                            <th>{{ 'delete'|trans({}, 'platform') }}</th>
                            </thead>
                            <tbody id="table-group-body">
                            {% for group in model.getGroups() %}
                                {% include "ClarolineCoreBundle:Tool\\workspace\\parameters\\model:groupRow.html.twig" with {'group': group, 'model': model} %}
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="tab-pane margin-top-md" id="links">
                <button id="add-resnode-link" class="btn btn-primary margin-bottom-md">{{ 'link'|trans({}, 'platform') }}</button>
                <ul class="list-group" id="list-resnode-link">
                    {% for link in links %}
                        {% include "ClarolineCoreBundle:Tool\\workspace\\parameters\\model:resourceElement.html.twig"
                        with {'name': link.getResourceNode().getName(), 'resourceModelId': link.getId()} %}
                    {% endfor %}
                </ul>
            </div>
            <div class="tab-pane margin-top-md" id="copies">
                <button id="add-resnode-copy" class="btn btn-primary margin-bottom-md">{{ 'copy'|trans({}, 'platform') }}</button>
                <ul class="list-group" id="list-resnode-copy">
                    {% for copy in copied %}
                        {% include "ClarolineCoreBundle:Tool\\workspace\\parameters\\model:resourceElement.html.twig"
                        with {'name': copy.getResourceNode().getName(), 'resourceModelId': copy.getId()} %}
                    {% endfor %}
                </ul>
            </div>
            <div class="tab-pane margin-top-md" id="tabs">
                <button id="add-tab" href="{{ path('ws_model_homeTabs_list', {'model': model.getId()}) }}"
                        class="btn btn-primary margin-bottom-md">{{ 'tab'|trans({}, 'platform') }}</button>
                <div id="tab-list">
                    {% for tab in model.getHomeTabs() %}
                        {% include "ClarolineCoreBundle:Tool\\workspace\\parameters\\model:tabElement.html.twig"
                        with {'name': tab.getName(), 'homeTabId': tab.getId(), 'modelId': model.getId()} %}
                    {% endfor %}
                </div>
            </div>
        </div>

        <div id="data" data-root-id="{{ rootId }}" data-model-id="{{ model.getId() }}"></div>
        <div id="div-data" data-model-id="{{ model.getId() }}"></div>
    </div>
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script src='{{ asset('bundles/clarolinecore/js/tool/workspace/model/configure.js') }}' type="text/javascript"></script>
{% endblock %}