fixed bug where insert cset did not show it in menu until a full reload

This commit is contained in:
2026-02-11 12:02:09 +11:00
parent f0fee15548
commit b8c1edc084
3 changed files with 19 additions and 13 deletions

4
BUGS
View File

@@ -1,7 +1,3 @@
* Add a cset, and it does not appear in the compare_to menu until another reload
- main.py:119 -- need insert_cset to return id, name, and the 200 success,
and then the jscript can insert the option into the select
* with future bills - recalculate bills button blows away growth! * with future bills - recalculate bills button blows away growth!
- BUT, I think just loading the bills page puts it back -- need to validate and fix if so - BUT, I think just loading the bills page puts it back -- need to validate and fix if so

View File

@@ -117,8 +117,9 @@ def index():
@app.route('/save', methods=['POST']) @app.route('/save', methods=['POST'])
def save(): def save():
insert_cset( request.get_json() ) cset_id=insert_cset( request.get_json() )
return "200" name = request.get_json()['vars']['name']
return jsonify( cset_id=cset_id, name=name )
@app.route('/update', methods=['POST']) @app.route('/update', methods=['POST'])
def update(): def update():

View File

@@ -230,7 +230,12 @@
$(function() { $('[data-bs-toggle="popover"]').popover(); }); $(function() { $('[data-bs-toggle="popover"]').popover(); });
window.onload = function() { window.onload = function() {
$('#Sell_shares').val( {{finance['Sell_shares']}} ) $('#Sell_shares').val( {{finance['Sell_shares']}} )
{% if finance['compare_to'] %}
$('#compare_to').val( {{finance['compare_to']}} ) $('#compare_to').val( {{finance['compare_to']}} )
{% else %}
// set this to Nothing by default
$('#compare_to').val( 0 )
{% endif %}
$('#Ioniq6_future').val( {{finance['Ioniq6_future']}} ) $('#Ioniq6_future').val( {{finance['Ioniq6_future']}} )
if( $("#Ioniq6_future option:selected"). text() == 'lease' ) if( $("#Ioniq6_future option:selected"). text() == 'lease' )
@@ -440,7 +445,11 @@
url: '/save', url: '/save',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify({ 'vars': vars, 'savings_data': savingsData }), data: JSON.stringify({ 'vars': vars, 'savings_data': savingsData }),
success: function() { $('#save_modal').modal('hide'); } } )" success: function(resp) {
$('#save_modal').modal('hide');
$('#compare_to').append($('<option>', { value: resp.cset_id, text: resp.name }));
}
});"
>Save</button> >Save</button>
</div> </div>
</div> </div>