mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +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
|
||||
|
||||
class << self
|
||||
def statuses_for_client
|
||||
CLIENT_STATUSES.map { |x| x.sub('client', '') }
|
||||
def admin_statuses
|
||||
[
|
||||
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
|
||||
|
||||
def statuses_for_admin
|
||||
SERVER_STATUSES.map { |x| [x.sub('server', ''), x] }
|
||||
def admin_statuses_map
|
||||
[
|
||||
['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
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
.col-md-8
|
||||
.tab-content{style:'margin-top: 20px;'}
|
||||
#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
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- 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')
|
||||
= 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
|
||||
.tab-content{style:'margin-top: 20px;'}
|
||||
#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
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#js-statuses
|
||||
- f.object.statuses.each do |s|
|
||||
- disabled = !DomainStatus::SERVER_STATUSES.include?(s)
|
||||
- disabled = disabled_statuses.include?(s)
|
||||
- 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-heading.clearfix
|
||||
|
@ -14,18 +14,18 @@
|
|||
= f.label 'status', class: 'col-md-2 control-label'
|
||||
.col-md-10
|
||||
.js-select{style: disabled_style}
|
||||
= select_tag 'domain[statuses][]',
|
||||
options_for_select(DomainStatus.statuses_for_admin, s),
|
||||
= select_tag "#{model}[statuses][]",
|
||||
options_for_select(admin_statuses_map, s),
|
||||
include_blank: true, class: "form-control"
|
||||
- if disabled
|
||||
.disabled-value.js-disabled-value
|
||||
= s
|
||||
= hidden_field_tag 'domain[statuses][]', s, readonly: true
|
||||
= hidden_field_tag "#{model}[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 'domain[status_notes_array][]', value, class: 'form-control'
|
||||
= text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control'
|
||||
|
||||
:coffee
|
||||
$("#js-statuses").nestedAttributes
|
Loading…
Add table
Add a link
Reference in a new issue