User tests: Successful: Unsuccessful:
Pull Request for Issue #46701
This PR fixes issue #46701 where archived categories were not selectable in article edit and batch operation dropdowns. And prevents category from resetting to first available non-archived category when editing articles assigned to archived categories.
First Test:
Create an article.
Verify that archived categories can be assigned to the article.
Assign a archived category to the article.
Edit the article
Verify that the category of the article has not been auto assigned to the first available non-archived category.
Second Test:
Third Test:
Verify that categories can be assigned archived categories as their parents
NOTE: If a published/unpublished category is assigned an archived category as its parent, then those categories also become archived.
When editing an article assigned to an archived category, the category dropdown did not show the archived category.
If the category of an article was archived then, it would be changed to an available non-archived category upon editing the article.
Archived categories were not listed in the batch "Select Category for Move/Copy" dropdown
Cannot assign archived categories as parent to other categories.
Category drop-down when editing an article shows archived categories. Archived categories assigned to articles don't get swapped for non-archived categories
Archived categories are listed in batch "Select Category for Move/Copy" dropdown.
Archived categories can be assigned as parent to other categories
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Administration com_categories Layout |
| Title |
|
||||||
| Title |
|
||||||
@brianteeman
It is definitely possible that the BEFORE of this PR was intended, considering the archived = finished / don't assign anything more here philosophy.
And this PR solves the problem of not being able to assign archived category for a new article( or as parent to a different category ) , which might be a very small use case while introducing new dropdown elements ( confusion ) to every user.
But it fixes the bug where an archived category would get swapped out for the first available non-archived category which is an improvement.
Would be glad to hear some advice on how to progress with this further.
@peterhulst you also have to think about side effects. For batch process, the result is not acceptable.
@hiteshm0 could you enclose archived categoriesl in brackets also in the dropown for batch process?
| Labels |
Added:
Feature
b/c break
PR-6.1-dev
|
||
Thank you @hiteshm0 for the change, but this is not what we do in Joomla. We separate data and presentation layer.
No database queries in layouts.
You could add the published field into the categories (this means change the categries model) so it is available in the layout.
Another solution would be: Let the code as it is now, filter = 0, 1.
Then make an new select with filter = 2. This gives the arcived categories.
Build the final drop down in two parts - first the published categories as it is now,
then append '- archived categories -' (use a language key)
and the all the archived categories.
This seems less confusing than having prublished and archived categories mixed in a dropdown.
I have checked e580fa5 and it works as expected.
Proposal:
To overcome the comment of @chmst instead of [] for both unpublished and archived categories, the archived categories can be enclosed with {} instead [] (or something else: - archived categories -' (using a language key))
The code change in the latest modification is easy:
in item.php
if (isset($publishedStates[$catId]) && $publishedStates[$catId]->published != 1) {
$option->text = '[' . $option->text . ']';
}
Change to:
if (isset($publishedStates[$catId]) && $publishedStates[$catId]->published == 0) {
$option->text = '[' . $option->text . ']';
}
if (isset($publishedStates[$catId]) && $publishedStates[$catId]->published == 2) {
$option->text = '{' . $option->text . '}';
}
And in components\com_categories\src\Field\CategoryeditField.php:
if ($option->published == 1 ) {
$option->text = str_repeat('- ', !$option->level ? 0 : $option->level - 1) . $option->text;
}
Change to:
if ($option->published == 1 ) {
$option->text = str_repeat('- ', !$option->level ? 0 : $option->level - 1) . $option->text;
}
elseif ($option->published == 0) {
$option->text = str_repeat('- ', !$option->level ? 0 : $option->level - 1) . '[' . $option->text . ']';
}
elseif ($option->published == 2) {
$option->text = str_repeat('- ', !$option->level ? 0 : $option->level - 1) . '{' . $option->text . '}';
}
// Displays language code if not set to All
if ($option->language !== '*') {
$option->text .= ' (' . $option->language . ')';
}
Regards,
Peter
@peterhulst your proposal definitely works but as mentioned by @chmst it is not in joomlas practice to do database queries in layouts, so the solution will become quite complicated.
@hiteshm0 The proposal of @peterhulst means that you can remove the database access. You need only the extra line for archived categories.
But then we have two or three database queries instead of one.
Layout: At the moment, there is no difference for published and unpublished categories - but could be interesting.
What would you expect as administrator if you have hundreds of categories?
Would be nice to have more opinions - @brianteeman
if we dont display any difference between published/unpublished categories then I wouldnt expect any visual difference with archived
i dont understand why this is labelled a b/c break. Nothing breaks you just get extra functionality
@brianteeman its most probably labelled as a b/c break, because in the batch operations dropdown there is no difference in the way archived and published categories are shown ( even unpublished categories are shown without any brackets ).
I am working on a fix for this right now
That doesn't constitute a breaking change
| Category | Administration com_categories Layout | ⇒ | Administration com_categories Language & Strings Layout Libraries |
quite a bit of duplicate code in CategoryeditField.php
I have checked both changes succesfully in Joomla 5.4.2. Thank you! Nice implementation!
@peterhulst If you have successfully tested this pull request, then please go to it in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/46706 and use the blue "Test this" button at the top left corner to submit your test result. I think I've told you that a few times in last already.
I have tested this item ✅ successfully on 458aa6e
I have verified it succesfully in J5.4.2
@richard67 sorry, i'm a test beginner and i didn't know from the blue test button. It was never told to me.
I see no b/c break at the first glance so I removed it maybe @chmst can explain why she added it.
I'm a bit confused about the duplicated code in CategoryeditField::getOptions(), I didn't a full code review just wondering if the code you added isn't the same already in the method.
@HLeithner there was an existing database query for category state = 0,1 in getOptions. I added another database query for category state = 2. The ACL filtering logic that succeeds both these database queries is identical.
| Labels |
Added:
Language Change
PBF
Removed: b/c break |
||
@HLeithner
-> By default a database query for category published state = 0,1,2 is run. All filtering logic happens only once.
And then a separator is put between active and archived categories.
-> If need be the required published states can be explicitly mentioned through the XML.
tbh why to separate them? it's isn't it annoying if you have a tree structure and the archive which should be in the 5th subtree item is not there?
@HLeithner
i just felt like this was the more cleaner approach as it shows archived categories in the end ( practically assigning of archived categories will be rare ). And unpublished categories are visually indicated using [], so we'll have to use {} to indicate archived categories which might become cluttered.
Implementation wise using {} to indicate archived categories is simpler than separating and showing in the end.
Some advice and opinions from end users could be valuable here
you can make it italic, not sure if it works in all browsers, but would make it nicer I think.
ill add curly braces around the archived categories to make sure there is consistency with how we use square brackets for unpublished categories
| Category | Administration com_categories Layout Language & Strings Libraries | ⇒ | Administration com_categories Layout Libraries |
@HLeithner
Separation between active and archived categories has been removed.
[] brackets around unpublished categories and {} brackets around archived categories as their respective visual indicator has been added.
( if you'd prefer me not pinging you, please let me know 😅 )
Edit: The failed check will most probably pass upon rerunning the check. But i am unable to rerun checks for some reason.
| Labels |
Removed:
Language Change
|
||
@hiteshm0 since I'm one of the 2 release manger for 6.1 it's ok when you ping me.
would you do me a favor and check convert all double equal checks to tripple equal checks.
$item->published == 2 to $item->published === 2
if $item->published is not an integer please case it to int, but we nice if you could test first if it's an integer on your installation.
@HLeithner
$item->published is an integer in my installation so ill skip on casting it to int.
ive changed all the '==' that ive added to '===' ( there were 6 of them )
We don't have many use cases in real life so it is hard to decide what is better UX.
Normal users I don't know what italic or a special kind of bracket means. Is it archived, is it unpublished, is it trashed?
This is not self-explaining.
Maybe the usual icon or an additional text is better?
Suppose you have 200 catregories until now and work with them since years. Suddenly the dropdown contains 400 categories, all the archived categories are mixed in between. Better or worse?
I would say better in between. It's more strange if you need to have the same tree 2 times in the dropdown.
Maybe it's better to not mark it at all, or append "(archived)" and "(unpublished)" but I think unpublished is not needed. I'm open to how and if it's marked, what I don't think is a good idea to separated it at the bottom.
Ok for having one tree.
But we need the additional text - at least (archived) - for accessibility and usabiltiy. Also possible is an icon (must be implemented in an accessible way).
@HLeithner @chmst
A couple of options we could explore:
would you guys prefer something else ?
a and u might make sense in english but who knows about all the other supported languages. The words might start with the same letter
a and u might make sense in english but who knows about all the other supported languages. The words might start with the same letter
Indeed that is the case for more languages. Danish would be (A) arkiveret and (A) afpubliseret.
I have tested this item ✅ successfully on 1dee2b8
I have tested this item ✅ successfully on 1dee2b8
i wonder why we have never been able to do this before. As far as I can tell the behaviour has been this way for at least 8 years and probably longer
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46706.