mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Registrar: domain form autocompletes registrar and contact code
This commit is contained in:
parent
2b9923de49
commit
2ea24f42fc
8 changed files with 29 additions and 4 deletions
|
@ -7,5 +7,8 @@
|
|||
#= require jquery.nested_attributes
|
||||
#= require shared/jquery.validate.bootstrap
|
||||
#= require jquery-ui/datepicker
|
||||
#= require select2
|
||||
|
||||
#= require shared/general
|
||||
|
||||
#= require registrar/application
|
||||
|
|
|
@ -19,3 +19,8 @@ $(document).on 'ready page:load', ->
|
|||
dateFormat: "yy-mm-dd",
|
||||
maxDate: tomorrow
|
||||
);
|
||||
|
||||
$('.js-combobox').select2
|
||||
width: "100%"
|
||||
selectOnBlur: true
|
||||
dropdownAutoWidth: if self==top then true else false
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
//= require 'shared/general-manifest'
|
||||
//= require 'registrar/registrar-bootstrap'
|
||||
//= require 'jquery-ui/datepicker'
|
||||
//= require 'select2'
|
||||
//= require 'select2-bootstrap'
|
||||
@import shared/fonts
|
||||
@import shared/general
|
||||
@import nprogress
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -17,11 +17,15 @@
|
|||
.col-md-3.control-label
|
||||
= label_tag "domain_contacts_attributes_#{k}_code", t(:contact_code), class: 'required'
|
||||
.col-md-7.has-feedback
|
||||
= text_field_tag("domain[contacts_attributes][#{k}][code]", v['code'],
|
||||
class: 'form-control', placeholder: t(:contact_code), autocomplete: 'off', required: true)
|
||||
= select_tag "domain[contacts_attributes][#{k}][code]",
|
||||
options_for_select(@contacts_autocomplete_map, selected: v['code']),
|
||||
include_blank: true, class: 'js-combobox', required: true
|
||||
|
||||
:coffee
|
||||
$("#domain-contacts").nestedAttributes
|
||||
bindAddTo: $(".add-domain-contact")
|
||||
afterAdd: (item) ->
|
||||
item.find('select').each (k, v) ->
|
||||
$(v).val($(v).find('option:first-child').val())
|
||||
|
||||
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
.col-md-3.control-label
|
||||
= label_tag :domain_registrant, t(:registrant), class: 'required'
|
||||
.col-md-7
|
||||
= text_field_tag('domain[registrant]', @domain_params[:registrant],
|
||||
class: 'form-control', placeholder: t(:contact_code), autocomplete: 'off', required: true)
|
||||
= select_tag "domain[registrant]",
|
||||
options_for_select(@contacts_autocomplete_map, selected: @domain_params[:registrant]),
|
||||
include_blank: true, class: 'js-combobox', required: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue