Commit 9a330cb1 authored by Oliver Feldt's avatar Oliver Feldt
Browse files

Fixed bug not being able to return radios via scan

parent 3395be5f
......@@ -62,9 +62,10 @@ $("#search_form").on("submit", function(e) {
$.getJSON(
"/radios",
$(this).serialize(),
function (data) {
var radio = data.radio;
var checkouts = data.checkouts;
function (response) {
var radio = response.radio;
var checkouts = response.checkouts;
var angel = response.angel;
if (radio.id === null) {
$("#new_radio_form input[name='radio_id']").val(radio.name);
$("#new_radio").modal("show");
......@@ -78,7 +79,7 @@ $("#search_form").on("submit", function(e) {
$("#radio_form input[name='radio_id']").val(radio.name);
$("#radios tr[data-id='"+ radio.id +"']").data("last_scanned_at", new Date());
if (radio.angel === undefined) {
if (angel === null) {
$("#radio_form button[name='return']").addClass("disabled");
} else {
$("#radio_form button[name='return']").removeClass("disabled");
......
......@@ -58,7 +58,9 @@ module CCC
@radio.save
end
json radio: @radio, checkouts: @radio.checkouts.all
checkouts = @radio.checkouts.all
angel = checkouts.last && !checkouts.last.checked_in_at ? checkouts.last.angel : nil
json(radio: @radio, checkouts: checkouts, angel: angel)
end
get "/checkouts" do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment