Remove domain statuses from form

This commit is contained in:
Priit Tark 2015-04-15 12:00:00 +03:00
parent 47db36db15
commit 279f0a7e58
10 changed files with 70 additions and 80 deletions

View file

@ -5,7 +5,7 @@ module Depp
attr_accessor :name, :current_user, :epp_xml
DOMAIN_STATUSES = %w(
STATUSES = %w(
clientDeleteProhibited
clientHold
clientRenewProhibited
@ -13,6 +13,8 @@ module Depp
clientUpdateProhibited
)
PERIODS = [['1 year', '1y'], ['2 years', '2y'], ['3 years', '3y']]
def initialize(args = {})
self.current_user = args[:current_user]
self.epp_xml = EppXml::Domain.new(cl_trid_prefix: current_user.tag)
@ -36,7 +38,7 @@ module Depp
xml = epp_xml.create({
name: { value: domain_params[:name] },
registrant: { value: domain_params[:registrant] },
period: { value: domain_params[:period], attrs: { unit: domain_params[:period_unit] } },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } },
ns: Domain.create_nameservers_hash(domain_params),
_anonymus: Domain.create_contacts_hash(domain_params)
}, {
@ -164,7 +166,7 @@ module Depp
end
data.css('status').each_with_index do |x, i|
next unless DOMAIN_STATUSES.include?(x['s'])
next unless STATUSES.include?(x['s'])
ret[:statuses_attributes][i] = {
code: x['s'],
description: x.text
@ -190,12 +192,10 @@ module Depp
def construct_edit_hash(domain_params, old_domain_params)
contacts = create_contacts_hash(domain_params) - create_contacts_hash(old_domain_params)
statuses = create_statuses_hash(domain_params) - create_statuses_hash(old_domain_params)
add_anon = contacts + statuses
add_anon = contacts
contacts = create_contacts_hash(old_domain_params) - create_contacts_hash(domain_params)
statuses = create_statuses_hash(old_domain_params) - create_statuses_hash(domain_params)
rem_anon = contacts + statuses
rem_anon = contacts
if domain_params[:registrant] != old_domain_params[:registrant]
chg = [{ registrant: { value: domain_params[:registrant] } }]
@ -283,18 +283,6 @@ module Depp
pubKey: { value: key_data_params['public_key'] }
}
end
def create_statuses_hash(domain_params)
ret = []
domain_params[:statuses_attributes].each do |_k, v|
next if v['code'].blank?
ret << {
status: { value: v['description'], attrs: { s: v['code'] } }
}
end
ret
end
end
end
end

View file

@ -1,4 +1,4 @@
%h1= t('add_deposit')
%h1= t(:add_deposit)
%hr
= form_for([:registrar, @deposit], method: :post) do |f|
.row

View file

@ -1,7 +1,7 @@
- path = (params[:domain_name]) ? update_registrar_domains_path : registrar_domains_path
= form_tag(path, class: 'form-horizontal', multipart: true) do
.row
.col-md-12
.col-md-8
#general-tab.tab-pane.active
= render 'registrar/domains/form_partials/general'
= render 'registrar/domains/form_partials/contacts'
@ -16,9 +16,13 @@
= label_tag 'domain[legal_document]', t('legal_document'),class: 'col-md-3 control-label'
.col-md-9
= file_field_tag 'domain[legal_document]'
.col-md-4
%p.domain-general-help= t(:domain_general_help).html_safe
%p.domain-admin-contact-help= t(:domain_admin_contact_help).html_safe
%p.domain-tech-contact-help= t(:domain_tech_contact_help).html_safe
.row
.col-md-12.text-right
.col-md-8.text-right
= button_tag(t('shared.save'), class: 'btn btn-primary')
:javascript

View file

@ -8,13 +8,13 @@
= link_to(t('delete'), '#', class: 'btn btn-danger btn-xs destroy')
.panel-body
.form-group
= label_tag "domain_contacts_attributes_#{k}_type", t('contact_type'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_contacts_attributes_#{k}_type", t('contact_type'), class: 'col-md-3 control-label'
.col-md-7
= select_tag "domain[contacts_attributes][#{k}][type]", options_for_select(['admin', 'tech'], v['type']), {class: 'form-control'}
.form-group
= label_tag "domain_contacts_attributes_#{k}_code", t('contact_code'), class: 'col-md-2 control-label'
.col-md-10.has-feedback
= label_tag "domain_contacts_attributes_#{k}_code", t('contact_code'), class: 'col-md-3 control-label'
.col-md-7.has-feedback
= text_field_tag("domain[contacts_attributes][#{k}][code]", v['code'], class: 'form-control', placeholder: t('contact_code'), autocomplete: 'off')
:coffee
$("#domain-contacts").nestedAttributes

View file

@ -9,43 +9,43 @@
.panel-body
- if ENV['show_ds_data_fields'] == 'true'
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_ds_key_tag", t('ds_key_tag'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_ds_key_tag", t('ds_key_tag'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[dnskeys_attributes][#{k}][ds_key_tag]", v['ds_key_tag'], {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_ds_alg", t('ds_algorithm'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_ds_alg", t('ds_algorithm'), class: 'col-md-3 control-label'
.col-md-7
= select_tag "domain[dnskeys_attributes][#{k}][ds_alg]", options_for_select(Depp::Dnskey::ALGORITHMS, v['ds_alg']), {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_ds_digest_type", t('ds_digest_type'), class: 'col-md-2 control-label'
.col-md-10
.col-md-7
= select_tag "domain[dnskeys_attributes][#{k}][ds_digest_type]", options_for_select(Depp::Dnskey::DS_DIGEST_TYPES, v['ds_digest_type']), {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_ds_digest", t('ds_digest'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_ds_digest", t('ds_digest'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[dnskeys_attributes][#{k}][ds_digest]", v['ds_digest'], {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_flags", t('flags'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_flags", t('flags'), class: 'col-md-3 control-label'
.col-md-7
= select_tag "domain[dnskeys_attributes][#{k}][flags]", options_for_select(Depp::Dnskey::FLAGS, v['flags']), {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_protocol", t('protocol'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_protocol", t('protocol'), class: 'col-md-3 control-label'
.col-md-7
= select_tag "domain[dnskeys_attributes][#{k}][protocol]", options_for_select(Depp::Dnskey::PROTOCOLS, v['protocol']), {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_alg", t('alg'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_alg", t('alg'), class: 'col-md-3 control-label'
.col-md-7
= select_tag "domain[dnskeys_attributes][#{k}][alg]", options_for_select(Depp::Dnskey::ALGORITHMS, v['alg']), {class: 'form-control'}
.form-group
= label_tag "domain_dnskeys_attributes_#{k}_public_key", t('public_key'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_dnskeys_attributes_#{k}_public_key", t('public_key'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[dnskeys_attributes][#{k}][public_key]", v['public_key'], class: 'form-control'
:coffee
$("#dnskeys").nestedAttributes

View file

@ -1,20 +1,19 @@
.general-tab.panel.panel-default
.panel-body
.form-group
= label_tag :domain_name, t('name'), class: 'col-md-2 control-label'
.col-md-10
= label_tag :domain_name, t('name'), class: 'col-md-3 control-label'
.col-md-7
- readonly = params[:domain_name] ? true : false
= text_field_tag('domain[name]', @domain_params[:name], class: 'form-control', readonly: readonly)
- unless params[:domain_name]
.form-group
= label_tag :domain_period, t('period'), class: 'col-md-2 control-label'
.col-md-5
= text_field_tag('domain[period]', @domain_params[:period], class: 'form-control')
.col-md-5
= select_tag 'domain[period_unit]', options_for_select(['y', 'm', 'd'], @domain_params[:period_unit]), { class: 'form-control' }
= label_tag :domain_period, t('period'), class: 'col-md-3 control-label'
.col-md-7
= select_tag 'domain[period]',
options_for_select(Depp::Domain::PERIODS, @domain_params[:period]), { class: 'form-control' }
.form-group
= label_tag :domain_registrant, t('registrant'), class: 'col-md-2 control-label'
.col-md-10
= label_tag :domain_registrant, t('registrant'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag('domain[registrant]', @domain_params[:registrant], class: 'form-control', placeholder: t('contact_code'), autocomplete: 'off')

View file

@ -8,16 +8,16 @@
= link_to(t('delete'), '#', class: 'btn btn-danger btn-xs destroy')
.panel-body
.form-group
= label_tag "domain_nameservers_attributes_#{k}_hostname", t('hostname'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_nameservers_attributes_#{k}_hostname", t('hostname'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[nameservers_attributes][#{k}][hostname]", v['hostname'], class: 'form-control'
.form-group
= label_tag "domain_nameservers_attributes_#{k}_ipv4", t('ipv4'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_nameservers_attributes_#{k}_ipv4", t('ipv4'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[nameservers_attributes][#{k}][ipv4]", v['ipv4'], class: 'form-control'
.form-group
= label_tag "domain_nameservers_attributes_#{k}_ipv6", t('ipv6'), class: 'col-md-2 control-label'
.col-md-10
= label_tag "domain_nameservers_attributes_#{k}_ipv6", t('ipv6'), class: 'col-md-3 control-label'
.col-md-7
= text_field_tag "domain[nameservers_attributes][#{k}][ipv6]", v['ipv6'], class: 'form-control'
:coffee
$("#nameservers").nestedAttributes

View file

@ -1,24 +0,0 @@
#domain-statuses
- @domain_params['statuses_attributes'].each do |k, v|
%br
.panel.panel-default
.panel-heading.clearfix
.pull-left= t('status')
.pull-right
= link_to(t('add_another'), '#', class: 'btn btn-primary btn-xs add-domain-status')
= link_to(t('delete'), '#', class: 'btn btn-danger btn-xs destroy')
.panel-body
.form-group
= label_tag "domain_statuses_attributes_#{k}_code", t('code'),class: 'col-md-2 control-label'
.col-md-10
= select_tag "domain[statuses_attributes][#{k}][code]", options_for_select(Depp::Domain::DOMAIN_STATUSES, v['code']), {class: 'form-control', prompt: ''}
.form-group
= label_tag "domain_statuses_attributes_#{k}_description", t('description'),class: 'col-md-2 control-label'
.col-md-10
= text_field_tag "domain[statuses_attributes][#{k}][description]", v['description'], class: 'form-control', autocomplete: 'off'
:coffee
$("#domain-statuses").nestedAttributes
bindAddTo: $(".add-domain-status")
afterAdd: (item) ->
item.find('select').each (k, v) ->
$(v).val($(v).find('option:first-child').val())

View file

@ -0,0 +1,14 @@
#domain_statuses.panel.panel-default
.panel-heading.clearfix
%h3.panel-title= t(:statuses)
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-6'}= t('status')
%th{class: 'col-xs-6'}= t('description')
%tbody
- @data.css('status').each do |x|
%tr
%td= x['s']
%td= x.text