Files @ 2f008f0153c7
Branch filter:

Location: kallithea/kallithea/templates/index_base.html

Mads Kiilerich
style: put all datatable widgets on one line above the table

This makes tables look less messy - especially on the repogroups page where
there are 2 datatables.

We put all the info above the template so it is visible and stays in the same
place, no matter how many entries are shown or if filtering change the number.

TODO: We should probably get a wrapper around datatable instead of repeating
this so many times ...
<%page args="parent,group_name=''" />
    <div class="panel panel-primary">
        <!-- box / title -->
        <div class="panel-heading clearfix">
            <div class="breadcrumbs">
                %if c.group is not None:
                    %for group in c.group.parents:
                        ${h.link_to(group.name, url('repos_group_home', group_name=group.group_name))}
                        &raquo;
                    %endfor
                    ${c.group.group_name}
                %endif
            </div>

            %if c.authuser.username != 'default':
              <ul class="links">
                <li>
                <%
                    gr_name = c.group.group_name if c.group else None
                    # create repositories with write permission on group is set to true
                    create_on_write = h.HasPermissionAny('hg.create.write_on_repogroup.true')()
                    group_admin = h.HasRepoGroupPermissionAny('group.admin')(gr_name, 'can write into group index page')
                    group_write = h.HasRepoGroupPermissionAny('group.write')(gr_name, 'can write into group index page')
                %>
                %if h.HasPermissionAny('hg.admin','hg.create.repository')() or (group_admin or (group_write and create_on_write)):
                  %if c.group:
                        <a href="${h.url('new_repo',parent_group=c.group.group_id)}" class="btn btn-default btn-xs"><i class="icon-plus"></i> ${_('Add Repository')}</a>
                        %if h.HasPermissionAny('hg.admin')() or h.HasRepoGroupPermissionAny('group.admin')(c.group.group_name):
                            <a href="${h.url('new_repos_group', parent_group=c.group.group_id)}" class="btn btn-default btn-xs"><i class="icon-plus"></i> ${_('Add Repository Group')}</a>
                        %endif
                  %else:
                    <a href="${h.url('new_repo')}" class="btn btn-default btn-xs"><i class="icon-plus"></i> ${_('Add Repository')}</a>
                    %if h.HasPermissionAny('hg.admin')():
                        <a href="${h.url('new_repos_group')}" class="btn btn-default btn-xs"><i class="icon-plus"></i> ${_('Add Repository Group')}</a>
                    %endif
                  %endif
                %endif
                %if c.group and h.HasRepoGroupPermissionAny('group.admin')(c.group.group_name):
                    <a href="${h.url('edit_repo_group',group_name=c.group.group_name)}" title="${_('You have admin right to this group, and can edit it')}" class="btn btn-default btn-xs"><i class="icon-pencil"></i> ${_('Edit Repository Group')}</a>
                %endif
                </li>
              </ul>
            %endif
        </div>
        <!-- end box / title -->
        %if c.groups:
        <div class="table">
            <div id='groups_list_wrap'>
              <table id="groups_list">
                  <thead>
                      <tr>
                          <th class="left">${_('Repository Group Name')}</th>
                          <th class="left">${_('Description')}</th>
                          ##<th class="left">${_('Number of Repositories')}</th>
                      </tr>
                  </thead>

                  ## REPO GROUPS
                  % for gr in c.groups:
                    <tr>
                        <td>
                            <div class="dt_repo">
                              <a href="${url('repos_group_home',group_name=gr.group_name)}">
                                <i class="icon-folder"></i>
                                <span class="dt_repo_name">${gr.name}</span>
                              </a>
                            </div>
                        </td>
                        <td>${h.urlify_text(gr.group_description, stylize=c.visual.stylify_metatags)}</td>
                        ## this is commented out since for multi nested repos can be HEAVY!
                        ## in number of executed queries during traversing uncomment at will
                        ##<td><b>${gr.repositories_recursive_count}</b></td>
                    </tr>
                  % endfor
              </table>
            </div>
        </div>
        %endif
        <div class="table">
            <table id="repos_list_wrap"></table>
        </div>
    </div>

      <script>
        $('#groups_list').DataTable({
            dom: '<"dataTables_left"f><"dataTables_right"ilp>t',
            pageLength: 100
        });

        var data = ${c.data|n},
            $dataTable = $("#repos_list_wrap").DataTable({
                data: data.records,
                columns: [
                    {data: "raw_name", visible: false, searchable: false},
                    {title: "${_('Repository Name')}", data: "name", orderData: 1, render: {
                        filter: function(data) {
                            return $(data).find(".dt_repo_name").text();
                        }
                    }},
                    {data: "desc", title: "${_('Description')}", searchable: false},
                    {data: "last_change_iso", visible: false, searchable: false},
                    {data: "last_change", title: "${_('Last Change')}", orderData: 4, searchable: false},
                    {data: "last_rev_raw", visible: false, searchable: false},
                    {data: "last_changeset", title: "${_('Tip')}", orderData: 6, searchable: false},
                    {data: "owner", title: "${_('Owner')}", searchable: false},
                    {data: "atom", sortable: false}
                ],
                order: [[1, "asc"]],
                dom: '<"dataTables_left"f><"dataTables_right"ilp>t',
                pageLength: 100
            });
      </script>