Registrar: domain form autocompletes registrar and contact code

This commit is contained in:
Priit Tark 2015-05-07 15:50:55 +03:00
parent 2b9923de49
commit 2ea24f42fc
8 changed files with 29 additions and 4 deletions

View file

@ -1,5 +1,6 @@
class Registrar::DomainsController < Registrar::DeppController # EPP controller
before_action :init_domain, except: :new
before_action :init_contacts_autocomplete_map, only: [:new, :edit, :create, :update]
def index
authorize! :view, Depp::Domain
@ -116,4 +117,9 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
def init_contacts_autocomplete_map
@contacts_autocomplete_map ||=
current_user.registrar.contacts.pluck(:name, :code).map {|c| ["#{c.second} #{c.first}", c.second]}
end
end