Add preview when creating tickets
This commit is contained in:
parent
4fc244d3ea
commit
5a123a5872
|
@ -205,3 +205,15 @@ select.form-control {
|
|||
max-height: 250px;
|
||||
}
|
||||
}
|
||||
|
||||
.ticket-preview {
|
||||
border: 1px dashed black;
|
||||
padding: 0.5rem;
|
||||
margin: 1rem 0;
|
||||
|
||||
.preview-tag {
|
||||
float: right;
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ from flask import Blueprint, render_template, request, url_for, abort, redirect
|
|||
from todosrht.color import color_from_hex, color_to_hex, get_text_color
|
||||
from todosrht.color import valid_hex_color_code
|
||||
from todosrht.access import get_tracker
|
||||
from todosrht.filters import render_markup
|
||||
from todosrht.search import apply_search
|
||||
from todosrht.tickets import get_last_seen_times, get_comment_counts
|
||||
from todosrht.tickets import get_participant_for_user, submit_ticket
|
||||
|
@ -190,6 +191,11 @@ def tracker_submit_POST(owner, name):
|
|||
db.session.commit() # Unlock tracker row
|
||||
return return_tracker(tracker, access, **valid.kwargs), 400
|
||||
|
||||
if "preview" in request.form:
|
||||
preview = render_markup(tracker, desc)
|
||||
return return_tracker(tracker, access,
|
||||
rendered_preview=preview, **valid.kwargs), 200
|
||||
|
||||
# TODO: Handle unique constraint failure (contention) and retry?
|
||||
participant = get_participant_for_user(current_user)
|
||||
ticket = submit_ticket(tracker, participant, title, desc)
|
||||
|
|
|
@ -113,6 +113,9 @@
|
|||
>
|
||||
Submit {{icon("caret-right")}}
|
||||
</button>
|
||||
<button type="submit" name="preview" class="btn btn-default">
|
||||
Preview {{icon("caret-right")}}
|
||||
</button>
|
||||
<label class="form-check-label" style="margin-left: 2rem">
|
||||
<input
|
||||
class="form-check-input"
|
||||
|
@ -124,6 +127,15 @@
|
|||
{% endif %}> Submit another?
|
||||
</label>
|
||||
</form>
|
||||
|
||||
{% if rendered_preview %}
|
||||
<div class="ticket-preview">
|
||||
<span class="preview-tag">Ticket preview</span>
|
||||
<h2>{{ title }}</h2>
|
||||
{{ rendered_preview }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% elif cfg("todo.sr.ht::mail", "posting-domain") %}
|
||||
<a
|
||||
class="btn btn-primary"
|
||||
|
|
Loading…
Reference in New Issue