From d1719b70a39ee5452c9f70205877a372558a9fe8 Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Mon, 5 Jun 2023 13:00:47 +0300 Subject: [PATCH] checkbox tree --- .../book/modals/access_level_modal.html | 88 +++++++++++-------- src/indeterminateInputs.ts | 9 ++ src/main.ts | 2 + 3 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 src/indeterminateInputs.ts diff --git a/app/templates/book/modals/access_level_modal.html b/app/templates/book/modals/access_level_modal.html index 2fe3328..f21ccd6 100644 --- a/app/templates/book/modals/access_level_modal.html +++ b/app/templates/book/modals/access_level_modal.html @@ -20,54 +20,72 @@
-
    +
    • - + + {{ book.label }}
      - {% for collection in book.last_version.children_collections %} + {%- for collection in book.last_version.children_collections recursive %} +
      +
      • - + {{ collection.label }}
        - {% for sub_collection in collection.active_children %} -
          -
        • -
          - - {{ sub_collection.label }} -
          - {% for section in sub_collection.sections %} -
            -
          • -
            - - {{ section.label }} -
            -
          • -
          - {% endfor %} -
        • -
        - {% endfor %} + {% if collection.active_children %} - {% for section in collection.sections %} -
          -
        • -
          - - {{ section.label }} -
          -
        • -
        - {% endfor %} + {{ loop(collection.active_children)}} + + {# + {% for sub_collection in collection.active_children %} +
          +
        • +
          + + {{ sub_collection.label }} +
          + {% for section in sub_collection.sections %} +
            +
          • +
            + + {{ section.label }} +
            +
          • +
          + {% endfor %} +
        • +
        + {% endfor %} + #} + + + {% else %} + + + {% for section in collection.sections %} +
          +
        • +
          + + + {{ section.label }} +
          +
        • +
        + {% endfor %} + + + {% endif %}
      - {% endfor %} +
      + {%- endfor %}
diff --git a/src/indeterminateInputs.ts b/src/indeterminateInputs.ts new file mode 100644 index 0000000..3f3d0ee --- /dev/null +++ b/src/indeterminateInputs.ts @@ -0,0 +1,9 @@ +export function indeterminateInputs() { + const indeterminatedInputs = document.querySelectorAll( + 'input[indeterminate=true]', + ); + + indeterminatedInputs.forEach((element: HTMLInputElement) => { + element.indeterminate = true; + }); +} diff --git a/src/main.ts b/src/main.ts index bab3c53..253cc44 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,6 +29,7 @@ import {flash} from './flash'; import {slashSearch} from './slashSearch'; import {editInterpretations} from './editInterpretations'; import {deleteInterpretation} from './deleteInterpretation'; +import {indeterminateInputs} from './indeterminateInputs'; initQuillReadOnly(); initBooks(); @@ -61,3 +62,4 @@ flash(); slashSearch(); editInterpretations(); deleteInterpretation(); +indeterminateInputs();