diff --git a/app/assets/javascripts/time_entries.js b/app/assets/javascripts/time_entries.js index 6fc3766..8fab897 100644 --- a/app/assets/javascripts/time_entries.js +++ b/app/assets/javascripts/time_entries.js @@ -59,21 +59,18 @@ $(document).ready(function(){ }); $("#confirmation_delete").click(function(){ - console.log($(this).data("entry_id")); - /** + entry_id = $(this).data("entry_id"); + url = $("#confirmation_delete").data("url") + entry_id; $.ajax({ - url: $("#confirmation_delete").data("url"), + url: url, type: "delete", - data: JSON.stringify(json_data), contentType: 'application/json', - dataType: "json", success: function(data, status, xhr){ - window.location = forward; + location.reload(); }, error: function(data, status ){ displayFormErrors(data.responseJSON); } }); - */ }); }); diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index aafea6a..f782c4e 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -20,4 +20,8 @@ class TimeEntry < ActsAsLoggable::Log def duration_in_hours (duration / 1.hour).round(2) end + + def type + log_action.action + end end diff --git a/app/views/time_entries/index.haml b/app/views/time_entries/index.haml index 608dc83..1875d17 100644 --- a/app/views/time_entries/index.haml +++ b/app/views/time_entries/index.haml @@ -18,6 +18,7 @@ "data-start_date" => entry.start_date.to_date.to_formatted_s(:rfc822)} %td #{entry.start_date.to_date.to_formatted_s(:rfc822)} %td #{entry.duration_in_hours} + %td #{entry.type} %td #{truncate(entry.description)} %td %button{ class: "btn icon-remove btn-danger work_entry-delete-btn", role: "button", "data-toggle" => "modal", "data-target" => "#confirmation" } @@ -37,7 +38,7 @@ Description .modal-footer %button{ class: "btn", "data-dismiss" => "modal", "aria-hidden" => "true"} Close - %button{ id: "confirmation_delete", class: "btn btn-primary" } Delete + %button{ id: "confirmation_delete", class: "btn btn-primary", "data-url" => "api/v1/time_entries/" } Delete