mirror of https://github.com/logos-co/open-law.git
dnd after refactor
This commit is contained in:
parent
67ff1e360d
commit
4e80a653fe
File diff suppressed because one or more lines are too long
148645
app/static/js/main.js
148645
app/static/js/main.js
File diff suppressed because one or more lines are too long
|
@ -13,3 +13,10 @@
|
|||
* @copyright Chen, Yi-Cyuan 2015-2018
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/**!
|
||||
* Sortable 1.15.0
|
||||
* @author RubaXa <trash@rubaxa.org>
|
||||
* @author owenm <owen23355@gmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<a id="accordion-collapse-heading-{{collection.id}}" class=" text-black dark:text-white ">
|
||||
<form id="rename-collection-label-form-{{collection.id}}" data-book-id='{{book.id}}' data-collection-id="{{collection.id}}" method="post" class="mb-0">
|
||||
{{ form_hidden_tag() }}
|
||||
<input class=" bg-inherit border-none " value="{{collection.label}}" type="text" name="label" id="edit-collection-label-{{collection.id}}" placeholder="Collection label" required readonly/>
|
||||
<input class=" bg-inherit border-none " value="{{collection.label}}/{{collection.id}}" type="text" name="label" id="edit-collection-label-{{collection.id}}" placeholder="Collection label" required readonly/>
|
||||
<button name="submit" type="submit"></button>
|
||||
</form>
|
||||
</a>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="">
|
||||
<div class="flex flex-col ml-6">
|
||||
<button
|
||||
type="button"
|
||||
href="#section-{{section.label}}"
|
||||
id="section-heading-{{section.id}}"
|
||||
class="text-gray-500 dark:text-gray-400">
|
||||
class="text-gray-500 dark:text-gray-400 w-max">
|
||||
<!-- prettier-ignore -->
|
||||
<form
|
||||
id="rename-section-label-form-{{section.id}}"
|
||||
|
@ -13,11 +13,12 @@
|
|||
data-sub-collection-id="{{sub_collection.id}}"
|
||||
{% endif %}
|
||||
data-section-id="{{section.id}}"
|
||||
method="post">
|
||||
method="post"
|
||||
class="inline-block w-auto">
|
||||
{{ form_hidden_tag() }}
|
||||
<input
|
||||
class="bg-inherit border-none underline"
|
||||
value="{{section.label}}"
|
||||
value="{{section.label}}/{{section.id}}"
|
||||
type="text"
|
||||
name="label"
|
||||
id="edit-section-label-{{section.id}}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% if not collection.is_leaf %}
|
||||
<!-- if collection has sub_collection make for loop for it -->
|
||||
{% for sub_collection in collection.children if not sub_collection.is_deleted%}
|
||||
<p class="my-3">##{{sub_collection.label}}</p>
|
||||
<p class="my-3">##{{sub_collection.label}}/{{sub_collection.id}}</p>
|
||||
{% if not sub_collection.active_sections and not sub_collection.children %}
|
||||
<p class="ml-3 my-3 italic text-sm">This sub collection is empty</p>
|
||||
{% endif %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
<div class="flex w-full mb-1 dark:text-gray-100 flex-col">
|
||||
<!-- prettier-ignore -->
|
||||
<a href="{{url_for('book.interpretation_view', book_id=book.id, section_id=section.id)}}">
|
||||
<p id="section-{{section.label}}" class="truncate my-3">{{ section.label }}</p></a>
|
||||
<p id="section-{{section.label}}" class="truncate my-3">{{ section.label }}/{{section.id}}</p></a>
|
||||
{% if not section.active_interpretations %}
|
||||
<p class="ml-3 my-3 italic text-sm">This section is empty</p>
|
||||
{% else %}
|
||||
|
@ -164,7 +164,7 @@
|
|||
<!-- prettier-ignore -->
|
||||
<a href="{{url_for('book.interpretation_view', book_id=book.id, section_id=section.id)}}">
|
||||
<!-- prettier-ignore -->
|
||||
<p id="section-{{section.label}}" class="truncate my-3"> {{ section.label }} </p></a >
|
||||
<p id="section-{{section.label}}" class="truncate my-3"> {{ section.label }}/{{section.id}} </p></a >
|
||||
{% if not section.active_interpretations %}
|
||||
<p class="ml-3 my-3 italic text-sm">This section is empty</p>
|
||||
{% else %}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<div class="ml-6">
|
||||
<div class="ml-6" data-dnd="dnd-sub-collection">
|
||||
{% if not collection.is_leaf %}
|
||||
<!-- if collection has sub_collection make for loop for it -->
|
||||
<!-- Nested accordion -->
|
||||
{% for sub_collection in collection.children if not
|
||||
sub_collection.is_deleted%}
|
||||
<div id="accordion-nested-collapse" data-accordion="open">
|
||||
<div
|
||||
id="accordion-nested-collapse"
|
||||
data-accordion="open"
|
||||
data-sub-collection-id="{{sub_collection.id}}">
|
||||
<!-- prettier-ignore -->
|
||||
<div class="flex items-center justify-start w-full font-medium text-left text-gray-500 focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800 dark:text-gray-400">
|
||||
<button
|
||||
|
@ -21,7 +24,7 @@
|
|||
<form id="rename-sub-collection-label-form-{{sub_collection.id}}" data-book-id="{{book.id}}" data-collection-id="{{collection.id}}" data-sub-collection-id="{{sub_collection.id}}" method="post" class="mb-0">
|
||||
{{ form_hidden_tag() }}
|
||||
<!-- prettier-ignore -->
|
||||
<input class="bg-inherit border-none" value="{{sub_collection.label}}" type="text" name="label" id="edit-sub-collection-label-{{sub_collection.id}}" placeholder="Sub collection label" required readonly />
|
||||
<input class="bg-inherit border-none" value="{{sub_collection.label}}/{{sub_collection.id}}" type="text" name="label" id="edit-sub-collection-label-{{sub_collection.id}}" placeholder="Sub collection label" required readonly />
|
||||
<button name="submit" type="submit"></button>
|
||||
</form>
|
||||
</a>
|
||||
|
@ -65,10 +68,10 @@
|
|||
</div>
|
||||
<!-- prettier-ignore -->
|
||||
<div id="accordion-nested-collapse-body-{{sub_collection.parent.id}}-{{sub_collection.id}}" class="hidden" aria-labelledby="accordion-nested-collapse-heading-{{sub_collection.id}}">
|
||||
{% if sub_collection.children %}
|
||||
{% if sub_collection.children or not sub_collection.active_sections%}
|
||||
{{recursive_render("book/components/sub_collection_tab_content.html",sub_collection,book)|safe}}
|
||||
{% else %}
|
||||
<div class="ml-6">
|
||||
{% elif sub_collection.active_sections %}
|
||||
<div id="draggableSectionItems" data-sub-collection-id="{{sub_collection.id}}">
|
||||
<!-- here comes for loop for all section in this sub_collection-->
|
||||
{% for section in sub_collection.active_sections %}
|
||||
{% include 'book/components/section_tab_content.html' %}
|
||||
|
@ -81,7 +84,10 @@
|
|||
<!-- End: Nested accordion -->
|
||||
{% else %}
|
||||
<!-- if collection doesn't have sub_collection -->
|
||||
<div class="ml-6">
|
||||
<div
|
||||
class="ml-6"
|
||||
id="draggableSectionItems"
|
||||
data-collection-id="{{collection.id}}">
|
||||
<!-- here comes for loop for all section in this collection-->
|
||||
{% for section in collection.active_sections %} {% include
|
||||
'book/components/section_tab_content.html' %} {% endfor %}
|
||||
|
|
|
@ -3,7 +3,7 @@ import Sortable from 'sortablejs';
|
|||
|
||||
export function initDnD() {
|
||||
const divsForSectionsDnD: NodeListOf<HTMLDivElement> =
|
||||
document.querySelectorAll('#draggableItems');
|
||||
document.querySelectorAll('#draggableSectionItems');
|
||||
const divsForSubCollectionsDnD: NodeListOf<HTMLDivElement> =
|
||||
document.querySelectorAll('[data-dnd="dnd-sub-collection"]');
|
||||
divsForSubCollectionsDnD.forEach((div: HTMLDivElement) =>
|
||||
|
|
Loading…
Reference in New Issue