internetee-registry/app/views/admin/shared/form/_statuses.haml

44 lines
1.8 KiB
Text

#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
- if model == 'domain'
= render 'admin/domains/form/pending_update', f: f, status: s
= render 'admin/domains/form/pending_delete', f: f, status: s
= 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()