mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Contact/Domain statuses admin interface refactored #2785
This commit is contained in:
parent
ac0ca8c6dc
commit
e387ea4bb4
6 changed files with 58 additions and 54 deletions
|
@ -120,12 +120,47 @@ class DomainStatus < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def statuses_for_client
|
def admin_statuses
|
||||||
CLIENT_STATUSES.map { |x| x.sub('client', '') }
|
[
|
||||||
|
SERVER_DELETE_PROHIBITED,
|
||||||
|
SERVER_HOLD,
|
||||||
|
SERVER_RENEW_PROHIBITED,
|
||||||
|
SERVER_TRANSFER_PROHIBITED,
|
||||||
|
SERVER_UPDATE_PROHIBITED,
|
||||||
|
SERVER_MANUAL_INZONE,
|
||||||
|
SERVER_REGISTRANT_CHANGE_PROHIBITED,
|
||||||
|
SERVER_ADMIN_CHANGE_PROHIBITED,
|
||||||
|
SERVER_TECH_CHANGE_PROHIBITED
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses_for_admin
|
def admin_statuses_map
|
||||||
SERVER_STATUSES.map { |x| [x.sub('server', ''), x] }
|
[
|
||||||
|
['Hold', SERVER_HOLD],
|
||||||
|
# ['ManualInzone', SERVER_MANUAL_INZONE],
|
||||||
|
# [''],
|
||||||
|
# ['RenewProhibited', SERVER_RENEW_PROHIBITED],
|
||||||
|
# ['TransferProhibited', SERVER_TRANSFER_PROHIBITED],
|
||||||
|
# ['RegistrantChangeProhibited', SERVER_REGISTRANT_CHANGE_PROHIBITED],
|
||||||
|
# ['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED],
|
||||||
|
# ['TechChangeProhibited', SERVER_TECH_CHANGE_PROHIBITED],
|
||||||
|
# [''],
|
||||||
|
['UpdateProhibited', SERVER_UPDATE_PROHIBITED],
|
||||||
|
['DeleteProhibited', SERVER_DELETE_PROHIBITED]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def admin_not_deletable_statuses
|
||||||
|
[
|
||||||
|
OK,
|
||||||
|
INACTIVE,
|
||||||
|
FORCE_DELETE,
|
||||||
|
PENDING_CREATE,
|
||||||
|
PENDING_DELETE,
|
||||||
|
PENDING_RENEW,
|
||||||
|
PENDING_TRANSFER,
|
||||||
|
PENDING_UPDATE
|
||||||
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,12 @@
|
||||||
.col-md-8
|
.col-md-8
|
||||||
.tab-content{style:'margin-top: 20px;'}
|
.tab-content{style:'margin-top: 20px;'}
|
||||||
#general-tab.tab-pane.active
|
#general-tab.tab-pane.active
|
||||||
= render 'admin/contacts/form_partials/statuses', f: f
|
= render 'admin/shared/form/statuses', f: f,
|
||||||
|
model: 'contact',
|
||||||
|
admin_statuses_map: Contact.admin_statuses_map,
|
||||||
|
disabled_statuses: Contact::STATUSES - Contact.admin_statuses,
|
||||||
|
not_deletable_statuses: [Contact::OK, Contact::LINKED]
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-8.text-right
|
.col-md-8.text-right
|
||||||
= button_tag(t(:save), class: 'btn btn-primary')
|
= button_tag(t(:save), class: 'btn btn-primary')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- content_for :actions do
|
- content_for :actions do
|
||||||
= link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-contact-status')
|
= link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-status')
|
||||||
= link_to(t(:back_to_contact), [:admin, @contact], class: 'btn btn-default')
|
= link_to(t(:back_to_contact), [:admin, @contact], class: 'btn btn-default')
|
||||||
= render 'shared/title', name: "#{t(:edit)}: #{@contact.name}"
|
= render 'shared/title', name: "#{t(:edit)}: #{@contact.name}"
|
||||||
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
#js-contact-statuses
|
|
||||||
- f.object.statuses.each do |s|
|
|
||||||
- disabled = !Contact.admin_statuses.include?(s)
|
|
||||||
- disabled_style = disabled ? 'display: none' : ''
|
|
||||||
- delete_style = [Contact::OK, Contact::LINKED].include?(s) ? 'display: none' : ''
|
|
||||||
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading.clearfix
|
|
||||||
.pull-left= t(:status)
|
|
||||||
.pull-right
|
|
||||||
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs js-destroy-status', style: delete_style)
|
|
||||||
.panel-body
|
|
||||||
.form-group
|
|
||||||
= f.label 'status', class: 'col-md-2 control-label'
|
|
||||||
.col-md-10
|
|
||||||
.js-select{style: disabled_style}
|
|
||||||
= select_tag 'contact[statuses][]',
|
|
||||||
options_for_select(Contact::admin_statuses_map, s),
|
|
||||||
include_blank: true, class: "form-control"
|
|
||||||
- if disabled
|
|
||||||
.disabled-value.js-disabled-value
|
|
||||||
= s
|
|
||||||
= hidden_field_tag 'contact[statuses][]', s, readonly: true
|
|
||||||
.form-group
|
|
||||||
= label_tag t(:notes), nil, class: 'col-md-2 control-label'
|
|
||||||
.col-md-10
|
|
||||||
- value = f.object.new_record? ? '' : f.object.status_notes[s]
|
|
||||||
= text_field_tag 'contact[status_notes_array][]', value, class: 'form-control'
|
|
||||||
|
|
||||||
:coffee
|
|
||||||
$("#js-contact-statuses").nestedAttributes
|
|
||||||
bindAddTo: $(".js-add-contact-status")
|
|
||||||
afterAdd: (el) ->
|
|
||||||
if el.find('.js-disabled-value')
|
|
||||||
el.find('.js-disabled-value').remove()
|
|
||||||
el.find('.js-select').show()
|
|
||||||
el.find('.js-destroy-status').show()
|
|
||||||
|
|
||||||
$(document).on 'click', '.js-destroy-status', (e) ->
|
|
||||||
e.preventDefault()
|
|
||||||
$(this).parents('.panel').remove()
|
|
|
@ -6,7 +6,12 @@
|
||||||
.col-md-8
|
.col-md-8
|
||||||
.tab-content{style:'margin-top: 20px;'}
|
.tab-content{style:'margin-top: 20px;'}
|
||||||
#general-tab.tab-pane.active
|
#general-tab.tab-pane.active
|
||||||
= render 'admin/domains/form_partials/statuses', f: f
|
= render 'admin/shared/form/statuses', f: f,
|
||||||
|
model: 'domain',
|
||||||
|
admin_statuses_map: DomainStatus.admin_statuses_map,
|
||||||
|
disabled_statuses: DomainStatus::STATUSES - DomainStatus.admin_statuses,
|
||||||
|
not_deletable_statuses: DomainStatus.admin_not_deletable_statuses
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-8.text-right
|
.col-md-8.text-right
|
||||||
= button_tag(t(:save), class: 'btn btn-primary')
|
= button_tag(t(:save), class: 'btn btn-primary')
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#js-statuses
|
#js-statuses
|
||||||
- f.object.statuses.each do |s|
|
- f.object.statuses.each do |s|
|
||||||
- disabled = !DomainStatus::SERVER_STATUSES.include?(s)
|
- disabled = disabled_statuses.include?(s)
|
||||||
- disabled_style = disabled ? 'display: none' : ''
|
- disabled_style = disabled ? 'display: none' : ''
|
||||||
- delete_style = [DomainStatus::OK].include?(s) ? 'display: none' : ''
|
- delete_style = not_deletable_statuses.include?(s) ? 'display: none' : ''
|
||||||
|
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading.clearfix
|
.panel-heading.clearfix
|
||||||
|
@ -14,18 +14,18 @@
|
||||||
= f.label 'status', class: 'col-md-2 control-label'
|
= f.label 'status', class: 'col-md-2 control-label'
|
||||||
.col-md-10
|
.col-md-10
|
||||||
.js-select{style: disabled_style}
|
.js-select{style: disabled_style}
|
||||||
= select_tag 'domain[statuses][]',
|
= select_tag "#{model}[statuses][]",
|
||||||
options_for_select(DomainStatus.statuses_for_admin, s),
|
options_for_select(admin_statuses_map, s),
|
||||||
include_blank: true, class: "form-control"
|
include_blank: true, class: "form-control"
|
||||||
- if disabled
|
- if disabled
|
||||||
.disabled-value.js-disabled-value
|
.disabled-value.js-disabled-value
|
||||||
= s
|
= s
|
||||||
= hidden_field_tag 'domain[statuses][]', s, readonly: true
|
= hidden_field_tag "#{model}[statuses][]", s, readonly: true
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag t(:notes), nil, class: 'col-md-2 control-label'
|
= label_tag t(:notes), nil, class: 'col-md-2 control-label'
|
||||||
.col-md-10
|
.col-md-10
|
||||||
- value = f.object.new_record? ? '' : f.object.status_notes[s]
|
- value = f.object.new_record? ? '' : f.object.status_notes[s]
|
||||||
= text_field_tag 'domain[status_notes_array][]', value, class: 'form-control'
|
= text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control'
|
||||||
|
|
||||||
:coffee
|
:coffee
|
||||||
$("#js-statuses").nestedAttributes
|
$("#js-statuses").nestedAttributes
|
Loading…
Add table
Add a link
Reference in a new issue