mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Story#108869472 - contact history uses same pagination what domain history does
This commit is contained in:
parent
97c4bf0097
commit
4b9ba0fe13
3 changed files with 22 additions and 25 deletions
|
@ -30,9 +30,18 @@ class Admin::ContactVersionsController < AdminController
|
|||
def show
|
||||
per_page = 7
|
||||
@version = ContactVersion.find(params[:id])
|
||||
@q = ContactVersion.where(item_id: @version.item_id).order(created_at: :desc).search
|
||||
@versions = @q.result.page(params[:page])
|
||||
@versions = @versions.per(per_page)
|
||||
@versions = ContactVersion.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
|
||||
|
|
|
@ -92,15 +92,9 @@
|
|||
.panel.panel-default{:style => "min-height:420px;"}
|
||||
%ul.nav.nav-pills.nav-stacked
|
||||
- @versions.each do |vs|
|
||||
- if vs.id == @version.id
|
||||
%li.active
|
||||
= link_to admin_contact_version_path(vs.id) do
|
||||
= l(vs.created_at, format: :short)
|
||||
= vs.event
|
||||
- else
|
||||
%li
|
||||
= link_to admin_contact_version_path(vs.id) do
|
||||
%li{class: (vs.id == @version.id) && :active}
|
||||
= link_to admin_contact_version_path(vs.id, page: params[:page]) do
|
||||
= l(vs.created_at, format: :short)
|
||||
= vs.event
|
||||
%span{:style => "padding-left:10px; position: absolute; bottom: 10px;"}
|
||||
= paginate @versions
|
||||
= paginate @versions, theme: :admin
|
|
@ -96,13 +96,7 @@
|
|||
.panel.panel-default{:style => "min-height:450px;"}
|
||||
%ul.nav.nav-pills.nav-stacked
|
||||
- @versions.each do |vs|
|
||||
- if vs.id == @version.id
|
||||
%li.active
|
||||
= link_to admin_domain_version_path(vs) do
|
||||
= l(vs.created_at, format: :short)
|
||||
= vs.event
|
||||
- else
|
||||
%li
|
||||
%li{class: (vs.id == @version.id) && :active}
|
||||
= link_to admin_domain_version_path(vs) do
|
||||
= l(vs.created_at, format: :short)
|
||||
= vs.event
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue