add bookmark collection editor

This commit is contained in:
2026-06-02 08:12:26 +03:00
parent 5676ced836
commit edfa2e232f
9 changed files with 163 additions and 24 deletions

View File

@@ -270,7 +270,7 @@
{%- endmacro %}
{% macro sortable_list_item(key, immovable=false, attr=none) -%}
<li class="sortable-item{{ ' immovable' if immovable else '' }} plank even no-shadow {{'tertiary-bg' if immovable else ''}}" data-sortable-list-key="{{key}}" {% if attr %}{{ dict_to_attr(attr) }}{% endif %}>
<li class="sortable-item{{ ' immovable' if immovable else '' }} plank even no-shadow {{'secondary-bg' if immovable else ''}}" data-sortable-list-key="{{key}}" {% if attr %}{{ dict_to_attr(attr) }}{% endif %}>
<span class="dragger plank minimal even no-shadow tertiary-bg" draggable="{{ 'true' if not immovable else 'false' }}">{{ icn_dragger() }}</span>
<div class="sortable-item-inner">{{ caller() }}</div>
</li>

View File

@@ -0,0 +1,44 @@
{%- from 'common/macros.html' import subheader, sortable_list, sortable_list_item -%}
{%- macro collection_item(name='', can_delete=true, id=-1, thread_count=0, post_count=0) -%}
<input name="name[]" type="text" autocomplete="off" value="{{name}}" required maxlength=60 placeholder="Collection name">
<input type="hidden" name="id[]" value="{{ 'new' if id == -1 else id}}" autocomplete="off">
<span>{{thread_count}} {{'thread' | pluralize(num=thread_count)}}, {{post_count}} {{'post' | pluralize(num=post_count)}} </span>
{%- if not can_delete -%}
<i>Default collection</i>
{%- else -%}
<button type="button" class="critical" data-s="deleteCollection">Delete</button>
{%- endif -%}
{%- endmacro -%}
{%- extends 'base.html' -%}
{%- block title -%}managing bookmark collections{%- endblock -%}
{%- block content -%}
<bitty-8 data-connect="/static/js/bits/collections-editor.js"></bitty-8>
{%- set sh -%}
<span class="js-only" data-r="enhance">
Drag collections to reoder them. You cannot move or remove the default collection, but you can rename it.
</span>
<div data-r="enhanceHide">This page requires JS enabled to work correctly.</div>
{%- endset -%}
{%- call() subheader('Manage bookmark collections', sh) -%}
<fieldset class="plank even no-shadow minimal thread-actions js-only" data-r="enhance">
<legend>Actions</legend>
<button data-s="addCollection">Add new collection</button>
<input type="submit" class="alt" value="Save collections" form="collections-form">
</fieldset>
{%- endcall -%}
<form class="plank" method="POST" id="collections-form">
<input type="hidden" autocomplete="off" name="deleted_ids" value="" data-r="countDeletedCollection">
{%- call() sortable_list(attr={'data-r': 'addCollection'}) -%}
{%- for collection in collections -%}
{%- call() sortable_list_item(key='bc', immovable=collection.is_default == 1, attr={'data-r': 'deleteCollection', 'data-id': collection.id}) -%}
{{ collection_item(name=collection.name, can_delete=collection.is_default != 1, thread_count=collection.get_threads_count(), post_count=collection.get_posts_count(), id=collection.id) }}
{%- endcall -%}
{%- endfor -%}
{%- endcall -%}
</form>
<script type="text/html" data-template="collectionItem">
{%- call() sortable_list_item(key='bc', attr={'data-r': 'deleteCollection', 'data-id': 'new'}) -%}
{{- collection_item() -}}
{%- endcall -%}
</script>
{%- endblock -%}