mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Domain form has now domain_contact part
This commit is contained in:
parent
4fef7e94c8
commit
d3e3c9e8b0
6 changed files with 41 additions and 12 deletions
|
@ -8,6 +8,7 @@ class Admin::DomainsController < ApplicationController
|
|||
params[:domain_owner_contact] = owner_contact
|
||||
|
||||
@domain.nameservers.build
|
||||
@domain.domain_contacts.build
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -61,7 +62,14 @@ class Admin::DomainsController < ApplicationController
|
|||
end
|
||||
|
||||
def domain_params
|
||||
params.require(:domain).permit(:name, :period, :period_unit, :registrar_id, :owner_contact_id, nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy])
|
||||
params.require(:domain).permit(
|
||||
:name,
|
||||
:period,
|
||||
:period_unit,
|
||||
:registrar_id,
|
||||
:owner_contact_id,
|
||||
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
||||
domain_contacts_attributes: [:id, :contact_type, :contact_id, :_destroy])
|
||||
end
|
||||
|
||||
def verify_deletion
|
||||
|
|
|
@ -4,7 +4,8 @@ class Domain < ActiveRecord::Base
|
|||
belongs_to :registrar
|
||||
belongs_to :owner_contact, class_name: 'Contact'
|
||||
|
||||
has_many :domain_contacts, dependent: :delete_all, autosave: true
|
||||
has_many :domain_contacts, dependent: :delete_all
|
||||
accepts_nested_attributes_for :domain_contacts, allow_destroy: true
|
||||
|
||||
has_many :tech_contacts, -> do
|
||||
where(domain_contacts: { contact_type: DomainContact::TECH })
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#nameservers-tab.tab-pane
|
||||
= render 'admin/domains/form_partials/nameservers', f: f
|
||||
#tech-contacts-tab.tab-pane
|
||||
= render 'admin/domains/form_partials/tech_contacts', f: f
|
||||
#admin-contacts-tab.tab-pane ...
|
||||
#statuses-tab.tab-pane ...
|
||||
.row
|
||||
|
|
28
app/views/admin/domains/form_partials/_tech_contacts.haml
Normal file
28
app/views/admin/domains/form_partials/_tech_contacts.haml
Normal file
|
@ -0,0 +1,28 @@
|
|||
#domain_contacts
|
||||
= f.fields_for :domain_contacts do |contact_fields|
|
||||
.panel.panel-default
|
||||
.panel-heading.text-right
|
||||
= link_to(t('shared.add_another'), '#', class: 'btn btn-primary btn-xs add-domain-contact')
|
||||
= link_to(t('shared.delete'), '#', class: 'btn btn-danger btn-xs destroy')
|
||||
.panel-body
|
||||
.errors
|
||||
= render 'admin/shared/errors', object: contact_fields.object
|
||||
.row
|
||||
.col-md-6
|
||||
.form-group
|
||||
= contact_fields.label :contact_type
|
||||
= contact_fields.select :contact_type, options_for_select(DomainContact::TYPES, contact_fields.object.contact_type), {}, {class: 'form-control'}
|
||||
.col-md-6
|
||||
.form-group.has-feedback
|
||||
= label_tag :contact
|
||||
= text_field_tag(:contact, params[: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-remove.form-control-feedback.js-typeahead-remove
|
||||
= contact_fields.hidden_field(:contact_id, class: 'js-contact-id')
|
||||
:javascript
|
||||
$("#domain_contacts").nestedAttributes({
|
||||
bindAddTo: $(".add-domain-contact"),
|
||||
afterAdd: function(item) {
|
||||
item.find('.errors').html('');
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue