Skip to content

Commit

Permalink
WIP merging frontends
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan committed Sep 13, 2024
1 parent f65388b commit 3c671f5
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 48 deletions.
26 changes: 25 additions & 1 deletion app/blueprints/fund_builder/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def section(round_id):
}
if request.args.get("action") == "remove":
update_section(request.args.get("section_id"), {"round_id": None}) # TODO remove properly
return redirect(url_for("build_fund_bp.configure_round", round_id=round_id, _method="POST", code=307))
return redirect(url_for("build_fund_bp.view_app_config", round_id=round_id))
if form.validate_on_submit():
round = get_round_by_id(form.round_id.data)
count_existing_sections = len(round.sections)
Expand Down Expand Up @@ -308,6 +308,30 @@ def view_all_questions(round_id):
return render_template("view_questions.html", round=round, fund=fund, question_html=html)


@build_fund_bp.route("/fund/round/<round_id>/all_questions/<form_id>", methods=["GET"])
def view_form_questions(round_id, form_id):
"""
Generates the form data for this form, then uses that to generate the 'All Questions'
data for that form and returns that to render in a template.
"""
round = get_round_by_id(round_id)
fund = get_fund_by_id(round.fund_id)
form = get_form_by_id(form_id=form_id)
section_data = [
{
"section_title": f"Preview of form [{form.name_in_apply_json['en']}]",
"forms": [{"name": form.runner_publish_name, "form_data": build_form_json(form)}],
}
]

print_data = generate_print_data_for_sections(
section_data,
lang="en",
)
html = print_html(print_data)
return render_template("view_questions.html", round=round, fund=fund, question_html=html)


@build_fund_bp.route("/create_export_files/<round_id>", methods=["GET"])
def create_export_files(round_id):
generate_form_jsons_for_round(round_id)
Expand Down
89 changes: 42 additions & 47 deletions app/blueprints/fund_builder/templates/view_application_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,52 @@ <h2 class="govuk-heading-m">{{ fund.short_name }} - {{ round.short_name }}</h2>
</div>
{{ govukButton({
"text": "View All Questions",
"href": url_for("build_fund_bp.view_all_questions", round_id=round.round_id),
"classes": "govuk-button--secondary"
"href": url_for("build_fund_bp.view_all_questions", round_id=round.round_id) ,
"classes": "govuk-button--secondary"
})
}}
{{ govukButton({
"text": "Create export files for round",
"href": url_for("build_fund_bp.create_export_files", round_id=round.round_id),
"classes": "govuk-button--secondary"
"href": url_for("build_fund_bp.create_export_files", round_id=round.round_id) ,
"classes": "govuk-button--secondary"
})
}}
{% for section in round.sections %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h3 class="govuk-heading-s">{{ section.index }}. {{ section.name_in_apply_json["en"] }}</h3>
{% for form in section.forms %}
<h4 class="govuk-heading-s">Form {{ form.section_index }}. {{ form.name_in_apply_json["en"] }}</h4>
{{ govukButton({
"text": "Preview Form",
"href": url_for("build_fund_bp.preview_form", form_id=form.form_id),
"classes": "govuk-button--secondary"
})
}}
{{ govukButton({
"text": "Download JSON",
"href": url_for("build_fund_bp.download_form_json", form_id=form.form_id),
"classes": "govuk-button--secondary"
})
}}
{% for page in form.pages %}
<div class="section_page">
<span class="govuk-body">{{ page.form_index }}. {{ page.name_in_apply_json["en"] }}</span>
<ul class="govuk-list--bullet">
{% for component in page.components %}
{% set list_details %}

{% if component.lizt != None %}
[
{%for item in component.lizt.items %}
{{item.text}},
{% endfor %}
]
{% endif %}
{% endset %}
<li class="govuk-body">{{ component.page_index }} - {{ component.title }} ({{ component.type.value }}{{list_details}})</li>
{% endfor %}
</ul>
</div>
<ol class="app-task-list">
{% for section in round.sections %}
<li>
<h2 class="app-task-list__section">{{ section.index }}. {{ section.name_in_apply_json["en"] }}</h2>
{{ govukButton({
"text": "Remove",
"href": url_for("build_fund_bp.section",round_id=round.round_id, section_id=section.section_id, action="remove") ,
"classes": "govuk-button--warning"
}) }}
<ul class="app-task-list__items">
{% for form in section.forms %}
<li class="app-task-list__item task-list__new-design">
<span class="app-task-list__task-name">
<a class="govuk-body govuk-link govuk-link--no-visited-state" href="{{url_for('build_fund_bp.view_form_questions', round_id=round.round_id, form_id=form.form_id)}}">{{ section.index }}.&nbsp;{{ form.section_index }}.&nbsp;{{ form.name_in_apply_json["en"] }}</a>
</span>
<span class="app-task-list__task-actions">
{{ govukButton({
"text": "Download JSON",
"href": url_for("build_fund_bp.download_form_json", form_id=form.form_id) ,
"classes": "govuk-button--secondary"
}) }}
{{ govukButton({
"text": "Preview",
"href": url_for("build_fund_bp.preview_form", form_id=form.form_id) ,
"classes": "govuk-button--secondary"
}) }}
<form
method="post"
action="{{ url_for('build_fund_bp.configure_forms_in_section', round_id=round.round_id, section_id=section.section_id, form_id=form.form_id, action='remove') }}">
{{ govukButton({"text": "Remove", "classes": "govuk-button--warning"}) }}
</form>
</span>
</li>
{% endfor %}
{% endfor %}
</div>
</div>
{% endfor %}
<style>div.section_page{padding-left: 15px;}</style>
{% endblock content %}
</li>
{% endfor %}
</ol>

{% endblock content %}
61 changes: 61 additions & 0 deletions app/static/src/styles/fab.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.app-task-list {
list-style-type: none;
padding-left: 0;
margin-top: 0;
margin-bottom: 0;
}

.app-task-list__section {
display: table;
font-family: "GDS Transport", arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-weight: 700;
font-size: 18px;
font-size: 1.125rem;
line-height: 1.1111111111;
}

.app-task-list__items {
font-family: "GDS Transport", arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-weight: 400;
font-size: 16px;
font-size: 1rem;
line-height: 1.25;
margin-bottom: 40px;
list-style: none;
padding-left: 0;
}

.app-task-list__item {
border-bottom: 1px solid #b1b4b6;
margin-bottom: 0 !important;
padding-top: 10px;
padding-bottom: 10px;
}

.app-task-list__item:after {
content: "";
display: block;
clear: both;
}

.app-task-list__item:first-child {
border-top: 1px solid #b1b4b6;
}

.app-task-list__task-name {
display: inline;
}

.app-task-list__task-actions {
float: right;
margin-top: 0;
margin-bottom: 0;
}

.app-task-list__task-actions form {
display: inline;
}
3 changes: 3 additions & 0 deletions app/templates/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<link rel="stylesheet" type="text/css"
href="{{ url_for('static', filename='govuk-frontend/govuk-frontend-5.4.0.min.css') }}" /><!--<![endif]-->

<link rel="stylesheet" type="text/css"
href="{{ url_for('static', filename='styles/fab.css') }}" />


<!-- jsDelivr :: Sortable :: Latest (https://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
1 change: 1 addition & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def build_govuk_assets(static_dist_root="app/static/dist"):

# Copy css
os.makedirs("./app/static/dist/styles")
shutil.copyfile("./app/static/src/styles/fab.css", "./app/static/dist/styles/fab.css")

# Copy over JS source
os.makedirs("./app/static/dist/js")
Expand Down

0 comments on commit 3c671f5

Please sign in to comment.