mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +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
41
app/views/admin/shared/form/_statuses.haml
Normal file
41
app/views/admin/shared/form/_statuses.haml
Normal file
|
@ -0,0 +1,41 @@
|
|||
#js-statuses
|
||||
- f.object.statuses.each do |s|
|
||||
- disabled = disabled_statuses.include?(s)
|
||||
- disabled_style = disabled ? 'display: none' : ''
|
||||
- delete_style = not_deletable_statuses.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 "#{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 "#{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 "#{model}[status_notes_array][]", value, class: 'form-control'
|
||||
|
||||
:coffee
|
||||
$("#js-statuses").nestedAttributes
|
||||
bindAddTo: $(".js-add-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()
|
Loading…
Add table
Add a link
Reference in a new issue