mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
Admin contact statuses management #2477
This commit is contained in:
parent
1f85cec9ac
commit
601592aed1
23 changed files with 335 additions and 190 deletions
11
app/views/admin/contacts/_form.haml
Normal file
11
app/views/admin/contacts/_form.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
= form_for([:admin, contact], html: { class: 'form-horizontal' }) do |f|
|
||||
.errors
|
||||
= render 'shared/errors', object: contact
|
||||
.row
|
||||
.col-md-8
|
||||
.tab-content{style:'margin-top: 20px;'}
|
||||
#general-tab.tab-pane.active
|
||||
= render 'admin/contacts/form_partials/statuses', f: f
|
||||
.row
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
6
app/views/admin/contacts/edit.haml
Normal file
6
app/views/admin/contacts/edit.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-contact-status')
|
||||
= link_to(t(:back_to_contact), [:admin, @contact], class: 'btn btn-default')
|
||||
= render 'shared/title', name: "#{t(:edit)}: #{@contact.name}"
|
||||
|
||||
= render 'form', contact: @contact
|
41
app/views/admin/contacts/form_partials/_statuses.haml
Normal file
41
app/views/admin/contacts/form_partials/_statuses.haml
Normal file
|
@ -0,0 +1,41 @@
|
|||
#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()
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
%br
|
||||
|
||||
|
||||
%dt= t(:ident)
|
||||
%dd= ident_for(@contact)
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:status)
|
||||
%th{class: 'col-xs-6'}= t(:description)
|
||||
%th{class: 'col-xs-6'}= t(:notes)
|
||||
%tbody
|
||||
- contact.statuses.each do |s|
|
||||
- contact.statuses.each do |status|
|
||||
%tr
|
||||
%td= s.value
|
||||
%td= s.description
|
||||
%td= status
|
||||
%td= contact.status_notes[status]
|
||||
|
||||
- if contact.errors.messages[:statuses]
|
||||
%tfoot
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:edit_statuses), edit_admin_contact_path(@contact), class: 'btn btn-primary')
|
||||
= render 'shared/title', name: @contact.name
|
||||
|
||||
.row
|
||||
|
|
|
@ -10,7 +10,3 @@
|
|||
.row
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
||||
|
||||
:coffee
|
||||
$ ->
|
||||
$("#tabs a:first").tab "show"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue