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 }
|
||||
next unless existing.length > 1
|
||||
validated << status.value
|
||||
errors.add(:domain_statuses, :invalid)
|
||||
errors.add(:domain_statuses, :invalid) if errors[:domain_statuses].blank?
|
||||
status.errors.add(:value, :taken)
|
||||
end
|
||||
end
|
||||
|
@ -161,6 +161,15 @@ class Domain < ActiveRecord::Base
|
|||
(errors.keys - assoc_errors).empty?
|
||||
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
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -4,13 +4,29 @@
|
|||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
/ Nav tabs
|
||||
%ul.nav.nav-tabs{:role => "tablist", id: 'tabs'}
|
||||
- li_class = @domain.general_tab_valid? ? nil : 'error-tab'
|
||||
%li.active{class: li_class}
|
||||
%a{"data-toggle" => "tab", :href => "#general-tab", :role => "tab"}= t('shared.general')
|
||||
- li_class = @domain.statuses_tab_valid? ? nil : 'error-tab'
|
||||
%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/statuses', f: f
|
||||
%hr
|
||||
= render 'admin/domains/form_partials/nameservers', f: f
|
||||
#statuses-tab.tab-pane
|
||||
= render 'admin/domains/form_partials/statuses', f: f
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
= 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