diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb index cbc3205a3..1a469ddeb 100644 --- a/app/controllers/admin/domain_versions_controller.rb +++ b/app/controllers/admin/domain_versions_controller.rb @@ -43,10 +43,19 @@ class Admin::DomainVersionsController < AdminController def show per_page = 7 - @version = DomainVersion.find(params[:id]) - @q = DomainVersion.where(item_id: @version.item_id).order(created_at: :desc).search - @versions = @q.result.page(params[:page]) - @versions = @versions.per(per_page) + @version = DomainVersion.find(params[:id]) + @versions = DomainVersion.where(item_id: @version.item_id).order(created_at: :desc) + + # what we do is calc amount of results until needed version + # then we cacl which page it is + if params[:page].blank? + counter = @versions.where("created_at > ?", @version.created_at).count + page = counter / per_page + page += 1 if (counter % per_page) != 0 + params[:page] = page + end + + @versions = @versions.page(params[:page]).per(per_page) end def search diff --git a/app/views/admin/domain_versions/show.haml b/app/views/admin/domain_versions/show.haml index 2799591f6..5157c9371 100644 --- a/app/views/admin/domain_versions/show.haml +++ b/app/views/admin/domain_versions/show.haml @@ -10,8 +10,6 @@ - registrant = Contact.all_versions_for(children[:registrant], @version.created_at) - event = @version.event - creator = plain_username(@version.terminator) - - domain = Domain.new(@version.object.to_h) - - @version.object_changes.to_h.each{|k,v| domain[k]=v.last} = render 'shared/title', name: domain.name @@ -99,11 +97,8 @@ %br %dt= t(:registrar) - %dd{class: changing_css_class(@version,"registrar_id")} - = link_to admin_registrar_path(domain.registrar), target: "registrar_#{domain.registrar.id}" do - = domain.registrar.name - - %span{:style => "padding-right:10px; padding-top:40px; float: right; bottom: 10px;"} + %dd= domain.registrar.name + %div{:style => "margin: 20px 20px; clear:both;"} - if @version.previous = link_to(t(:previous), admin_domain_version_path(@version.previous.id), @@ -123,15 +118,15 @@ .panel.panel-default{:style => "min-height:450px;"} %ul.nav.nav-pills.nav-stacked - @versions.each do |vs| - - if vs.id == @version.id and vs.reify + - if vs.id == @version.id %li.active - = link_to admin_domain_version_path(vs.id) do + = link_to admin_domain_version_path(vs) do = l(vs.created_at, format: :short) = vs.event - else %li - = link_to admin_domain_version_path(vs.id) do + = link_to admin_domain_version_path(vs) do = l(vs.created_at, format: :short) = vs.event %span{:style => "padding-left:10px; position: absolute; bottom: 10px;"} - = paginate @versions + = paginate @versions, theme: :admin diff --git a/app/views/kaminari/admin/_first_page.html.haml b/app/views/kaminari/admin/_first_page.html.haml new file mode 100644 index 000000000..c5bbf13e1 --- /dev/null +++ b/app/views/kaminari/admin/_first_page.html.haml @@ -0,0 +1,11 @@ +-# Link to the "First" page +-# available local variables +-# url: url to the first page +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span.first + - param_name = current_page.instance_variable_get("@options")[:param_name] || Kaminari.config.param_name + - urlik = url_for( params.merge(param_name => 1, :only_path => true)) + = link_to_unless current_page.first?, t('views.pagination.first').html_safe, urlik, :remote => remote diff --git a/app/views/kaminari/admin/_gap.html.haml b/app/views/kaminari/admin/_gap.html.haml new file mode 100644 index 000000000..dd5789cc1 --- /dev/null +++ b/app/views/kaminari/admin/_gap.html.haml @@ -0,0 +1,8 @@ +-# Non-link tag that stands for skipped pages... +-# available local variables +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span.page.gap + = t('views.pagination.truncate').html_safe diff --git a/app/views/kaminari/admin/_last_page.html.haml b/app/views/kaminari/admin/_last_page.html.haml new file mode 100644 index 000000000..cdddb9e7c --- /dev/null +++ b/app/views/kaminari/admin/_last_page.html.haml @@ -0,0 +1,9 @@ +-# Link to the "Last" page +-# available local variables +-# url: url to the last page +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span.last + = link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote diff --git a/app/views/kaminari/admin/_next_page.html.haml b/app/views/kaminari/admin/_next_page.html.haml new file mode 100644 index 000000000..2865dcd0c --- /dev/null +++ b/app/views/kaminari/admin/_next_page.html.haml @@ -0,0 +1,9 @@ +-# Link to the "Next" page +-# available local variables +-# url: url to the next page +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span.next + = link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote diff --git a/app/views/kaminari/admin/_page.html.haml b/app/views/kaminari/admin/_page.html.haml new file mode 100644 index 000000000..d583c58f1 --- /dev/null +++ b/app/views/kaminari/admin/_page.html.haml @@ -0,0 +1,12 @@ +-# Link showing page number +-# available local variables +-# page: a page object for "this" page +-# url: url to this page +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span{:class => "page#{' current' if page.current?}"} + - param_name = current_page.instance_variable_get("@options")[:param_name] || Kaminari.config.param_name + - urlik = url_for( params.merge(param_name => page.to_i, :only_path => true)) + = link_to_unless page.current?, page, urlik, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} diff --git a/app/views/kaminari/admin/_paginator.html.haml b/app/views/kaminari/admin/_paginator.html.haml new file mode 100644 index 000000000..4f33e2dee --- /dev/null +++ b/app/views/kaminari/admin/_paginator.html.haml @@ -0,0 +1,18 @@ +-# The container tag +-# available local variables +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +-# paginator: the paginator that renders the pagination tags inside += paginator.render do + %nav.pagination + = first_page_tag unless current_page.first? + = prev_page_tag unless current_page.first? + - each_page do |page| + - if page.left_outer? || page.right_outer? || page.inside_window? + = page_tag page + - elsif !page.was_truncated? + = gap_tag + = next_page_tag unless current_page.last? + = last_page_tag unless current_page.last? diff --git a/app/views/kaminari/admin/_prev_page.html.haml b/app/views/kaminari/admin/_prev_page.html.haml new file mode 100644 index 000000000..3b565fa6f --- /dev/null +++ b/app/views/kaminari/admin/_prev_page.html.haml @@ -0,0 +1,11 @@ +-# Link to the "Previous" page +-# available local variables +-# url: url to the previous page +-# current_page: a page object for the currently displayed page +-# total_pages: total number of pages +-# per_page: number of items to fetch per page +-# remote: data-remote +%span.prev + - param_name = current_page.instance_variable_get("@options")[:param_name] || Kaminari.config.param_name + - urlik = url_for( params.merge(param_name => current_page.to_i - 1, :only_path => true)) + = link_to_unless current_page.first?, t('views.pagination.previous').html_safe, urlik, :rel => 'prev', :remote => remote