From e2e2fbbdc6b26e00101f5d4d1b05c0d076c817c2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 26 Jan 2013 16:22:52 +0100 Subject: Add a bit of AJAX to remove the just deleted row in call_history#index --- app/views/call_histories/_index_core.html.haml | 61 ++++++++++++++------------ app/views/call_histories/destroy.js.erb | 1 + 2 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 app/views/call_histories/destroy.js.erb (limited to 'app/views') 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 -- cgit v1.2.3 From c7b119d19bb866630ce9b152b28308ae3487a77f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 26 Jan 2013 16:38:56 +0100 Subject: Added the trash icon. --- app/views/call_histories/_index_core.html.haml | 9 +++------ app/views/call_histories/destroy.js.erb | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'app/views') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 27c6d36..550f055 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -14,7 +14,7 @@ - for call_history in call_histories - 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}"} + %tr{:id => "call_history_id_#{call_history.id}_tr"} %td - if call_history.voicemail_message? .voicemail-message @@ -67,8 +67,5 @@ = 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 "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') - + = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' + \ No newline at end of file diff --git a/app/views/call_histories/destroy.js.erb b/app/views/call_histories/destroy.js.erb index 2d14ddb..d952c58 100644 --- a/app/views/call_histories/destroy.js.erb +++ b/app/views/call_histories/destroy.js.erb @@ -1 +1 @@ -$('#call_history_id_<%= @call_history.id %>').remove(); \ No newline at end of file +$('#call_history_id_<%= @call_history.id %>_tr').remove(); \ No newline at end of file -- cgit v1.2.3