kennethkalmer/powerdns-on-rails

View on GitHub
app/views/domains/_record.html.haml

Summary

Maintainability
Test Coverage
- css_class = cycle('even', 'odd')

%tr[ record, :marker ]
%tr[ record, :show ]{:class => css_class}
  %td{ :width => 250 }= record.shortname
  %td{ :width => 50 }= record.ttl
  %td{ :width => 30 }= record.type
  %td{ :width => 30 }= record.prio
  %td{ :width => 250 }= record.content
  %td{ :width => 39 }
    - unless record.domain.slave?
      - if current_user || current_token.can_change?( record )
        = link_to_function info_icon('database_edit.png', "record-template-edit"), "editRecord(#{record.id}, '#{record.type.downcase}')"
      - if current_user || current_token.can_remove?( record )
        = link_to info_icon('database_delete.png', "record-template-delete"), domain_record_path( record.domain, record ), :method => :delete, :confirm => t(:confirm_domain_delte_record)

- unless record.domain.slave?
  - if current_user || current_token.can_change?( record )
    %tr[ record, :edit ]{ :style => "display: none;", :class => css_class}
      %td{ :colspan => 7 }
        = form_for( record, :as => :record, :url => domain_record_path(record.domain, record ), :remote => true ) do |f|
          %div[ record, :error ]
            %table.gridwide
              %tr
                %td{ :width => 250 }= f.text_field :shortname, :size => 15
                %td{ :width => 50 }= f.text_field :ttl, :size => 3
                %td{ :width => 30 }= record.type
                %td{ :width => 30 }
                  - if record.supports_prio?
                    = f.text_field :prio, :size => 2
                  - else
                     
                %td{ :width => 250 }= f.text_field :content, :size => 15
                %td{ :width => 39 }
                  = image_submit_tag "table_save.png", { :class => 'nb' }
                  = link_to_function image_tag("cancel.png"), "hideRecord(#{record.id}, '#{record.type.downcase}')"