Fix domain history ordering and current state display

- Ensure "Current state" (pending/current domain) is always shown as the first row in domain history.
- Sort post-update domain states by updated_at descending for correct chronological order.
- Fix version navigation and sidebar highlighting for current state in domain version show view.
- Unify logic for displaying domain and contact data in both history and single version views.
- Remove legacy ObjectVersionsParser usage and handle nil @version cases gracefully.
- Refactor partials and controller logic to ensure all rows in history reflect the correct post-update state.
This commit is contained in:
oleghasjanov 2025-07-17 09:07:40 +03:00
parent 0b13cfbe0f
commit 9e5b2743a3
6 changed files with 74 additions and 45 deletions

View file

@ -56,14 +56,18 @@ module Admin
def show
per_page = 7
@version = Version::DomainVersion.find(params[:id])
@versions = Version::DomainVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
if params[:current]
@domain = Domain.find(params[:domain_id] || params[:id])
@version = nil
else
@version = Version::DomainVersion.find(params[:id])
@domain = Domain.find(@version.item_id)
end
@versions = Version::DomainVersion.where(item_id: @domain.id).order(created_at: :desc, id: :desc)
@versions_map = @versions.all.map(&:id)
# what we do is calc amount of results until needed version
# then we cacl which page it is
if params[:page].blank?
counter = @versions_map.index(@version.id) + 1
counter = @version ? (@versions_map.index(@version.id) + 1) : 1
page = counter / per_page
page += 1 if (counter % per_page) != 0
params[:page] = page