From 102795211ec11edf30c7a5f1bd33d0c9f718ba40 Mon Sep 17 00:00:00 2001 From: Kostiantyn Stoliarskyi Date: Fri, 19 May 2023 14:29:42 +0300 Subject: [PATCH] work fix scrolls and need to resolve url adding from a --- app/models/collection.py | 2 +- app/static/css/styles.css | 29 +++++ app/templates/book/collection_view.html | 150 +++++++++++++++++------- app/views/book.py | 7 +- app/views/book/collection.py | 14 +-- app/views/book/section.py | 4 +- 6 files changed, 147 insertions(+), 59 deletions(-) diff --git a/app/models/collection.py b/app/models/collection.py index 2c8d11a..39c6313 100644 --- a/app/models/collection.py +++ b/app/models/collection.py @@ -22,7 +22,7 @@ class Collection(BaseModel): "Collection", backref=db.backref("parent", remote_side=[id]), viewonly=True, - order_by="desc(Collection.id)", + order_by="asc(Collection.id)", ) sections = db.relationship("Section") diff --git a/app/static/css/styles.css b/app/static/css/styles.css index 36ef4b6..0eae315 100644 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -1221,6 +1221,11 @@ input:checked + .toggle-bg { margin-bottom: auto; } +.my-3 { + margin-top: 0.75rem; + margin-bottom: 0.75rem; +} + .-mb-px { margin-bottom: -1px; } @@ -1353,6 +1358,14 @@ input:checked + .toggle-bg { margin-top: auto; } +.mt-\[135\] { + margin-top: 135; +} + +.box-border { + box-sizing: border-box; +} + .block { display: block; } @@ -1833,10 +1846,18 @@ input:checked + .toggle-bg { align-self: center; } +.overflow-auto { + overflow: auto; +} + .overflow-hidden { overflow: hidden; } +.overflow-scroll { + overflow: scroll; +} + .overflow-x-auto { overflow-x: auto; } @@ -1853,6 +1874,10 @@ input:checked + .toggle-bg { overflow-x: scroll; } +.overflow-y-scroll { + overflow-y: scroll; +} + .truncate { overflow: hidden; text-overflow: ellipsis; @@ -2295,6 +2320,10 @@ input:checked + .toggle-bg { padding-top: 1.5rem; } +.pt-\[135\] { + padding-top: 135; +} + .text-left { text-align: left; } diff --git a/app/templates/book/collection_view.html b/app/templates/book/collection_view.html index 985e6bf..28235b6 100644 --- a/app/templates/book/collection_view.html +++ b/app/templates/book/collection_view.html @@ -14,11 +14,11 @@ {% block content %} -
+
+ class="p-3 w-2/6 border-t border-r border-gray-200 dark:border-gray-700 overflow-y-scroll h-box">
@@ -52,6 +52,7 @@
{% endfor %}
-
+

Created by {{book.owner.username}} on {{book.created_at.strftime('%B %d, %Y')}}. Last updated on {{book.created_at.strftime('%B %d, %Y')}}

{{book.label}}

-

{% if book.about==None %}About text{% else %}{{book.about}}{% endif %}

{% for collection in book.versions[-1].children_collections if not collection.is_root and not collection.is_deleted %} -

#{{collection.label}}

+

#{{collection.label}}

+ {% if not collection.is_leaf and not collection.children %} +

Collection is empty

+ {% endif %} {% if not collection.is_leaf %} {% for sub_collection in collection.children if not sub_collection.is_deleted%} -

##{{sub_collection.label}}

+

##{{sub_collection.label}}

+ {% if not sub_collection.active_sections %} +

This sub collection is empty

+ {% endif %} {% for section in sub_collection.active_sections %}
- -

{{ section.label }}

+ +

{{ section.label }}

{% if not section.active_interpretations %}

This section is empty

{% else %}
-
-

{{ section.approved_interpretation.text|safe }}

-
+
+

{{ section.approved_interpretation.text|safe }}

-
- Interpretation by {{section.approved_interpretation}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}} +
+
+ Interpretation by {{section.approved_interpretation.user.username}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}}
-
-

-

- {% endfor %} {% endfor %} {% else %} {% for section in collection.active_sections %} - -

{{ section.label }}

+ +

{{ section.label }}

{% if not section.active_interpretations %}

This section is empty

{% else %} -
+

{{ section.approved_interpretation.text|safe }}

- Interpretation by {{section.approved_interpretation.user.username}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}} + Interpretation by {{section.approved_interpretation.user.username}} on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}}
+ + {% if not section.approved_comments %} +
+

No comments for current section

+
+ {% else %} +
+

+ +

+ +
+ {% endif %} {% endif %} {% endfor %} {% endif %} diff --git a/app/views/book.py b/app/views/book.py index a97a773..049103a 100644 --- a/app/views/book.py +++ b/app/views/book.py @@ -512,7 +512,8 @@ def collection_create(book_id: int, collection_id: int | None = None): flash("Success!", "success") if collection_id: redirect_url = url_for( - "book.sub_collection_view", book_id=book_id, collection_id=collection_id + "book.collection_view", + book_id=book_id, ) return redirect(redirect_url) else: @@ -583,10 +584,8 @@ def collection_edit( flash("Success!", "success") if sub_collection_id: redirect_url = url_for( - "book.section_view", + "book.collection_view", book_id=book_id, - collection_id=collection_id, - sub_collection_id=sub_collection_id, ) return redirect(redirect_url) else: diff --git a/app/views/book/collection.py b/app/views/book/collection.py index 02a5d2d..6d3e868 100644 --- a/app/views/book/collection.py +++ b/app/views/book/collection.py @@ -124,9 +124,7 @@ def collection_create(book_id: int, collection_id: int | None = None): flash("Success!", "success") if collection_id: - redirect_url = url_for( - "book.sub_collection_view", book_id=book_id, collection_id=collection_id - ) + redirect_url = url_for("book.collection_view", book_id=book_id) return redirect(redirect_url) else: log(log.ERROR, "Collection/Subcollection create errors: [%s]", form.errors) @@ -153,9 +151,8 @@ def collection_edit( form = f.EditCollectionForm() redirect_url = url_for( - "book.sub_collection_view", + "book.collection_view", book_id=book_id, - collection_id=collection_id, ) if form.validate_on_submit(): @@ -195,12 +192,7 @@ def collection_edit( flash("Success!", "success") if sub_collection_id: - redirect_url = url_for( - "book.section_view", - book_id=book_id, - collection_id=collection_id, - sub_collection_id=sub_collection_id, - ) + redirect_url = url_for(redirect_url) return redirect(redirect_url) else: log(log.ERROR, "Collection edit errors: [%s]", form.errors) diff --git a/app/views/book/section.py b/app/views/book/section.py index 42648b5..ca362b7 100644 --- a/app/views/book/section.py +++ b/app/views/book/section.py @@ -94,10 +94,8 @@ def section_create( redirect_url = url_for("book.collection_view", book_id=book_id) if collection_id: redirect_url = url_for( - "book.section_view", + "book.collection_view", book_id=book_id, - collection_id=collection_id, - sub_collection_id=sub_collection_id, ) form = f.CreateSectionForm()