SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit a6d4f0b7 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add dynamic pickers for changing stream props

parent 97cffd9b
No related branches found
No related tags found
1 merge request!43Polish up new production page
Showing
with 540 additions and 113 deletions
{% comment %} Only show something if the option is about to change {% endcomment %}
{% if not current_option == new_option %}
{% comment %} If selected option is None, it is being removed {% endcomment %}
{% if new_option == "None" %}
<button type="submit" class="btn btn-danger">
Remove
</button>
{% comment %} Otherwise differentiate between changing or adding based on current option {% endcomment %}
{% else %}
<button type="submit" class="btn btn-primary">
{% if current_option == "None" %}
Add
{% else %}
Change
{% endif %}
</button>
{% endif %}
{% endif %}
{% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.invitations_officer.choices|length > 0 %}
<div id="productionstream-update-invitations_officer">
<form hx-post="{% url 'production:update_invitations_officer' stream.id %}" hx-target="#productionstream-update-invitations_officer" hx-swap="outerHTML" class="row">
{% csrf_token %}
<div class="col">
{{form|bootstrap_purely_inline}}
</div>
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'invitations_officer' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="change from:select#id_invitations_officer" hx-target="this">
</div>
<div class="text-primary">{{message}}</div>
</form>
</div>
{% endif %}
\ No newline at end of file
{% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.officer.choices|length > 0 %}
<div id="productionstream-update-officer">
<form hx-post="{% url 'production:update_officer' stream.id %}" hx-target="#productionstream-update-officer" hx-swap="outerHTML" class="row">
{% csrf_token %}
<div class="col">
{{form|bootstrap_purely_inline}}
</div>
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'officer' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="change from:select#id_officer" hx-target="this">
</div>
<div class="text-primary">{{message}}</div>
</form>
</div>
{% endif %}
\ No newline at end of file
{% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.status.choices|length > 0 %}
<div id="productionstream-update-status">
<form hx-post="{% url 'production:update_status' stream.id %}" hx-target="#productionstream-update-status" hx-swap="outerHTML" class="row">
{% csrf_token %}
<div class="col">
{{form|bootstrap_purely_inline}}
</div>
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'status' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="load, change from:select#id_status" hx-target="this">
</div>
<div class="text-primary">{{message}}</div>
</form>
</div>
{% endif %}
\ No newline at end of file
{% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.supervisor.choices|length > 0 %}
<div id="productionstream-update-supervisor">
<form hx-post="{% url 'production:update_supervisor' stream.id %}" hx-target="#productionstream-update-supervisor" hx-swap="outerHTML" class="row">
{% csrf_token %}
<div class="col">
{{form|bootstrap_purely_inline}}
</div>
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'supervisor' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="load, change from:select#id_supervisor" hx-target="this">
</div>
<div class="text-primary">{{message}}</div>
</form>
</div>
{% endif %}
\ No newline at end of file
{% load guardian_tags %}
{% get_obj_perms request.user for productionstream as "sub_perms" %}
<p> <p>
<strong class="text-warning">While the new production page is being built</strong>: go the the <a href="{{ productionstream.get_absolute_url }}" target="_blank">(old) stream detail page</a> to manage this stream. <strong class="text-warning">While the new production page is being built</strong>: go the the <a href="{{ productionstream.get_absolute_url }}" target="_blank">(old) stream detail page</a> to manage this stream.
</p> </p>
<div class="row overflow-hidden" style="height: min(50vh, 40em)">
<div class="col-lg-6">
<h3>Actions</h3>
{% if "can_perform_supervisory_actions" in sub_perms %}
<div class="container">
<h4>Change:</h4>
<div class="border-primary border-start ps-2">
{% include "production/_hx_productionstream_change_status.html" with form=status_form stream=productionstream %}
{% include "production/_hx_productionstream_change_supervisor.html" with form=supervisor_form stream=productionstream %}
{% include "production/_hx_productionstream_change_prodofficer.html" with form=prod_officer_form stream=productionstream %}
{% include "production/_hx_productionstream_change_invofficer.html" with form=inv_officer_form stream=productionstream %}
</div>
</div>
{% endif %}
<ul>
<li>Worklog</li>
<li>Completed</li>
<li>Upload proofs</li>
<li>Accessibility</li>
<li>Send Proofs</li>
</ul>
</div>
<h3>Events</h3> <div id="productionstream-{{ productionstream.id }}-event-container"
{% include 'production/_productionstream_events.html' with productionstream=productionstream events=productionstream.events.all_without_duration %} class="col-lg-6 h-100 overflow-scroll">
<h3>Events</h3>
{% include "production/_productionstream_events.html" with productionstream=productionstream events=productionstream.events.all_without_duration %}
<button <div id="productionstream-{{ productionstream.id }}-event-new-comment-form">
hx-get="{% url 'production:_hx_event_form' productionstream_id=productionstream.id %}" <button hx-get="{% url 'production:_hx_event_form' productionstream_id=productionstream.id %}"
hx-target="#productionstream-{{ productionstream.id }}-event-form" hx-target="#productionstream-{{ productionstream.id }}-event-new-comment-form"
hx-trigger="click" hx-trigger="click"
> hx-swap="outerHTML">Add a comment to this stream</button>
Add a comment to this stream </div>
</button> </div>
<div id="productionstream-{{ productionstream.id }}-event-form"></div> </div>
{% load bootstrap %} {% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.status.choices|length > 0 %} {% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.status.choices|length > 0 %}
<h3>Change current stream status:</h3> <form method="post" action="{% url 'production:update_status' stream.id %}" class="row">
<form method="post" action="{% url 'production:update_status' stream.id %}" class="form-inline">
{% csrf_token %} {% csrf_token %}
{{ form|bootstrap_inline }} {{ form|bootstrap_purely_inline }}
<div class="form-group row"> <div class="col-auto">
<div class="col-form-label col ms-2"> <button type="submit" class="btn btn-primary">Change</button>
<button type="submit" class="btn btn-primary">Change</button>
</div>
</div> </div>
</form> </form>
{% endif %} {% endif %}
...@@ -71,7 +71,6 @@ urlpatterns = [ ...@@ -71,7 +71,6 @@ urlpatterns = [
production_views.delete_officer, production_views.delete_officer,
name="delete_officer", name="delete_officer",
), ),
# streams
path( path(
"streams/<int:stream_id>/", "streams/<int:stream_id>/",
include( include(
...@@ -122,37 +121,82 @@ urlpatterns = [ ...@@ -122,37 +121,82 @@ urlpatterns = [
), ),
path("events/add", production_views.add_event, name="add_event"), path("events/add", production_views.add_event, name="add_event"),
path("logs/add", production_views.add_work_log, name="add_work_log"), path("logs/add", production_views.add_work_log, name="add_work_log"),
path("officer/add", production_views.add_officer, name="add_officer"),
path( path(
"officer/<int:officer_id>/remove", "officer",
production_views.remove_officer, include(
name="remove_officer", [
), path(
path( "add",
"invitations_officer/add", production_views.add_officer,
production_views.add_invitations_officer, name="add_officer",
name="add_invitations_officer", ),
), path(
path( "<int:officer_id>/remove",
"invitations_officer/<int:officer_id>/remove", production_views.remove_officer,
production_views.remove_invitations_officer, name="remove_officer",
name="remove_invitations_officer", ),
path(
"update",
production_views.update_officer,
name="update_officer",
),
]
),
), ),
path( path(
"supervisor/add", "invitations_officer",
production_views.add_supervisor, include(
name="add_supervisor", [
path(
"add",
production_views.add_invitations_officer,
name="add_invitations_officer",
),
path(
"<int:officer_id>/remove",
production_views.remove_invitations_officer,
name="remove_invitations_officer",
),
path(
"update",
production_views.update_invitations_officer,
name="update_invitations_officer",
),
]
),
), ),
path( path(
"supervisor/<int:officer_id>/remove", "supervisor",
production_views.remove_supervisor, include(
name="remove_supervisor", [
path(
"add",
production_views.add_supervisor,
name="add_supervisor",
),
path(
"<int:officer_id>/remove",
production_views.remove_supervisor,
name="remove_supervisor",
),
path(
"update",
production_views.update_supervisor,
name="update_supervisor",
),
]
),
), ),
path( path(
"mark_completed", "mark_completed",
production_views.mark_as_completed, production_views.mark_as_completed,
name="mark_as_completed", name="mark_as_completed",
), ),
path(
"render_action_buttons/<str:key>",
production_views.render_action_buttons,
name="render_action_buttons",
),
] ]
), ),
), ),
......
This diff is collapsed.
...@@ -60,6 +60,19 @@ def bootstrap_inline(element, args="2,10"): ...@@ -60,6 +60,19 @@ def bootstrap_inline(element, args="2,10"):
return render(element, markup_classes) return render(element, markup_classes)
@register.filter
def bootstrap_purely_inline(element, args="2,10"):
args = [arg.strip() for arg in args.split(",")]
markup_classes = {
"label": "col-auto fs-6",
"value": "col",
"single_value": "",
}
markup_classes["form_control"] = ""
return render(element, markup_classes)
@register.filter @register.filter
def bootstrap_grouped(element, args="2,10"): def bootstrap_grouped(element, args="2,10"):
return bootstrap(element, args, "grouped") return bootstrap(element, args, "grouped")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment