mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Domain form contacts partial refactor
This commit is contained in:
parent
bfe89c7a09
commit
89295f5642
6 changed files with 17 additions and 14 deletions
|
@ -9,7 +9,7 @@ class @Autocomplete
|
||||||
displayKey: "display_key"
|
displayKey: "display_key"
|
||||||
source: Autocomplete.constructSourceAdapter(obj.remote)
|
source: Autocomplete.constructSourceAdapter(obj.remote)
|
||||||
).on('typeahead:selected', (e, item) ->
|
).on('typeahead:selected', (e, item) ->
|
||||||
parent = $(e.currentTarget).parents('div.has-feedback')
|
parent = $(e.currentTarget).parents('div.js-typeahead-container')
|
||||||
jObj = parent.find(obj.hiddenSelector).val item.id
|
jObj = parent.find(obj.hiddenSelector).val item.id
|
||||||
Autocomplete.toggleOkFeedback(jObj)
|
Autocomplete.toggleOkFeedback(jObj)
|
||||||
)
|
)
|
||||||
|
@ -27,8 +27,8 @@ class @Autocomplete
|
||||||
source.ttAdapter()
|
source.ttAdapter()
|
||||||
|
|
||||||
@toggleOkFeedback: (jObj) ->
|
@toggleOkFeedback: (jObj) ->
|
||||||
ok = jObj.parents('div.has-feedback').find('.js-typeahead-ok')
|
ok = jObj.parents('div.js-typeahead-container').find('.js-typeahead-ok')
|
||||||
remove = jObj.parents('div.has-feedback').find('.js-typeahead-remove')
|
remove = jObj.parents('div.js-typeahead-container').find('.js-typeahead-remove')
|
||||||
|
|
||||||
if jObj.val()
|
if jObj.val()
|
||||||
ok.removeClass('hidden')
|
ok.removeClass('hidden')
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Admin::DomainsController < ApplicationController
|
||||||
:registrar_id,
|
:registrar_id,
|
||||||
:owner_contact_id,
|
:owner_contact_id,
|
||||||
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
||||||
domain_contacts_attributes: [:id, :contact_type, :contact_id, :_destroy])
|
domain_contacts_attributes: [:id, :contact_type, :contact_id, :typeahead_value, :_destroy])
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_deletion
|
def verify_deletion
|
||||||
|
|
|
@ -3,6 +3,8 @@ class DomainContact < ActiveRecord::Base
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
|
attr_accessor :typeahead_value
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2302' => [
|
'2302' => [
|
||||||
|
@ -28,4 +30,8 @@ class DomainContact < ActiveRecord::Base
|
||||||
def tech?
|
def tech?
|
||||||
contact_type == TECH
|
contact_type == TECH
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def typeahead_value
|
||||||
|
@typeahead_value || contact.try(:name) || nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
%li
|
%li
|
||||||
%a{"data-toggle" => "tab", :href => "#nameservers-tab", :role => "tab"} nameservers-tab
|
%a{"data-toggle" => "tab", :href => "#nameservers-tab", :role => "tab"} nameservers-tab
|
||||||
%li
|
%li
|
||||||
%a{"data-toggle" => "tab", :href => "#tech-contacts-tab", :role => "tab"} tech-contacts-tab
|
%a{"data-toggle" => "tab", :href => "#contacts-tab", :role => "tab"} contacts-tab
|
||||||
%li
|
|
||||||
%a{"data-toggle" => "tab", :href => "#admin-contacts", :role => "tab"} admin-contacts-tab
|
|
||||||
%li
|
%li
|
||||||
%a{"data-toggle" => "tab", :href => "#statuses-tab", :role => "tab"} statuses-tab
|
%a{"data-toggle" => "tab", :href => "#statuses-tab", :role => "tab"} statuses-tab
|
||||||
/ Tab panes
|
/ Tab panes
|
||||||
|
@ -26,9 +24,8 @@
|
||||||
= render 'admin/domains/form_partials/general', f: f
|
= render 'admin/domains/form_partials/general', f: f
|
||||||
#nameservers-tab.tab-pane
|
#nameservers-tab.tab-pane
|
||||||
= render 'admin/domains/form_partials/nameservers', f: f
|
= render 'admin/domains/form_partials/nameservers', f: f
|
||||||
#tech-contacts-tab.tab-pane
|
#contacts-tab.tab-pane
|
||||||
= render 'admin/domains/form_partials/tech_contacts', f: f
|
= render 'admin/domains/form_partials/contacts', f: f
|
||||||
#admin-contacts-tab.tab-pane ...
|
|
||||||
#statuses-tab.tab-pane ...
|
#statuses-tab.tab-pane ...
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
= contact_fields.select :contact_type, options_for_select(DomainContact::TYPES, contact_fields.object.contact_type), {}, {class: 'form-control'}
|
= contact_fields.select :contact_type, options_for_select(DomainContact::TYPES, contact_fields.object.contact_type), {}, {class: 'form-control'}
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group.has-feedback.js-typeahead-container
|
.form-group.has-feedback.js-typeahead-container
|
||||||
= label_tag :contact
|
= contact_fields.label :typeahead_value
|
||||||
= text_field_tag(:contact, params[:contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
= contact_fields.text_field(:typeahead_value, class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
||||||
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||||
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
||||||
= contact_fields.hidden_field(:contact_id, class: 'js-contact-id')
|
= contact_fields.hidden_field(:contact_id, class: 'js-contact-id')
|
|
@ -11,13 +11,13 @@
|
||||||
.col-md-6
|
.col-md-6
|
||||||
= f.select :period_unit, options_for_select(['y', 'm', 'd'], @domain.period_unit), {}, {class: 'form-control'}
|
= f.select :period_unit, options_for_select(['y', 'm', 'd'], @domain.period_unit), {}, {class: 'form-control'}
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group.has-feedback
|
.form-group.has-feedback.js-typeahead-container
|
||||||
= f.label :registrar
|
= f.label :registrar
|
||||||
= text_field_tag(:domain_registrar, params[:registrar], class: 'form-control js-registrar-typeahead', placeholder: t('shared.registrar_name'), autocomplete: 'off')
|
= text_field_tag(:domain_registrar, params[:registrar], class: 'form-control js-registrar-typeahead', placeholder: t('shared.registrar_name'), autocomplete: 'off')
|
||||||
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||||
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
||||||
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
||||||
.form-group.has-feedback
|
.form-group.has-feedback.js-typeahead-container
|
||||||
= f.label :owner_contact
|
= f.label :owner_contact
|
||||||
= text_field_tag(:domain_owner_contact, params[:domain_owner_contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
= text_field_tag(:domain_owner_contact, params[:domain_owner_contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
||||||
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue