finish first prototype
This commit is contained in:
parent
7bf67f151c
commit
2e658de219
@ -139,17 +139,16 @@ function render_response(td, set) {
|
||||
|
||||
// save/update global settings
|
||||
function save_settings() {
|
||||
settings['circulation'] = $('#circulation').val();
|
||||
let found_on = $('#found_on').val();
|
||||
if (found_on) {
|
||||
settings['found_on'] = found_on;
|
||||
} else {
|
||||
settings['found_on'] = get_datetime();
|
||||
}
|
||||
|
||||
let found_by = $('#found_by option[selected=selected]').html();
|
||||
if (found_by) {
|
||||
settings['found_by'] = found_by;
|
||||
}
|
||||
if (found_by) { settings['found_by'] = found_by; }
|
||||
|
||||
let found_on = $('#found_on').val();
|
||||
settings['found_on'] = (found_on) ? found_on : get_datetime();
|
||||
|
||||
let circulation = $('#circulation').val();
|
||||
if (circulation) { settings['circulation'] = circulation; }
|
||||
|
||||
let checkboxes = $('#found, #buy_only, #checked, #ec, #exists').map(function() {
|
||||
return { [$(this).prop('id')]: $(this).prop('checked') }
|
||||
}).get();
|
||||
@ -190,9 +189,8 @@ $(document).ready(function() {
|
||||
let circulation = (settings['circulation'] == 'Auflage') ? 0 : settings['circulation'];
|
||||
|
||||
// TODO it would be nicer if #circulation, #found_by and #found_on would have no value while #exists is checked. then this would also not be neccessary
|
||||
if (settings['exists'] === false) {
|
||||
circulation = 0;
|
||||
}
|
||||
if (settings['exists'] === false) { circulation = 0; }
|
||||
|
||||
let data = {
|
||||
csrfmiddlewaretoken: csrf_token,
|
||||
value: value,
|
||||
@ -239,6 +237,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
@ -256,6 +255,11 @@ $(document).ready(function() {
|
||||
// save settings
|
||||
save_settings();
|
||||
|
||||
// remove values
|
||||
$('#found_by, #found_on, #circulation').each(function() {
|
||||
$(this).val('');
|
||||
});
|
||||
|
||||
// disable settings
|
||||
$('#found, #buy_only, #checked, #ec').each(function() {
|
||||
$(this).prop('checked', false);
|
||||
@ -267,9 +271,12 @@ $(document).ready(function() {
|
||||
// checkbox #exists not checked
|
||||
} else {
|
||||
|
||||
// restore values
|
||||
$('#found_by').val(settings['found_by']);
|
||||
$('#found_on').val(settings['found_on']);
|
||||
$('#circulation').val(settings['circulation']);
|
||||
|
||||
// restore settings
|
||||
// $('#circulation').val(settings['circulation']);
|
||||
// $('#found_on').val(settings['found_on']);
|
||||
$('#found_now, #found, #buy_only, #checked, #ec').each(function() {
|
||||
let setting = $(this).prop('id');
|
||||
$(this).prop('checked', settings[setting]);
|
||||
@ -325,7 +332,6 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// detect ESC keypress
|
||||
$(document).keypress(function(event) {
|
||||
if (event.keyCode == 27) { // ESC is pressed
|
||||
@ -334,7 +340,6 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// button #close_modal_add_user
|
||||
$('#close_modal_add_user').click(function() {
|
||||
hide_modal();
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user