<script type="text/x-handlebars-template" data-name="main">
    <table class="table mapsvg-data-list-table" id="mapsvg-data-list-table">
        <thead>
        <tr>
            {{#each fields}}
                <th>{{name}}</th>
            {{/each}}
            <th style="width: 20px;"></th>
        </tr>
        </thead>
        <tbody>
        {{#each data}}
            {{>databaseListItemPartial fields=../fields params=this}}
        {{/each}}
        </tbody>
    </table>

    <div class="mapsvg-pagination-container">
    </div>

    <div class="mapsvg-view-padding" id="mapsvg-setup-database-msg" style="display: none;">
        <div class="well">
            <p class="help-block">You need to set up your Database fields first. Click on <span class="label label-default" style="font-size: 14px;"><i class="fa fa-columns"></i></span>  <i>Edit fields</i> icon in the toolbar.</p>
        </div>
    </div>
</script>

<script type="text/x-handlebars-template" data-name="item" data-partial="true">
    <tr id="mapsvg-data-{{params.id}}" data-id="{{params.id}}" class="mapsvg-data-row">
        {{#each fields}}

            {{#switch type}}
                {{#case "image" break=true}}
                    <td>{{getThumbs ../params name}}</td>
                {{/case}}
                {{#case "location" break=true}}
                    <td style="max-width: 170px;">{{getMarkerImage ../params name}}</td>
                {{/case}}
                {{#case "text" break=true}}
                    <td>{{lookup ../params name}}</td>
                {{/case}}
                {{#case "textarea" break=true}}
                    <td>{{lookup ../params name}}</td>
                {{/case}}
                {{#case "region" break=true}}
                    <td>{{getRegions ../params name}}</td>
                {{/case}}
                {{#case "checkbox" break=true}}
                    <td>{{lookup ../params name}}</td>
                {{/case}}
                {{#case "post" break=true}}
                    <td>
                        {{lookup ../params name}}
                    </td>
                {{/case}}
                {{#case "select" break=true}}
                    <td>
                        {{#ifjson ../params name}}
                            {{getSelectedOptions ../params name}}
                        {{/ifjson}}
                        {{#ifnotjson ../params name}}
                            {{getLabel optionsDict ../params name}}
                        {{/ifnotjson}}
                    </td>
                {{/case}}
                {{#case "radio" break=true}}
                    <td>
                        {{#ifjson ../params name}}
                            {{getSelectedOptions ../params name}}
                        {{/ifjson}}
                        {{#ifnotjson ../params name}}
                            {{getLabel optionsDict ../params name}}
                        {{/ifnotjson}}
                    </td>
                {{/case}}
                {{#default break=true}}<td>{{lookup ../params name}}</td>{{/default}}
            {{/switch}}

        {{/each}}
        <td>
            <button class="btn btn-sm btn-default mapsvg-data-copy toggle-tooltip" title="Copy">
                <i class="fa fa-clone"></i>
            </button>
            <button class="btn btn-sm btn-default mapsvg-data-delete toggle-tooltip" title="Delete">
                <i class="fa fa-trash"></i>
            </button>
        </td>
    </tr>
</script>