mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Refactor
This commit is contained in:
parent
44424984f0
commit
ef0eb7cbc6
2 changed files with 33 additions and 8 deletions
|
@ -130,7 +130,7 @@ class Domain < ActiveRecord::Base
|
||||||
existing = domain_statuses.select { |x| x.value == status.value }
|
existing = domain_statuses.select { |x| x.value == status.value }
|
||||||
next unless existing.length > 1
|
next unless existing.length > 1
|
||||||
validated << status.value
|
validated << status.value
|
||||||
errors.add(:domain_statuses, :invalid)
|
errors.add(:domain_statuses, :invalid) if errors[:domain_statuses].blank?
|
||||||
status.errors.add(:value, :taken)
|
status.errors.add(:value, :taken)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -161,6 +161,15 @@ class Domain < ActiveRecord::Base
|
||||||
(errors.keys - assoc_errors).empty?
|
(errors.keys - assoc_errors).empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def general_tab_valid?
|
||||||
|
status_errors = errors.keys.collect { |x| x.match(/domain_statuses/) }
|
||||||
|
(errors.keys - status_errors).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def statuses_tab_valid?
|
||||||
|
!errors.keys.any? { |x| x.match(/domain_statuses/) }
|
||||||
|
end
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -4,13 +4,29 @@
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= render 'admin/domains/form_partials/general', f: f
|
/ Nav tabs
|
||||||
%hr
|
%ul.nav.nav-tabs{:role => "tablist", id: 'tabs'}
|
||||||
= render 'admin/domains/form_partials/contacts', f: f
|
- li_class = @domain.general_tab_valid? ? nil : 'error-tab'
|
||||||
%hr
|
%li.active{class: li_class}
|
||||||
= render 'admin/domains/form_partials/statuses', f: f
|
%a{"data-toggle" => "tab", :href => "#general-tab", :role => "tab"}= t('shared.general')
|
||||||
%hr
|
- li_class = @domain.statuses_tab_valid? ? nil : 'error-tab'
|
||||||
= render 'admin/domains/form_partials/nameservers', f: f
|
%li{class: li_class}
|
||||||
|
%a{"data-toggle" => "tab", :href => "#statuses-tab", :role => "tab"}= t('shared.statuses')
|
||||||
|
/ Tab panes
|
||||||
|
.tab-content{style:'margin-top: 20px;'}
|
||||||
|
#general-tab.tab-pane.active
|
||||||
|
= render 'admin/domains/form_partials/general', f: f
|
||||||
|
%hr
|
||||||
|
= render 'admin/domains/form_partials/contacts', f: f
|
||||||
|
%hr
|
||||||
|
= render 'admin/domains/form_partials/nameservers', f: f
|
||||||
|
#statuses-tab.tab-pane
|
||||||
|
= render 'admin/domains/form_partials/statuses', f: f
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(function () {
|
||||||
|
$('#tabs a:first').tab('show')
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue