mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-30 19:02:34 +00:00
WIP
This commit is contained in:
parent
5b47c3e8eb
commit
bbcd70adc4
2 changed files with 76 additions and 12 deletions
|
@ -161,10 +161,15 @@ def save_settings(settings_items):
|
||||||
database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,))
|
database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Make sure that text based form values aren't pass as list
|
# Make sure that text based form values aren't pass as list unless they are language list
|
||||||
if isinstance(value, list) and len(value) == 1:
|
if isinstance(value, list) and len(value) == 1 and key not in ['settings-general-serie_default_language',
|
||||||
|
'settings-general-movie_default_language']:
|
||||||
value = value[0]
|
value = value[0]
|
||||||
|
|
||||||
|
# Make sure empty language list are stored correctly due to bug in bootstrap-select
|
||||||
|
if key in ['settings-general-serie_default_language', 'settings-general-movie_default_language'] and value == ['null']:
|
||||||
|
value = []
|
||||||
|
|
||||||
settings_keys = key.split('-')
|
settings_keys = key.split('-')
|
||||||
|
|
||||||
if value == 'true':
|
if value == 'true':
|
||||||
|
|
|
@ -63,9 +63,13 @@
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Series Default Settings</b>
|
<b>Series Default Settings</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-1">
|
||||||
|
<label class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="settings-general-serie_default_enabled" name="settings-general-serie_default_enabled">
|
||||||
|
<span class="custom-control-label" for="settings-general-serie_default_enabled"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
<div id="series_default_div">
|
<div id="series_default_div">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
|
@ -79,14 +83,24 @@
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Hearing-Impaired</b>
|
<b>Hearing-Impaired</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-1">
|
||||||
|
<label class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="settings-general-serie_default_hi" name="settings-general-serie_default_hi">
|
||||||
|
<span class="custom-control-label" for="settings-general-serie_default_hi"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Forced</b>
|
<b>Forced</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-8 pl-sm-0">
|
||||||
|
<select class="selectpicker" id="settings-general-serie_default_forced" name="settings-general-serie_default_forced">
|
||||||
|
<option value="False">False</option>
|
||||||
|
<option value="True">True</option>
|
||||||
|
<option value="Both">Both</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
@ -95,9 +109,13 @@
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Movies Default Settings</b>
|
<b>Movies Default Settings</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-1">
|
||||||
|
<label class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="settings-general-movie_default_enabled" name="settings-general-movie_default_enabled">
|
||||||
|
<span class="custom-control-label" for="settings-general-movie_default_enabled"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
<div id="movies_default_div">
|
<div id="movies_default_div">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
|
@ -111,14 +129,24 @@
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Hearing-Impaired</b>
|
<b>Hearing-Impaired</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-1">
|
||||||
|
<label class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="settings-general-movie_default_hi" name="settings-general-movie_default_hi">
|
||||||
|
<span class="custom-control-label" for="settings-general-movie_default_hi"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 text-right">
|
<div class="col-sm-3 text-right">
|
||||||
<b>Forced</b>
|
<b>Forced</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-8 pl-sm-0">
|
||||||
|
<select class="selectpicker" id="settings-general-movie_default_forced" name="settings-general-movie_default_forced">
|
||||||
|
<option value="False">False</option>
|
||||||
|
<option value="True">True</option>
|
||||||
|
<option value="Both">Both</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
@ -170,6 +198,8 @@
|
||||||
// Set Select input values
|
// Set Select input values
|
||||||
$('#settings-general-subfolder').val('{{settings.general.subfolder}}').trigger('change');
|
$('#settings-general-subfolder').val('{{settings.general.subfolder}}').trigger('change');
|
||||||
$('#settings-general-anti_captcha_provider').val('{{settings.general.anti_captcha_provider}}').trigger('change');
|
$('#settings-general-anti_captcha_provider').val('{{settings.general.anti_captcha_provider}}').trigger('change');
|
||||||
|
$('#settings-general-serie_default_forced').val('{{settings.general.serie_default_forced}}').trigger('change');
|
||||||
|
$('#settings-general-movie_default_forced').val('{{settings.general.movie_default_forced}}').trigger('change');
|
||||||
$('.selectpicker').selectpicker('refresh')
|
$('.selectpicker').selectpicker('refresh')
|
||||||
|
|
||||||
// Listen to single language checkbox change to adapt languages menus
|
// Listen to single language checkbox change to adapt languages menus
|
||||||
|
@ -185,12 +215,41 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide *_div on default-enabled change
|
||||||
|
$('#settings-general-serie_default_enabled').on('change', function() {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
$('#series_default_div').show();
|
||||||
|
} else {
|
||||||
|
$('#series_default_div').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#settings-general-movie_default_enabled').on('change', function() {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
$('#movies_default_div').show();
|
||||||
|
} else {
|
||||||
|
$('#movies_default_div').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Set Checkbox input values
|
// Set Checkbox input values
|
||||||
$('#settings-general-single_language').prop('checked', {{'true' if settings.general.getboolean('single_language') else 'false'}}).trigger('change');
|
$('#settings-general-single_language').prop('checked', {{'true' if settings.general.getboolean('single_language') else 'false'}}).trigger('change');
|
||||||
|
$('#settings-general-serie_default_enabled').prop('checked', {{'true' if settings.general.getboolean('serie_default_enabled') else 'false'}}).trigger('change');
|
||||||
|
$('#settings-general-serie_default_hi').prop('checked', {{'true' if settings.general.getboolean('serie_default_hi') else 'false'}}).trigger('change');
|
||||||
|
$('#settings-general-movie_default_enabled').prop('checked', {{'true' if settings.general.getboolean('movie_default_enabled') else 'false'}}).trigger('change');
|
||||||
|
$('#settings-general-movie_default_hi').prop('checked', {{'true' if settings.general.getboolean('movie_default_hi') else 'false'}}).trigger('change');
|
||||||
|
|
||||||
$('#save_button').on('click', function() {
|
$('#save_button').on('click', function() {
|
||||||
var formdata = new FormData(document.getElementById("settings_form"));
|
var formdata = new FormData(document.getElementById("settings_form"));
|
||||||
|
|
||||||
|
// Make sure empty default languages select are send (bug in bootstrap-select)
|
||||||
|
if (formdata.get('settings-general-serie_default_language') == null) {
|
||||||
|
formdata.append('settings-general-serie_default_language', null)
|
||||||
|
}
|
||||||
|
if (formdata.get('settings-general-movie_default_language') == null) {
|
||||||
|
formdata.append('settings-general-movie_default_language', null)
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure all checkbox input are sent with true/false value
|
// Make sure all checkbox input are sent with true/false value
|
||||||
$('input[type=checkbox]').each(function () {
|
$('input[type=checkbox]').each(function () {
|
||||||
formdata.set($(this).prop('id'), $(this).prop('checked'));
|
formdata.set($(this).prop('id'), $(this).prop('checked'));
|
||||||
|
|
Loading…
Reference in a new issue