mirror of
https://github.com/internetee/registry.git
synced 2025-05-20 11:19:39 +02:00
Refactor status form #2623
This commit is contained in:
parent
9b9e1a3068
commit
238b3aa5e0
4 changed files with 7 additions and 6 deletions
|
@ -22,7 +22,7 @@ class Admin::DomainsController < AdminController
|
||||||
flash[:notice] = I18n.t('domain_updated')
|
flash[:notice] = I18n.t('domain_updated')
|
||||||
redirect_to [:admin, @domain]
|
redirect_to [:admin, @domain]
|
||||||
else
|
else
|
||||||
@domain.domain_statuses.build if @domain.domain_statuses.empty?
|
build_associations
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
||||||
render 'edit'
|
render 'edit'
|
||||||
end
|
end
|
||||||
|
@ -64,11 +64,11 @@ class Admin::DomainsController < AdminController
|
||||||
@domain.domain_statuses.build if @domain.domain_statuses.empty?
|
@domain.domain_statuses.build if @domain.domain_statuses.empty?
|
||||||
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
|
||||||
@server_statuses = [nil] if @server_statuses.empty?
|
@server_statuses = [nil] if @server_statuses.empty?
|
||||||
|
@other_statuses = @domain.statuses.select { |x| !DomainStatus::SERVER_STATUSES.include?(x) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_prefix_to_statuses
|
def add_prefix_to_statuses
|
||||||
dp = domain_params
|
dp = domain_params
|
||||||
dp[:statuses] = domain_params[:statuses].map { |x| x.prepend('server') if x.present? }
|
|
||||||
dp[:statuses].reject! { |x| x.blank? }
|
dp[:statuses].reject! { |x| x.blank? }
|
||||||
dp
|
dp
|
||||||
end
|
end
|
||||||
|
|
|
@ -317,7 +317,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_deletable?
|
def force_deletable?
|
||||||
domain_statuses.where(value: DomainStatus::FORCE_DELETE).empty?
|
!statuses.include?(DomainStatus::FORCE_DELETE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_verification_asked?
|
def registrant_verification_asked?
|
||||||
|
|
|
@ -124,7 +124,7 @@ class DomainStatus < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses_for_admin
|
def statuses_for_admin
|
||||||
SERVER_STATUSES.map { |x| x.sub('server', '') }
|
SERVER_STATUSES.map { |x| [x.sub('server', ''), x] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
.form-group
|
.form-group
|
||||||
= f.label 'status', class: 'col-md-2 control-label'
|
= f.label 'status', class: 'col-md-2 control-label'
|
||||||
.col-md-10
|
.col-md-10
|
||||||
= select_tag 'domain[statuses][]', options_for_select(DomainStatus.statuses_for_admin, x.try(:sub, 'server', '')), include_blank: true, class: 'form-control'
|
= select_tag 'domain[statuses][]', options_for_select(DomainStatus.statuses_for_admin, x), include_blank: true, class: 'form-control'
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag t(:description), nil, class: 'col-md-2 control-label'
|
= label_tag t(:description), nil, class: 'col-md-2 control-label'
|
||||||
.col-md-10
|
.col-md-10
|
||||||
= text_field_tag :description, nil, class: 'form-control', autocomplete: 'off'
|
= text_field_tag :description, nil, class: 'form-control', autocomplete: 'off'
|
||||||
|
- @other_statuses.each do |x|
|
||||||
|
= hidden_field_tag 'domain[statuses][]', x, readonly: true
|
||||||
:coffee
|
:coffee
|
||||||
$("#domain-statuses").nestedAttributes
|
$("#domain-statuses").nestedAttributes
|
||||||
bindAddTo: $(".add-domain-status")
|
bindAddTo: $(".add-domain-status")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue