Version refactored

This commit is contained in:
Priit Tark 2015-01-30 23:25:46 +02:00
parent c1949e7069
commit 3e2be53853
48 changed files with 379 additions and 147 deletions

View file

@ -1,63 +1,125 @@
%td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
- if children[:domain]
%p{:style => "font-size:x-small;"}
= children[:domain][:period]
= children[:domain][:period_unit] if children[:domain][:period]
- if children[:domain][:valid_to] && children[:domain][:valid_from]
= ","
= l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
- if children[:domain].try(:[], :registrar_id)
= ","
= Registrar.find(children[:domain][:registrar_id]).try(:name)
- if children[:domain][:status]
= ',' + children[:domain][:status]
%td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
- if children[:owner_contact]
%p{:style => "font-size:x-small;"}
= children[:owner_contact][:name]
= ","
= children[:owner_contact][:phone]
= ","
= children[:owner_contact][:email]
= ","
= children[:owner_contact][:code]
%td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
- if children[:admin_contacts]
- children[:admin_contacts].each do |ac|
%p{:style => "font-size:x-small;"}
= ac[:name]
= ","
= ac[:phone]
= ","
= ac[:email]
= ","
= ac[:code]
%td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
- if children[:tech_contacts]
- children[:tech_contacts].each do |tc|
%p{:style => "font-size:x-small;"}
= tc[:name]
= ","
= tc[:phone]
= ","
= tc[:email]
= ","
= tc[:code]
%td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
- if children[:nameservers]
- children[:nameservers].each do |ns|
%p{:style => "font-size:x-small;"}
= ns[:hostname]
= ","
= ns[:ipv4] || ns[:ipv6]
- children = HashWithIndifferentAccess.new(version.children)
- nameservers = children[:nameservers] || []
- tech_contacts = children[:tech_contacts] || []
- admin_contacts = children[:admin_contacts] || []
- owner_contact = children[:owner_contact] || []
%td
%p{ :style => 'font-size:x-small;' }
= l(version.created_at, format: :short)
= whodunnit_with_protocol(version.whodunnit)
%p.nowrap
= l(domain.updated_at, format: :short)
= version.event
%p.text-right
= version.terminator
%td
%p
= "#{domain.period}#{domain.period_unit}"
= "#{l(domain.valid_from, format: :date)} - #{l(domain.valid_to, format: :date)}"
%p
= domain.status
%td
- owner_contact.each do |oc|
%p
= oc[:name]
= oc[:phone]
= oc[:email]
%p
= oc[:code]
%td
- admin_contacts.each do |ac|
%p
= ac[:name]
= ac[:phone]
= ac[:email]
%p
= ac[:code]
%td
- tech_contacts.each do |tc|
%p
= tc[:name]
= tc[:phone]
= tc[:email]
%p
= tc[:code]
%td
- nameservers.each do |ns|
%p
= ns[:hostname]
%br
= ns[:ipv4]
= ns[:ipv6]
%td
%p
= domain.registrar.name
-# %td
-# = version.children.inspect
-# %td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:domain]
-# %p{:style => "font-size:x-small;"}
-# = children[:domain][:period]
-# = children[:domain][:period_unit] if children[:domain][:period]
-# - if children[:domain][:valid_to] && children[:domain][:valid_from]
-# = ","
-# = l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
-# - if children[:domain].try(:[], :registrar_id)
-# = ","
-# = Registrar.find(children[:domain][:registrar_id]).try(:name)
-# - if children[:domain][:status]
-# = ',' + children[:domain][:status]
-# %td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:owner_contact]
-# %p{:style => "font-size:x-small;"}
-# = children[:owner_contact][:name]
-# = ","
-# = children[:owner_contact][:phone]
-# = ","
-# = children[:owner_contact][:email]
-# = ","
-# = children[:owner_contact][:code]
-# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:admin_contacts]
-# - children[:admin_contacts].each do |ac|
-# %p{:style => "font-size:x-small;"}
-# = ac[:name]
-# = ","
-# = ac[:phone]
-# = ","
-# = ac[:email]
-# = ","
-# = ac[:code]
-# %td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:tech_contacts]
-# - children[:tech_contacts].each do |tc|
-# %p{:style => "font-size:x-small;"}
-# = tc[:name]
-# = ","
-# = tc[:phone]
-# = ","
-# = tc[:email]
-# = ","
-# = tc[:code]
-# %td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:nameservers]
-# - children[:nameservers].each do |ns|
-# %p{:style => "font-size:x-small;"}
-# = ns[:hostname]
-# = ","
-# = ns[:ipv4] || ns[:ipv6]
-# %td
-# %p{ :style => 'font-size:x-small;' }
-# = l(version.created_at, format: :short)
-# = whodunnit_with_protocol(version.whodunnit)
-# = version.event

