internetee/registry

View on GitHub
app/views/admin/domains/versions.haml

Summary

Maintainability
Test Coverage
- content_for :actions do
  = link_to(t(:back_to_domain), [:admin, @domain], class: 'btn btn-default')
= render 'shared/title', name: "#{t(:history)}: #{@domain.name}"

.row
  .col-md-12
    .table-responsive{data: {doublescroll: true}}
      %table.table.table-bordered.table-condensed
        %thead
          %tr
            %th{class: 'col-xs-1'}= t('.time')
            %th{class: 'col-xs-2'}= t(:statuses)
            %th{class: 'col-xs-1'}= t(:period)
            %th{class: 'col-xs-2'}= t('.registrant')
            %th{class: 'col-xs-2'}= t('.admin_contact')
            %th{class: 'col-xs-2'}= t('.tech_contact')
            %th{class: 'col-xs-2'}= t(:nameservers)
            %th{class: 'col-xs-2'}= t(:dnskeys)
            %th{class: 'col-xs-2'}= t(:registrar_name)

        %tbody
          -#- if @pending_domain.present?
            %tr.small
              = render 'admin/domains/partials/version',
                domain: @pending_domain, pending_user: @pending_user, statuses_link: true

          -# current version
          - if @versions.present?
            - if params[:page].blank? || (params[:page].present? && params[:page].to_i < 2)
              %tr.small
                = render 'admin/domains/partials/version',
                  domain: @domain, version: @last_version

          -# all other older versions
          - @old_versions.each do |version|
            %tr.small
              = render 'admin/domains/partials/version',
                domain: version.reify, version: version.previous

.row 
  .col-md-6 
    = paginate @old_versions
  .col-md-6.text-right 
    .pagination 
      = t(:result_count, count: @old_versions.total_count + 1)

:javascript
  window.addEventListener('load', function() {
    $(document).on('click', '.js-pending, .js-event', function(e) {
      return e.preventDefault();
    });

    $(document).on('mousedown', '.js-pending, .js-event', function(e) {
      var target;
      target = $(e.target);
      return target.parents('tr').nextUntil('tr.small', 'tr.' + this.className).toggle();
    });
  });