|
Lines 1937-1972
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1937 |
bundle_form_active = item_id; |
1937 |
bundle_form_active = item_id; |
| 1938 |
}); |
1938 |
}); |
| 1939 |
|
1939 |
|
| 1940 |
$("#addToBundleForm").submit(function(event) { |
1940 |
function addToBundle (url, data) { |
| 1941 |
|
|
|
| 1942 |
/* stop form from submitting normally */ |
| 1943 |
event.preventDefault(); |
| 1944 |
|
| 1945 |
/* get the action attribute from the <form action=""> element */ |
| 1946 |
var $form = $(this), |
| 1947 |
url = $form.attr('action'); |
| 1948 |
|
| 1949 |
/* Send the data using post with external_id */ |
1941 |
/* Send the data using post with external_id */ |
| 1950 |
var posting = $.post({ |
1942 |
var posting = $.post({ |
| 1951 |
url: url, |
1943 |
url: url, |
| 1952 |
data: JSON.stringify({ external_id: $('#external_id').val()}), |
1944 |
data: JSON.stringify(data), |
| 1953 |
contentType: "application/json; charset=utf-8", |
1945 |
contentType: "application/json; charset=utf-8", |
| 1954 |
dataType: "json" |
1946 |
dataType: "json" |
| 1955 |
}); |
1947 |
}); |
| 1956 |
|
1948 |
|
|
|
1949 |
const barcode = data.external_id; |
| 1950 |
|
| 1957 |
/* Report the results */ |
1951 |
/* Report the results */ |
| 1958 |
posting.done(function(data) { |
1952 |
posting.done(function(data) { |
| 1959 |
var barcode = $('#external_id').val(); |
|
|
| 1960 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">'+_("Success: Added '%s'").format(barcode)+'</div>'); |
1953 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-success">'+_("Success: Added '%s'").format(barcode)+'</div>'); |
| 1961 |
$('#external_id').val('').focus(); |
1954 |
$('#external_id').val('').focus(); |
| 1962 |
bundle_changed = 1; |
1955 |
bundle_changed = 1; |
| 1963 |
}); |
1956 |
}); |
| 1964 |
posting.fail(function(data) { |
1957 |
posting.fail(function(data) { |
| 1965 |
var barcode = $('#external_id').val(); |
|
|
| 1966 |
if ( data.status === 409 ) { |
1958 |
if ( data.status === 409 ) { |
| 1967 |
var response = data.responseJSON; |
1959 |
var response = data.responseJSON; |
| 1968 |
if ( response.key === "PRIMARY" ) { |
1960 |
if ( response.key === "PRIMARY" ) { |
| 1969 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>'); |
1961 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>'); |
|
|
1962 |
} else if (response.key === 'checked_out') { |
| 1963 |
const button = $('<button type="button">') |
| 1964 |
.addClass('btn btn-xs') |
| 1965 |
.text(__('Check in and add to bundle')) |
| 1966 |
.on('click', function () { |
| 1967 |
addToBundle(url, { external_id: barcode, force_checkin: true }); |
| 1968 |
}); |
| 1969 |
$('#addResult') |
| 1970 |
.empty() |
| 1971 |
.attr('class', 'alert alert-warning') |
| 1972 |
.append(__x('Warning: Item {barcode} is checked out', { barcode })) |
| 1973 |
.append(' ', button); |
| 1974 |
} else if (response.key === 'failed_checkin') { |
| 1975 |
$('#addResult') |
| 1976 |
.empty() |
| 1977 |
.attr('class', 'alert alert-danger') |
| 1978 |
.append(__x('Failure: Item {barcode} cannot be checked in', { barcode })) |
| 1970 |
} else { |
1979 |
} else { |
| 1971 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>'); |
1980 |
$('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' belongs to another bundle").format(barcode)+'</div>'); |
| 1972 |
} |
1981 |
} |
|
Lines 1984-1989
Note that permanent location is a code, and location may be an authval.
Link Here
|
| 1984 |
} |
1993 |
} |
| 1985 |
$('#external_id').val('').focus(); |
1994 |
$('#external_id').val('').focus(); |
| 1986 |
}); |
1995 |
}); |
|
|
1996 |
} |
| 1997 |
|
| 1998 |
$("#addToBundleForm").submit(function(event) { |
| 1999 |
/* stop form from submitting normally */ |
| 2000 |
event.preventDefault(); |
| 2001 |
|
| 2002 |
const url = this.action; |
| 2003 |
const data = { external_id: this.elements.external_id.value }; |
| 2004 |
|
| 2005 |
addToBundle(url, data); |
| 1987 |
}); |
2006 |
}); |
| 1988 |
|
2007 |
|
| 1989 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |
2008 |
$("#addToBundleModal").on("hidden.bs.modal", function(e){ |