Files

29 lines
1.9 KiB
HTML

<section id="workout-note-{{ workout_id }}" class="workout-card workout-note-card"
hx-target="this" hx-swap="outerHTML">
{% if is_edit|default(false) %}
<form class="workout-note-editor"
hx-put="{{ url_for('notes.update_workout_note', person_id=person_id, workout_id=workout_id, view='session') }}"
hx-disabled-elt="find button"
_="on htmx:responseError remove .hidden from #note-error-{{ workout_id }}">
<label for="session-note-input-{{ workout_id }}">Session notes</label>
<textarea id="session-note-input-{{ workout_id }}" name="note" rows="5"
placeholder="Cues, energy, how it felt…"
_="init call me.focus() end">{{ note or '' }}</textarea>
<p id="note-error-{{ workout_id }}" class="workout-editor-error hidden" role="alert">Could not save your note. Please try again.</p>
<div class="workout-editor-actions">
<button type="button" class="workout-button"
hx-get="{{ url_for('notes.get_workout_note', person_id=person_id, workout_id=workout_id, view='session') }}">Cancel</button>
<button type="submit" class="workout-add-button">Save note</button>
</div>
</form>
{% else %}
<button type="button" class="workout-note-trigger"
hx-get="{{ url_for('notes.get_workout_note_edit_form', person_id=person_id, workout_id=workout_id, view='session') }}"
aria-label="{{ 'Edit session notes' if note else 'Add session notes' }}">
<span class="workout-inline-heading">Session notes <span class="workout-inline-action">{{ 'Edit' if note else '+ Add' }}</span></span>
{% if note %}<span class="workout-note-preview">{% for line in note.split('\n') %}{{ line }}{% if not loop.last %}<br>{% endif %}{% endfor %}</span>
{% else %}<span class="workout-subtle">Cues, energy, how it felt</span>{% endif %}
</button>
{% endif %}
</section>