mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +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
1
Gemfile
1
Gemfile
|
@ -37,6 +37,7 @@ gem 'kaminari', '~> 0.16.3' # pagination
|
|||
gem 'nprogress-rails', '~> 0.1.6.5' # visual loader
|
||||
gem 'html5_validators', '~> 1.1.3' # model requements now automatically on html form
|
||||
gem 'coderay', '~> 1.1.0' # xml console visualize
|
||||
gem 'select2-rails', '~> 3.5.9.3' # for autocomplete
|
||||
|
||||
# rights
|
||||
gem 'devise', '~> 3.4.1' # authenitcation
|
||||
|
|
|
@ -410,6 +410,8 @@ GEM
|
|||
sdoc (0.4.1)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
select2-rails (3.5.9.3)
|
||||
thor (~> 0.14)
|
||||
selectize-rails (0.11.2)
|
||||
sexp_processor (4.5.0)
|
||||
shoulda-matchers (2.6.2)
|
||||
|
@ -548,6 +550,7 @@ DEPENDENCIES
|
|||
rubycritic (~> 1.1.1)
|
||||
sass-rails (~> 5.0.1)
|
||||
sdoc (~> 0.4.0)
|
||||
select2-rails (~> 3.5.9.3)
|
||||
selectize-rails (~> 0.11.2)
|
||||
shoulda-matchers (~> 2.6.1)
|
||||
simplecov (~> 0.9.1)
|
||||
|
|
|
@ -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