Show ident info as text #2776

This commit is contained in:
Priit Tark 2015-07-21 18:26:24 +03:00
parent 4ade318870
commit 0e4f333c47
2 changed files with 25 additions and 10 deletions

View file

@ -136,6 +136,12 @@ module Depp
end
hash
end
def type_string(type_code)
return '' if type_code.blank?
t = SELECTION_TYPES.select { |tp| tp.second == type_code }
t.try(:first)
end
end
def initialize(attributes = {})

View file

@ -6,26 +6,35 @@
.col-md-3.control-label
= f.label :ident_country_code, t(:country) + '*'
.col-md-7
= f.select(:ident_country_code, SortedCountry.all_options(f.object.ident_country_code),
{ selected: f.object.ident_country_code, include_blank: true },
class: 'js-ident-country-code', required: true, disabled: @contact.persisted?)
- if f.object.ident_country_code.present?
= Country.new(f.object.ident_country_code).try(:to_s)
- else
= f.select(:ident_country_code, SortedCountry.all_options(f.object.ident_country_code), {},
class: 'js-ident-country-code', required: true)
.form-group
.col-md-3.control-label
= f.label :ident_type, t(:type) + '*'
.col-md-7
= f.select(:ident_type, Depp::Contact::SELECTION_TYPES,
{ selected: f.object.ident_type, include_blank: true },
class: 'js-ident-type', required: true, disabled: @contact.persisted?)
- if f.object.ident_type.present?
= Depp::Contact.type_string(f.object.ident_type)
= " [#{f.object.ident_type}]"
- else
= f.select(:ident_type, Depp::Contact::SELECTION_TYPES,
{ selected: f.object.ident_type },
class: 'js-ident-type', required: true)
.form-group
.col-md-3.control-label
= f.label :ident, t(:ident) + '*'
.col-md-7
= f.text_field :ident, class: 'form-control', required: true, disabled: @contact.persisted?
- tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none'
.js-ident-tip{ style: tip_visibility }
= t(:birthday_format)
- if f.object.ident.present?
= f.object.ident
- else
= f.text_field :ident, class: 'form-control', required: true, disabled: @contact.persisted?
- tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none'
.js-ident-tip{ style: tip_visibility }
= t(:birthday_format)
.panel.panel-default
.panel-heading.clearfix