[% site_config.title = c.loc('Manage Sound Set [_1]', set_result.name) -%]

<a class="btn btn-large btn-primary" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
[% back_created = 1 -%]

[% IF messages -%]
<div class="row">
    [% FOREACH m IN messages -%]
        <div class="alert alert-[% m.type %]">[% m.text %]</div>
    [% END -%]
</div>
[% END -%]

<div class="ngcp-separator"></div>

<div class="accordion" id="sound_groups">
[% FOREACH group IN sound_groups.pairs %]
<div class="accordion-group">
    <div class="accordion-heading">
        <a class="accordion-toggle" data-toggle="collapse" data-parent="#sound_groups" href="#collapse[% group.key %]">[% group.key %]</a>
    </div>
    <div class="accordion-body collapse" id="collapse[% group.key %]">
    <div class="accordion-inner">

<table class="table table-bordered table-striped table-highlight table-hover" id="sounds_table[% group.key %]">
    <thead>
        <tr>
            [% # one for description -%]
            <th>[% c.loc('Name') %]</th>
            <th>[% c.loc('Filename') %]</th>
            <th>[% c.loc('Loop') %]</th>
            [% # one for actions -%]
            <th></th>
        </tr>
    </thead>
    <tbody>
        [% FOREACH r IN group.value %]
            <tr class="sw_action_row">
                <td>
                  [% r.get_column("handlename") %]
                </td>
                <td>
                    [% r.get_column("filename") %]
                </td>
                <td>
                    <input type="checkbox" disabled="disabled" [% r.get_column('loopplay') ? 'checked="checked"' : '' %]>
                </td>
                <td>
                    <div class="sw_actions pull-right">
                        [% IF r.get_column("filename").size -%]
                            [% UNLESS c.user.read_only -%]
                            <a class="btn btn-small btn-primary" href="[% handles_base_uri _ "/" _ r.get_column("handleid") _ "/edit" %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
                            <a class="btn btn-small btn-secondary" data-confirm="Delete" href="[% handles_base_uri _ "/" _ r.get_column("handleid") _ "/delete" %]"><i class="icon-edit"></i> [% c.loc('Delete') %]</a>
                            [% END -%]
                            <a class="btn btn-small btn-tertiary" href="[% c.uri_for_action('/sound/handles_download', [c.req.captures.0, r.get_column('handleid')]) %]"><i class="icon-play"></i> [% c.loc('Play') %]</a>
                        [% ELSIF !c.user.read_only -%]
                            <a class="btn btn-small btn-primary" href="[% handles_base_uri _ "/" _ r.get_column("handleid") _ "/edit" %]"><i class="icon-edit"></i> [% c.loc('Upload') %]</a>
                        [% END -%]
                    </div>
                </td>
            </tr>
        [% END %]
    </tbody>
</table>
    </div>
    </div>
</div>
[% END %]
</div>

[% IF edit_flag -%]

[%
    PROCESS "helpers/modal.tt";
    modal_header(m.create_flag=0,
                 m.name = file_result.handle.name );
    translate_form(form).render;
    modal_footer();
-%]
<script>
    $(function () {
        $('#mod_edit').modal({keyboard: false, backdrop: 'static'});
        $('#mod_close').click(function(event) {
            window.location.href="[% handles_base_uri %]";
        });

    });
</script>
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

