integreat-cms icon indicating copy to clipboard operation
integreat-cms copied to clipboard

Empty tag for empty pages without non-archived children

Open svenseeberg opened this issue 3 years ago • 4 comments

Motivation

At the moment, the "empty" page label only works when a page has an empty content and no subpages. There is an edge case where an empty page has only subpages which are archived, so just inspecting the page object with is_leaf() is not sufficient to check whether the empty tag should be shown. Instead, the database needs to be queried to check whether all subpages are archived or not.

Proposed Solution

Since this means that we need to query n+1 levels from the database to show n levels correctly in the tree, we should start with fetching the additional layer right after the page has finished loading:

  • #1158

After this is implemented, we can use the additional information to correctly render the empty tag and insert it in those cases where only archived children exist. This is also connected to the following issue:

  • #1244

which can probably solved together with this one.

Alternatives

Alternatively, we can update the page tree view to query the first two levels instead of just the root pages on initial load. And on every expanding operation, all potential next levels need to be fetched to show the empty page tag correctly for subpages.

svenseeberg avatar Feb 16 '22 08:02 svenseeberg

Note: This is right now blocked on #1158

david-venhoff avatar Feb 19 '22 14:02 david-venhoff

@david-venhoff wouldn't it make more sense to calculate the data on the server side? https://github.com/digitalfabrik/integreat-cms/pull/1238/files#diff-14ce0fdb6517ed7eea832445e21efef7e7abb0f12ba444c3b6c26fe9c730fd16R230 will bring along a new function that may help here. It can check if a page has any public content for a given language.

svenseeberg avatar Feb 22 '22 20:02 svenseeberg

@svenseeberg In any case, we need to query n+1 levels of pages from the database to show n levels in the page tree. So even when we use the new function, it would still increase the database load, because it would require to fetch the first two layers of pages instead of just the root pages. This was my thought process behind the proposal of combining this ticket with #1158 and query the additional levels dynamically. Apart from that, this ticket is only about the archived flag (since it's about the page tree and we want to show pages without public translation in the page tree)...

timobrembeck avatar Feb 22 '22 21:02 timobrembeck

@timoludwig can you update the initial post? I'm a little confused right now what this issue is actually about. And AFAICT this is now mostly solved, so we can have a lower prio now.

svenseeberg avatar Feb 23 '22 10:02 svenseeberg

Currently no empty tag is shown even if a page has only empty descendants. Should this remain so?

Then, I guess we only have to check whether a page as at least one non-archied child, becuase all the later descendants (grand children, grand grand children......) are all implecity but archived if all the children pages are archived. But I feel I'm missing something 🤔

MizukiTemma avatar Oct 23 '23 19:10 MizukiTemma

Currently no empty tag is shown even if a page has only empty descendants. Should this remain so?

Yes. I think we should check the content of child nodes. That would be too much logic and would become increasingly difficult to explain.

Then, I guess we only have to check whether a page as at least one non-archied child, becuase all the later descendants (grand children, grand grand children......) are all implecity but archived if all the children pages are archived. But I feel I'm missing something 🤔

AFAICT the following cases should display an empty label:

  • The page itself is a leaf node and has no content
  • The page is empty, has children, but the children are archived

svenseeberg avatar Oct 30 '23 07:10 svenseeberg