View file

@ -1,28 +1,31 @@
.row
.col-sm-12
%h2.text-center-xs= t('domains')
.col-sm-6
%h2.text-center-xs
= "#{t(:domain_history)}: #{@domain.name}"
.col-sm-6
%h2.text-right.text-center-xs
%hr
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-1'}
= t('name')
%th{class: 'col-xs-1'}
= sort_link(@q, 'whodunnit')
%th{class: 'col-xs-1'}
= sort_link(@q, 'created_at')
%th{class: 'col-xs-1'}= t(:timestap)
%th{class: 'col-xs-2'}= t(:period)
%th{class: 'col-xs-2'}= t(:owner)
%th{class: 'col-xs-2'}= t(:admin)
%th{class: 'col-xs-2'}= t(:tech)
%th{class: 'col-xs-2'}= t(:nameservers)
%th{class: 'col-xs-2'}= t(:registrar)
%tbody
- @domains.each do |domain|
- obj = domain.reify
%tr
%td= link_to(obj.name, admin_domain_version_path(obj))
%td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
%td= l(obj.created_at, format: :short)
%tr.small
= render 'admin/domain_versions/version',
domain: @domain, version: @domain.versions.last
.row
.col-md-12
= paginate @domains
- @domain.versions.not_creates.reverse.each do |version|
%tr.small
= render 'admin/domain_versions/version',
domain: version.reify, version: version.previous

View file

@ -0,0 +1,28 @@
-# .row
-# .col-sm-12
-# %h2.text-center-xs= t('domains')
-# %hr
-# .row
-# .col-md-12
-# .table-responsive
-# %table.table.table-hover.table-bordered.table-condensed
-# %thead
-# %tr
-# %th{class: 'col-xs-1'}
-# = t('name')
-# %th{class: 'col-xs-1'}
-# = sort_link(@q, 'whodunnit')
-# %th{class: 'col-xs-1'}
-# = sort_link(@q, 'created_at')
-# %tbody
-# - @domains.each do |domain|
-# - obj = domain.reify
-# %tr
-# %td= link_to(obj.name, admin_domain_version_path(obj))
-# %td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
-# %td= l(obj.created_at, format: :short)
-# .row
-# .col-md-12
-# = paginate @domains

View file

@ -1,29 +0,0 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t(:domain_history)} for " + @name.to_s
.col-sm-6
%h2.text-right.text-center-xs
%hr
.row
.col-md-12
.table-responsive
%table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-2'}= t(:'domain_info')
%th{class: 'col-xs-2'}= t(:'owner_contact')
%th{class: 'col-xs-2'}= t(:'admin_contacts')
%th{class: 'col-xs-2'}= t(:'tech_contacts')
%th{class: 'col-xs-2'}= t(:'nameservers')
%th{class: 'col-xs-1'}= t(:'changes_info')
%tbody
- @versions.each do |version|
%tr
- children = version.load_snapshot
- next unless children.is_a?(Hash)
- children = HashWithIndifferentAccess.new(children)
- changes = version.changed_elements
= render 'admin/domain_versions/version', children: children, version: version, changes: changes

View file

@ -4,8 +4,8 @@
= "#{t('domain_details')}"
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('edit_statuses'), edit_admin_domain_path(@domain), class: 'btn btn-primary')
= link_to(t(:'history'), admin_domain_version_path(@domain.id), method: :get, class: 'btn btn-primary')
= link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
%hr
.row