summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-26 16:22:52 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-26 16:22:52 +0100
commite2e2fbbdc6b26e00101f5d4d1b05c0d076c817c2 (patch)
tree9bcee822e17e416dbf012f180d0abcdd309b6c51 /app/views
parentaf4a02e15a02481e23f9458ae0a430ec52c57417 (diff)
Add a bit of AJAX to remove the just deleted row in call_history#index
Diffstat (limited to 'app/views')
-rw-r--r--app/views/call_histories/_index_core.html.haml61
-rw-r--r--app/views/call_histories/destroy.js.erb1
2 files changed, 33 insertions, 29 deletions
diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml
index 4ebcad0..27c6d36 100644
--- a/app/views/call_histories/_index_core.html.haml
+++ b/app/views/call_histories/_index_core.html.haml
@@ -12,33 +12,35 @@
%tbody
- for call_history in call_histories
- - phone_number = call_history.display_number
- - voicemail_message = call_history.voicemail_message
- - if phone_number
- - phone_book_entry = call_history.phone_book_entry_by_number(phone_number)
- %tr
+ - if !call_history.display_number.blank?
+ - phone_book_entry = call_history.phone_book_entry_by_number(call_history.display_number)
+ %tr{:id => "call_history_id_#{call_history.id}"}
%td
- - if voicemail_message
+ - if call_history.voicemail_message?
.voicemail-message
- %a{:href => sip_account_voicemail_messages_path(@sip_account, :anchor => "message_#{voicemail_message.id}")}
- = image_tag('icons/gs_envelope_16x.png', :class => 'display')
+ %a{:href => sip_account_voicemail_messages_path(@sip_account, :anchor => "message_#{call_history.voicemail_message.id}")}
+ = image_tag('icons/gs_envelope_16x.png')
= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
- - elsif call_history.entry_type == 'forwarded'
- .call-forwarded= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
- - if call_history.callee_account_type.to_s.downcase == 'voicemail'
- = t("call_histories.index.voicemail")
- - else
- = call_history.destination_number
- - elsif call_history.entry_type == 'dialed'
- .call-placed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
- - elsif call_history.entry_type == 'received'
- .call-received= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
- - elsif call_history.entry_type == 'missed'
- .call-missed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
- - else
- .call-unknown
- = t("call_histories.index.#{call_history.entry_type}")
- = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+
+ - else
+ - case call_history.entry_type
+ - when 'forwarded'
+ .call-forwarded= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+ - if call_history.callee_account_type.to_s.downcase == 'voicemail'
+ = t("call_histories.index.voicemail")
+ - else
+ = call_history.destination_number
+ - when 'dialed'
+ .call-placed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+ - when 'received'
+ .call-received= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+ - when 'missed'
+ .call-missed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+ - else
+ .call-unknown
+ = t("call_histories.index.#{call_history.entry_type}")
+ = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format"))
+
- if call_history.forwarding_service && call_history.entry_type != 'forwarded'
= t("call_histories.index.forwarded_by")
= call_history.display_auth_account_name
@@ -54,7 +56,7 @@
%a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name
- else
.name= display_name
- .phone= phone_number
+ .phone= call_history.display_number
%td
- if call_history.display_duration
.duration= call_history.display_duration
@@ -65,7 +67,8 @@
= link_to t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put
%td
- if can? :destroy, call_history
- / = link_to t('call_histories.index.actions.destroy'), sip_account_call_history_path(@sip_account, call_history), :method => :delete
- %a.btn.btn-mini.btn-danger{"data-confirm" => t("#{call_history.class.name.underscore.pluralize}.actions.confirm_destroy"), "data-method" => "delete", :href => sip_account_call_history_path(@sip_account, call_history), :rel => "nofollow"}
- %i.icon-trash.icon-white
- =t('call_histories.index.actions.destroy')
+ = link_to "remove", [@sip_account, call_history], :method => :delete, :remote => true
+ / %a.btn.btn-mini.btn-danger{"data-confirm" => t("#{call_history.class.name.underscore.pluralize}.index.actions.confirm_destroy"), "data-method" => "delete", :href => sip_account_call_history_path(@sip_account, call_history), :rel => "nofollow", remote: true}
+ / %i.icon-trash.icon-white
+ / =t('call_histories.index.actions.destroy')
+
diff --git a/app/views/call_histories/destroy.js.erb b/app/views/call_histories/destroy.js.erb
new file mode 100644
index 0000000..2d14ddb
--- /dev/null
+++ b/app/views/call_histories/destroy.js.erb
@@ -0,0 +1 @@
+$('#call_history_id_<%= @call_history.id %>').remove(); \ No newline at end of file