Skip to content

Support multiple fragment libraries with categories - #2548

Merged
tf merged 15 commits into
codevise:masterfrom
tf:multi-lib
Dec 3, 2026
Merged

tf merged 15 commits into
codevise:masterfrom
tf:multi-lib

Conversation

@tf

@tf tf commented Dec 3, 2026

Copy link
Copy Markdown
Member

No description provided.

@tf tf added this to the v17.3 milestone Dec 3, 2026
tf added 15 commits December 3, 2026 13:52
The content element created by the batch request could receive the
hard coded id of the supposedly unknown content element, depending on
how many content elements earlier specs had created. The update then
succeeded and nothing was rolled back.
Fragments can be grouped by category in insert dialogs. The category
is stored next to the fragment kind in the chapter configuration of
the library entry.
Accounts can have more than one shared fragment library. Extraction
requests can pass the id of an existing library of the account or the
title of a new library. Without either, fragments are still added to
the oldest shared library, which is created on demand.

The generated title of that default library no longer contains the
account name, since library titles will be displayed as labels in
the insert dialogs.
The editor lets users pick the library to extract fragments into. As
long as an account has no library yet, the index contains the
unpersisted default library, so the first extraction looks just like
later ones. Each library tells whether the user may add fragments to
it.
Fragments of all libraries the user can read are listed in the
insert dialogs. Fragments can be grouped by category, with
categories in alphabetical order and uncategorized fragments last.
The categories in use are available as suggestions for extraction.

Each library builds its fragment models once and keeps them when its
collections change. Filtering fragments by kind or library returns
plain arrays of these shared models, so filtering repeatedly does not
attach further listeners to them.
The extract dialog lets users pick one of the libraries they may add
fragments to or create a new one. The default library is offered even
before it exists. The last used library is preselected.

Categories already used for fragments of the same kind are suggested
in a combobox. Typed text that does not match an existing category is
offered as a new category, while text matching one apart from case
picks the existing category to avoid near duplicates. Leaving the
field keeps the typed text, so clicking the add button right after
typing does not drop the category.

Menu labels now speak of the fragment library instead of shared
fragments since there can be more than one library.
Both insert dialogs will list fragments in one column. Fragments are
grouped under category headings, merged across libraries. Pills let
users narrow the list to a single library once more than one library
contains fragments of the kind. The selected pill is remembered.
The fragments tab of the insert dialog uses the fragment list. The
heading for shared fragments gives way to category headings and
library pills.
The rail only ever showed the single shared library. Section
fragments are now listed like content element fragments: grouped by
category, with library pills once there is more than one library.
The preview stays fixed above the scrolling list.

The dialog opens on the first fragment in display order. When a pill
hides the selected fragment, the first displayed fragment is selected
instead, so the insert button never inserts a fragment the user
cannot see.

Cards compare fragments by key since the list creates new fragment
models when switching libraries.
Fragment libraries can now be curated from the editor of any entry.
A PATCH request to fragment_libraries/:library_id/fragments/:perma_id
rewrites title and category of the fragment chapter. An attribute
that is not part of the request keeps its value. Updating requires
the same permission as extracting into the library.

Fragments are modelled explicitly: SectionsFragment and
ContentElementsFragment wrap a chapter of a library entry and differ
in how content is copied into them. Libraries expose fragments,
sections_fragments and content_elements_fragments collections to find
fragments by perma id and to extract new ones. Extraction persists the
library on first use.
Sections fragments copy their sections into a chapter of the entry and
content elements fragments prepare unsaved content elements for it,
replacing the corresponding methods of fragment libraries that took a
perma id. Looking fragments up through the typed collections means
inserting a content elements fragment as sections now responds with
not found, like preparing a sections fragment already did.
Prepares reusing the combobox in a dialog to edit fragments. It now
accepts an initial value and owns its translations.
Fragments of libraries the user may update get a menu with an item to
open a dialog for name and category. Fragments know their library and
are saved with a PATCH request to the fragment resource. Since
libraries keep their fragment models, fragment lists regroup in place
once a fragment has been saved and keep the selected library pill.

The dialog is appended to the dialog container next to the open
fragment dialog instead of replacing it. The insert content element
dialog now only closes when an element type or fragment is clicked,
not when a fragment menu is opened.
Fragments are used far more often than they change. The entry now
holds a single fragment libraries collection. Only the first dialog
waits for libraries to load. Later dialogs render the loaded
fragments right away while libraries are fetched again in the
background. The refetch updates library and fragment models in place.
Fragment lists only re-render when libraries or fragments were added,
removed or changed, so thumbnails are not mounted again when nothing
changed. The preview of the selected fragment follows changes as
well. If the refetch fails, the loaded libraries stay in place.

Extracting a fragment invalidates the loaded libraries. The next
dialog waits for the refetch, so new libraries and categories are
offered right away.
@tf
tf merged commit b088730 into codevise:master Dec 3, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant