Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Enhancement: Dynamic Select Form #13

Merged
merged 43 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e70fae9
on branch dynamic-form, switch to dev server for feature enhancement
zshafiqu Mar 22, 2020
b295435
update bootstrap design with new page
zshafiqu Mar 22, 2020
82e29ee
add placeholder select groups in place of form inputs
zshafiqu Mar 22, 2020
61d7c02
remove unneeded imports
zshafiqu Mar 22, 2020
a4ff536
form update
zshafiqu Mar 22, 2020
77eb06d
update requirements .txt with flask_wtf amd wtforms
zshafiqu Mar 22, 2020
c209133
more updates
zshafiqu Mar 22, 2020
dc37c8e
honing in on the form stuff. just adding a commit for good measure
zshafiqu Mar 23, 2020
867c730
add list comprehension for flaskform tuple
zshafiqu Mar 24, 2020
cf76895
removed old form options
zshafiqu Mar 24, 2020
7dd961d
form values added
zshafiqu Mar 24, 2020
2352a95
list comprehension works on tuples for year range in flask form
zshafiqu Mar 24, 2020
f3f6197
create new function called get_table_name(), and retrieve table names…
zshafiqu Mar 24, 2020
7afac96
clean up report() code by removing unneeded stuff
zshafiqu Mar 24, 2020
ae7b478
successfully returning form data via POST
zshafiqu Mar 24, 2020
c4d6b5c
get distinct makes route created under makes/<year>/
zshafiqu Mar 24, 2020
52afa3f
add fetch() API script to report page to grab all distinct makes for …
zshafiqu Mar 24, 2020
8423fb8
script added to detect onchange for make and update corresponding value
zshafiqu Mar 24, 2020
56335c4
add style to form selectors using Jinja class_ declarator
zshafiqu Mar 24, 2020
69d6aed
add model selector
zshafiqu Mar 24, 2020
670ce35
report code cleanup
zshafiqu Mar 24, 2020
f704468
more updates'
zshafiqu Mar 24, 2020
9b52297
updated report endpoint
zshafiqu Mar 24, 2020
79f6693
report method has all three selectors populating, now just need to ad…
zshafiqu Mar 24, 2020
ca5380b
more code cleanup
zshafiqu Mar 24, 2020
4017fa5
make select on change works, just need to refactor it so it updates m…
zshafiqu Mar 24, 2020
d3e8004
fixed an out of scope error
zshafiqu Mar 24, 2020
9d43ac9
works, just need to figure out error for when you switch years to whe…
zshafiqu Mar 25, 2020
71c09f0
Resolved prior issue by calling the updateModel() method again on a r…
zshafiqu Mar 25, 2020
d097ce5
finished with scripts
zshafiqu Mar 25, 2020
b3ddf80
more updates to server
zshafiqu Mar 25, 2020
deb6a81
code cleanup
zshafiqu Mar 25, 2020
5ebffe3
omitting view_report route as we now allow report route to accept bot…
zshafiqu Mar 25, 2020
3818047
FOUND ANOTHER ISSUE - if you update year, the make defaults to acura,…
zshafiqu Mar 25, 2020
18ac61a
turn off autocomplete on select fields using flask-jinja syntaxing
zshafiqu Mar 25, 2020
38a43f0
resolved issue of models not updating by adding a 250 millisecond del…
zshafiqu Mar 25, 2020
7442256
various template and server updates
zshafiqu Mar 25, 2020
4663e25
add interface update to changelog
zshafiqu Mar 25, 2020
6330718
add API update since we
zshafiqu Mar 25, 2020
83ace1e
wrapped report() load code with while loop to help avoid database con…
zshafiqu Mar 25, 2020
b0fb9e4
more updates to changelog
zshafiqu Mar 25, 2020
b6fd004
updated README to reflect new changes
zshafiqu Mar 25, 2020
1a75695
swap to production server
zshafiqu Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
script added to detect onchange for make and update corresponding value
  • Loading branch information
zshafiqu committed Mar 24, 2020
commit 8423fb8403dd7022287a47fdf0d8ee3f2743aa0e
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ def get_distinct_makes_for_year(year):

for row in results:
make_object = dict()
make_object['name'] = row[0]
make_object['value'] = row[0]
make_object['label'] = row[0]
make_list.append(make_object)

return jsonify({'Makes' : make_list})
return jsonify({'makes' : make_list})
# ----------------------
@app.route('/view_report', methods=['POST'])
def handle_request():
Expand Down
13 changes: 10 additions & 3 deletions templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ <h2 class="text-info">Vehicle Report</h2>
year_select.onchange = function() {
// Retrieve value
year = year_select.value;

// Use fetch() API to access predefined flask route
// Use fetch() API to access predefined flask route [similar concept to AJAX]
fetch('/makes/'+year).then(function(response) {
// parse response as JSON and return data
response.json().then(function(data) {
console.table(data)
// use string builder to make new HTML objects for the given make
let makes_HTML = '';
// Loop over JSON object, the outermost key was set as 'makes'in flask route
for (let make of data.makes) {
makes_HTML += '<option value="'+ make.value + '">' + make.label + '</option>';
}
// overwrite the old HTML
make_select.innerHTML = makes_HTML;
});
});
}

</script>
{% endblock content %}