mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 17:33:57 +02:00
Prefixes to statuses are added no automatically in admin
This commit is contained in:
parent
5083062de4
commit
69a0d3938f
3 changed files with 18 additions and 1 deletions
|
@ -15,6 +15,8 @@ class Admin::DomainsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
add_prefix_to_statuses
|
||||||
|
|
||||||
if @domain.update(domain_params)
|
if @domain.update(domain_params)
|
||||||
flash[:notice] = I18n.t('shared.domain_updated')
|
flash[:notice] = I18n.t('shared.domain_updated')
|
||||||
redirect_to [:admin, @domain]
|
redirect_to [:admin, @domain]
|
||||||
|
@ -36,4 +38,10 @@ class Admin::DomainsController < AdminController
|
||||||
domain_statuses_attributes: [:id, :value, :description, :_destroy]
|
domain_statuses_attributes: [:id, :value, :description, :_destroy]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_prefix_to_statuses
|
||||||
|
domain_params[:domain_statuses_attributes].each do |_k, hash|
|
||||||
|
hash[:value] = hash[:value].prepend('server')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,5 +50,14 @@ class DomainStatus < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statuses_for_admin
|
||||||
|
ret = []
|
||||||
|
STATUSES.each do |x|
|
||||||
|
next unless x.start_with?('server')
|
||||||
|
ret << x.sub('server', '')
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group
|
.form-group
|
||||||
= status_fields.label :value
|
= status_fields.label :value
|
||||||
= status_fields.select :value, options_for_select(DomainStatus::STATUSES, status_fields.object.value), {include_blank: true}, {class: 'form-control'}
|
= status_fields.select :value, options_for_select(DomainStatus.statuses_for_admin, status_fields.object.value.sub('server', '')), {include_blank: true}, {class: 'form-control'}
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group
|
.form-group
|
||||||
= status_fields.label :description
|
= status_fields.label :description
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue