open-law/app/templates/book/qa_view.html

240 lines
16 KiB
HTML
Raw Normal View History

2023-05-05 16:51:55 +00:00
<!-- prettier-ignore -->
{% extends 'base.html' %}
2023-06-02 08:22:24 +00:00
{% block title %}{{ section.label[:32] }}{% endblock %}
2023-05-15 09:14:49 +00:00
2023-06-02 08:22:24 +00:00
{% block content %}
2023-05-15 09:14:49 +00:00
{% if current_user.is_authenticated %}
2023-06-02 08:22:24 +00:00
{% include 'book/modals/delete_comment_modal.html' %}
{% include 'book/modals/edit_comment_modal.html' %}
{% block right_sidebar %}
{% endblock %}
2023-05-15 09:14:49 +00:00
{% endif %}
{% include 'book/breadcrumbs_navigation.html'%}
2023-06-13 12:39:13 +00:00
<div class="mt-5 h-auto overflow-x-hidden">
<div class="ql-snow mt-20">
<h1
class="text-l font-extrabold dark:text-white p-4 break-words text-justify">
2023-05-18 12:37:55 +00:00
{{ section.label }}
</h1>
2023-05-22 11:44:12 +00:00
<div class="ql-editor-readonly text-lg dark:text-white p-3">
{{display_inline_elements(interpretation.text)|safe}}
2023-05-22 11:44:12 +00:00
</div>
</div>
2023-06-13 12:39:13 +00:00
<div class="text-sm dark:text-white p-3">Comments</div>
2023-06-13 12:39:13 +00:00
{% if not interpretation.copy_of %}
<div>
<!-- prettier-ignore -->
{% if not current_user.is_authenticated %}
<div
class="bg-white dark:bg-gray-900 max-w-full p-6 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3 truncate">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
Connect you wallet to start contributing!
</h3>
2023-05-15 09:14:49 +00:00
</div>
</div>
</div>
{% endif %} {% if current_user.is_authenticated %}
<form
action="{{ url_for('book.create_comment', book_id=book.id, interpretation_id=interpretation.id) }}"
method="post"
class="prevent-submit-on-enter flex flex-col bg-white dark:bg-gray-900 max-w-full p-3 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 my-3 md:m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
{{ form_hidden_tag() }}
<div class="relative z-0 w-full group">
<div class="mb-2">
<input type="hidden" name="text" id="comment-text-input" />
<div
class="w-full max-w-6xl mx-auto rounded-xl bg-gray-50 dark:bg-gray-600 shadow-lg text-white-900">
<div
class="overflow-hidden rounded-md bg-gray-50 [&>*]:dark:bg-gray-600 text-black [&>*]:!border-none [&>*]:!stroke-black dark:text-white dark:[&>*]:!stroke-white">
2023-05-22 11:44:12 +00:00
<div
id="comment-text"
class="quill-editor dark:text-white h-40"></div>
2023-05-22 11:44:12 +00:00
</div>
2023-05-17 09:07:41 +00:00
</div>
</div>
</div>
2023-05-17 09:07:41 +00:00
<!-- prettier-ignore -->
<button type="submit" class="ml-auto text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"> Leave comment </button>
</form>
{% endif %}
</div>
2023-06-01 04:57:31 +00:00
<!-- prettier-ignore -->
<dl class="w-md md:w-full text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700">
2023-06-13 12:39:13 +00:00
{% set access_to_delete_comment = has_permission(section, Access.D, EntityType.COMMENT) %}
{% set access_to_approve_comment = has_permission(section, Access.A, EntityType.COMMENT) %}
2023-05-10 12:07:07 +00:00
<!-- prettier-ignore -->
2023-06-13 12:39:13 +00:00
{% for comment in interpretation.comments if not comment.is_deleted and not comment.parent_id %}
<!-- prettier-ignore -->
<dl class="bg-white dark:bg-gray-900 max-w-full p-3 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 my-3 md:m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
<div class="flex flex-row pb-3 md:p-3 md:w-full">
<div class="vote-block flex flex-col mt-5 ml-1 mr-2 md:m-5 md:mr-8 md:justify-center items-center">
2023-05-10 12:07:07 +00:00
2023-06-13 12:39:13 +00:00
<div class="vote-button cursor-pointer" data-vote-for="comment" data-entity-id="{{ comment.id }}" data-positive="true">
<svg class="w-6 h-6 select-none {% if comment.current_user_vote %} stroke-green-500 {% endif %} " xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" > <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" /> </svg>
</div>
<span class="vote-count text-3xl select-none {% if comment.vote_count < 0 %} text-red-500 {% elif comment.vote_count > 0 %} text-green-500 {% endif %} " >
{{ comment.vote_count }}
</span>
<div class="vote-button cursor-pointer" data-vote-for="comment" data-entity-id="{{ comment.id }}" data-positive="false">
<svg class="w-6 h-6 select-none {% if comment.current_user_vote == False %} stroke-red-500 {% endif %} " xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3" /> </svg>
</div>
2023-05-10 12:07:07 +00:00
2023-05-11 15:02:14 +00:00
2023-06-13 12:39:13 +00:00
{% if access_to_approve_comment %}
<div class="approve-button select-none approve-btn mt-3 cursor-pointer" data-approve="comment" data-entity-id="{{ comment.id }}">
<!-- outline -->
<svg class="not-approved-icon w-6 h-6 {% if comment.approved %} hidden {% endif %}" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
2023-05-11 15:02:14 +00:00
2023-06-13 12:39:13 +00:00
<!-- solid -->
<svg class="approved-icon w-6 h-6 {% if not comment.approved %} hidden {% endif %}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" />
</svg>
2023-05-22 11:44:12 +00:00
</div>
2023-06-13 12:39:13 +00:00
{% endif %}
2023-05-10 12:07:07 +00:00
</div>
2023-06-13 12:39:13 +00:00
<!-- prettier-ignore -->
<dt class="flex justify-center w-full mb-1 text-gray-500 md:text-lg dark:text-gray-400 flex-col">
2023-05-22 11:44:12 +00:00
<div>
2023-06-13 12:39:13 +00:00
<div class="dark:text-white h-30">
<div class="ql-snow mb-2">
<div class="dark:text-white h-30 ql-editor-readonly !px-0">
<p>{{ display_inline_elements(comment.text)|safe }}</p>
</div>
</div>
</div>
2023-05-22 11:44:12 +00:00
</div>
2023-06-13 12:39:13 +00:00
<div id="accordion-collapse" data-accordion="collapse" class="flex border-t-2 pt-3 mt-6 align-center justify-between space-x-3">
<div>
Commented by
<span class="text-blue-500">{{comment.user.username}}</span>
on {{comment.created_at.strftime('%B %d, %Y')}}
{% if comment.edited %}
<i class="text-green-200"> edited</i>
{% endif %}
</div>
<div class="flex ml-auto justify-end space-x-2 w-24">
{% if comment.user_id == current_user.id %}
<div class="relative">
<button id="edit_comment_btn" data-popover-target="popover-edit" data-edit-comment-id="{{comment.id}}" data-edit-comment-text="{{comment.text}}" type="button" data-modal-target="edit_comment_modal" data-modal-toggle="edit_comment_modal" class="space-x-0.5 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" /> </svg>
</button>
<div data-popover id="popover-edit" role="tooltip" class="absolute z-10 invisible inline-block w-64 text-sm text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 dark:text-gray-400 dark:border-gray-600 dark:bg-gray-800">
<div class="px-3 py-2">
<p>Edit this comment</p>
</div>
<div data-popper-arrow></div>
</div>
</div>
{% endif %}
{% if comment.user_id == current_user.id or access_to_delete_comment %}
<div class="relative">
<button id="delete_comment_btn" data-popover-target="popover-delete" data-comment-id="{{comment.id}}" type="button" data-modal-target="delete_comment_modal" data-modal-toggle="delete_comment_modal" class="space-x-0.5 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /> </svg>
</button>
<div data-popover id="popover-delete" role="tooltip" class="absolute z-10 invisible inline-block w-64 text-sm text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 dark:text-gray-400 dark:border-gray-600 dark:bg-gray-800">
<div class="px-3 py-2">
<p>Delete this comment</p>
</div>
<div data-popper-arrow></div>
</div>
</div>
{% endif %}
2023-06-01 04:57:31 +00:00
<div class="relative">
2023-06-13 12:39:13 +00:00
<button type="button" data-popover-target="popover-comment" data-accordion-target="#accordion-collapse-body-{{loop.index}}" aria-expanded="false" aria-controls="accordion-collapse-body-1" class="relative space-x-0.5 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" /> </svg>
2023-06-01 04:57:31 +00:00
</button>
2023-06-13 12:39:13 +00:00
<div data-popover id="popover-comment" role="tooltip" class="absolute z-10 invisible inline-block w-64 text-sm text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 dark:text-gray-400 dark:border-gray-600 dark:bg-gray-800">
2023-06-01 04:57:31 +00:00
<div class="px-3 py-2">
2023-06-13 12:39:13 +00:00
<p>Comment to this comment</p>
2023-06-01 04:57:31 +00:00
</div>
2023-05-10 12:07:07 +00:00
</div>
2023-05-08 14:33:15 +00:00
</div>
2023-06-13 12:39:13 +00:00
</div>
</div>
</dt>
</div>
<div class="md:p-5 md:m-3 border-none">
2023-06-13 12:39:13 +00:00
{% for child in comment.children if not child.is_deleted %}
<div class="p-2 md:p-5 mb-2 flex justify-between items-end bg-slate-100 dark:bg-slate-600 rounded-lg">
<div class="ql-snow w-full">
2023-06-13 12:39:13 +00:00
<div class="inline-block mb-4 ql-editor-readonly !p-0">
{{display_inline_elements(child.text)|safe}}
</div>
<span class="flex justify-between w-full border-t-2 border-white pt-2">
2023-06-13 12:39:13 +00:00
<div>
by
<span class="text-blue-500">
{{child.user.username}}
</span>
{{child.created_at.strftime('%B %d, %Y')}}
</div>
{% if child.user_id == current_user.id %}
<div class="relative ml-2">
<button id="delete_comment_btn" data-popover-target="popover-delete" data-comment-id="{{child.id}}" type="button" data-modal-target="delete_comment_modal" data-modal-toggle="delete_comment_modal" class="space-x-0.5 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /> </svg>
</button>
<div data-popover id="popover-delete" role="tooltip" class="absolute z-10 invisible inline-block w-64 text-sm text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 dark:text-gray-400 dark:border-gray-600 dark:bg-gray-800">
<div class="px-3 py-2">
<p>Delete this comment</p>
</div>
<div data-popper-arrow></div>
</div>
</div>
{% endif %}
2023-06-13 12:39:13 +00:00
</span>
</div>
2023-05-22 11:44:12 +00:00
</div>
2023-06-13 12:39:13 +00:00
{% endfor %}
</div>
<div id="accordion-collapse-body-{{loop.index}}" class="hidden" aria-labelledby="accordion-collapse-heading-1">
<div class="p-1 md:p-5 border-t border-gray-200 dark:border-gray-700 dark:bg-gray-900">
2023-05-22 11:44:12 +00:00
<form
2023-05-30 07:12:43 +00:00
action="{{ url_for('book.create_comment', book_id=book.id, interpretation_id=interpretation.id) }}"
2023-05-22 11:44:12 +00:00
method="post"
class="prevent-submit-on-enter flex flex-col bg-white dark:bg-gray-900 max-w-full p-1 md:p-3 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 md:m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700"
2023-05-22 11:44:12 +00:00
>
{{ form_hidden_tag() }}
<input type="hidden" name="parent_id" id="parent_id" value="{{comment.id}}" />
<div class="relative z-0 w-full group border-none">
2023-05-22 11:44:12 +00:00
<div class="mb-2">
<label for="tags-input" class="p-2 block mb-2 text-sm font-medium text-gray-900 dark:text-white">
2023-05-22 11:44:12 +00:00
Comment
</label>
<input type="hidden" name="text" id="sub-comment-{{loop.index}}-text-input"/>
<div class="w-full max-w-6xl mx-auto rounded-xl bg-gray-50 dark:bg-gray-600 shadow-lg text-white-900">
<div class="overflow-hidden rounded-md bg-gray-50 [&>*]:dark:bg-gray-600 text-black [&>*]:!border-none [&>*]:!stroke-black dark:text-white dark:[&>*]:!stroke-white">
<div id="sub-comment-{{loop.index}}-text" class="quill-editor dark:text-white h-40"></div>
</div>
</div>
</div>
</div>
<!-- prettier-ignore -->
<button type="submit" class="ml-auto text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"> Leave comment </button>
</form>
2023-06-13 12:39:13 +00:00
</div>
2023-05-22 11:44:12 +00:00
</div>
2023-06-13 12:39:13 +00:00
</dl>
{% endfor %}
</dl>
{% endif %}
2023-05-05 16:51:55 +00:00
</div>
2023-05-08 12:19:22 +00:00
2023-05-05 16:51:55 +00:00
<!-- prettier-ignore -->
{% endblock %}