108869472-new_qieries_and_views

This commit is contained in:
Stas 2016-04-21 15:21:59 +03:00
parent ff33eaa031
commit a09e6b1a42
4 changed files with 39 additions and 21 deletions

View file

@ -30,7 +30,7 @@ class Admin::ContactVersionsController < AdminController
def show def show
per_page = 7 per_page = 7
@version = ContactVersion.find(params[:id]) @version = ContactVersion.find(params[:id])
@q = ContactVersion.where(item_id: @version.item_id).order(created_at: :asc).search @q = ContactVersion.where(item_id: @version.item_id).order(created_at: :desc).search
@versions = @q.result.page(params[:page]) @versions = @q.result.page(params[:page])
@versions = @versions.per(per_page) @versions = @versions.per(per_page)
end end
@ -40,7 +40,7 @@ class Admin::ContactVersionsController < AdminController
end end
def create_where_string(key, value) def create_where_string(key, value)
" AND object->>'#{key}' ~ '#{value}'" " AND object->>'#{key}' LIKE '%#{value}%'"
end end
end end

View file

@ -11,7 +11,7 @@
.col-md-3 .col-md-3
.form-group .form-group
= f.label :id = f.label :id
= f.search_field :id, value: params[:q][:id], class: 'form-control', placeholder: t(:id) = f.search_field :code, value: params[:q][:code], class: 'form-control', placeholder: t(:id)
.col-md-3 .col-md-3
.form-group .form-group
= f.label :ident = f.label :ident

View file

@ -19,14 +19,15 @@
%dt= t(:ident) %dt= t(:ident)
%dd= ident_for(contact) %dd= ident_for(contact)
%dt= t(:email) - if contact.email.present?
%dd= contact.email %dt= t(:email)
%dd= contact.email
- if contact.phone - if contact.phone.present?
%dt= t(:phone) %dt= t(:phone)
%dd= contact.phone %dd= contact.phone
- if contact.fax - if contact.fax.present?
%dt= t(:fax) %dt= t(:fax)
%dd= contact.fax %dd= contact.fax
@ -50,20 +51,25 @@
%dt= t(:org_name) %dt= t(:org_name)
%dd= contact.org_name %dd= contact.org_name
%dt= t(:street) - if contact.street.present?
%dd= contact.street.to_s.gsub("\n", '<br>').html_safe %dt= t(:street)
%dd= contact.street.to_s.gsub("\n", '<br>').html_safe
%dt= t(:city) - if contact.city.present?
%dd= contact.city %dt= t(:city)
%dd= contact.city
%dt= t(:zip) - if contact.zip.present?
%dd= contact.zip %dt= t(:zip)
%dd= contact.zip
%dt= t(:state) - if contact.state.present?
%dd= contact.state %dt= t(:state)
%dd= contact.state
%dt= t(:country) - if contact.country.present?
%dd= contact.country %dt= t(:country)
%dd= contact.country
%span{:style => "padding-right:10px; float: right;"} %span{:style => "padding-right:10px; float: right;"}

View file

@ -13,7 +13,7 @@
.row .row
.col-md-8 .col-md-8
.panel.panel-default{:style => "min-height:400px;"} .panel.panel-default{:style => "min-height:450px;"}
.panel-heading .panel-heading
%h3.panel-title %h3.panel-title
= l(@version.created_at, format: :short) = l(@version.created_at, format: :short)
@ -24,7 +24,19 @@
%dt= t(:name) %dt= t(:name)
%dd= link_to(domain.name, admin_domain_path(@version.item_id)) %dd= link_to(domain.name, admin_domain_path(@version.item_id))
%dt= t(:registered_at) %dt= t(:registered_at)
%dd= l(domain.registered_at, format: :short) %dd
= l(domain.registered_at, format: :short)
%dt= t(:created)
%dd
= l(domain.created_at, format: :short)
%dt= t(:updated)
%dd
= l(domain.updated_at, format: :short)
%br
%dt= t(:statuses) %dt= t(:statuses)
%dd %dd
- if domain.statuses.present? - if domain.statuses.present?
@ -63,7 +75,7 @@
%br %br
%dt= t(:registrar) %dt= t(:registrar)
%dd= domain.registrar.name %dd= domain.registrar.name
%span{:style => "padding-right:10px; padding-top:40px; float: right; bottom: 10px;"} %span{:style => "padding-right:10px; float: right; bottom: 10px;"}
- if @version.previous - if @version.previous
= link_to(t(:previous), = link_to(t(:previous),
admin_domain_version_path(@version.previous.id), admin_domain_version_path(@version.previous.id),
@ -80,7 +92,7 @@
%span= t(:next) %span= t(:next)
.col-md-4 .col-md-4
.panel.panel-default{:style => "min-height:400px;"} .panel.panel-default{:style => "min-height:450px;"}
%ul.nav.nav-pills.nav-stacked %ul.nav.nav-pills.nav-stacked
- @versions.each do |vs| - @versions.each do |vs|
- if vs.id == @version.id and vs.reify - if vs.id == @version.id and vs.reify