Browse Source

Finish time entry delete JS/html

denney-fix-saving-dates
Jason Denney 11 years ago
parent
commit
5e0d678ea1
  1. 11
      app/assets/javascripts/time_entries.js
  2. 4
      app/models/time_entry.rb
  3. 3
      app/views/time_entries/index.haml

11
app/assets/javascripts/time_entries.js

@ -59,21 +59,18 @@ $(document).ready(function(){
}); });
$("#confirmation_delete").click(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({ $.ajax({
url: $("#confirmation_delete").data("url"), url: url,
type: "delete", type: "delete",
data: JSON.stringify(json_data),
contentType: 'application/json', contentType: 'application/json',
dataType: "json",
success: function(data, status, xhr){ success: function(data, status, xhr){
window.location = forward; location.reload();
}, },
error: function(data, status ){ error: function(data, status ){
displayFormErrors(data.responseJSON); displayFormErrors(data.responseJSON);
} }
}); });
*/
}); });
}); });

4
app/models/time_entry.rb

@ -20,4 +20,8 @@ class TimeEntry < ActsAsLoggable::Log
def duration_in_hours def duration_in_hours
(duration / 1.hour).round(2) (duration / 1.hour).round(2)
end end
def type
log_action.action
end
end end

3
app/views/time_entries/index.haml

@ -18,6 +18,7 @@
"data-start_date" => entry.start_date.to_date.to_formatted_s(:rfc822)} "data-start_date" => entry.start_date.to_date.to_formatted_s(:rfc822)}
%td #{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.duration_in_hours}
%td #{entry.type}
%td #{truncate(entry.description)} %td #{truncate(entry.description)}
%td %td
%button{ class: "btn icon-remove btn-danger work_entry-delete-btn", role: "button", "data-toggle" => "modal", "data-target" => "#confirmation" } %button{ class: "btn icon-remove btn-danger work_entry-delete-btn", role: "button", "data-toggle" => "modal", "data-target" => "#confirmation" }
@ -37,7 +38,7 @@
Description Description
.modal-footer .modal-footer
%button{ class: "btn", "data-dismiss" => "modal", "aria-hidden" => "true"} Close %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

Loading…
Cancel
Save