diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index ddac61049..2383bda29 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -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 = {}) diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form_partials/_general.haml index 31479ddcd..ec408cbdc 100644 --- a/app/views/registrar/contacts/form_partials/_general.haml +++ b/app/views/registrar/contacts/form_partials/_general.haml @@ -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