Skip to content

Add category order - #2592

Merged
Alkarex merged 2 commits into
FreshRSS:devfrom
aledeg:feature/category-order
Oct 26, 2019
Merged

Alkarex merged 2 commits into
FreshRSS:devfrom
aledeg:feature/category-order

Conversation

@aledeg

@aledeg aledeg commented Oct 25, 2019

Copy link
Copy Markdown
Member

Each category has a new 'priority' attribute. It is used to sort categories in
views. Categories with the same priority are sorted alphabetically. Categories
with no priority are displayed after those with one.

For example, if we have the following categories:

  • A (priority: 2)
  • B (no priority)
  • C (priority: 1)
  • D (priority: 2)
  • E (no priority)
  • F (priority: 1)

They will be displayed in the following order:

  • C
  • F
  • A
  • D
  • B
  • E

See #190

Comment thread app/layout/aside_feed.phtml Outdated
$c_show = $c_active || FreshRSS_Context::$user_conf->display_categories;
?>
<li class="tree-folder category<?= $c_active ? ' active' : '' ?>" data-unread="<?= $cat->nbNotRead() ?>">
<li class="tree-folder category<?= $c_active ? ' active' : '' ?><?= null === $priority ? '' : " priority_$priority"?>" data-unread="<?= $cat->nbNotRead() ?>">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not checked in details, but I suggest using data-priority="..."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to be able to target them with a CSS rule. But I can also add some data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A [data-priority="1"] or something along those lines would be every so slightly more expensive (unless that changed in recent years) but it's hardly worth worrying about.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Frenzie I am not sure I follow you thinking. Could you explain me what you have in mind?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I figured you knew. That's a CSS attribute selector.

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

It's been supported by all browsers for close to 15 years.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Frenzie I knew but I didn't understand what you meant. Now I do :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread app/Models/Category.php Outdated

public function _attributes($key, $value) {
if ($key == '') {
if ('' === $key) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably == is better there. It would still be a problem with null and 0 and false

@Alkarex Alkarex added this to the 1.15.0 milestone Oct 25, 2019
@Alkarex

Alkarex commented Oct 25, 2019

Copy link
Copy Markdown
Member

Looks good and straightforward 👍

@aledeg

aledeg commented Oct 25, 2019

Copy link
Copy Markdown
Member Author

@Alkarex I think I should do something more user friendly by modifying the priority with drag&drop instead of manual entry.
What do you think?

@Alkarex

Alkarex commented Oct 25, 2019

Copy link
Copy Markdown
Member

@aledeg It would surely be better, if you are motivated enough :-P
Maybe we could have a first version for the 1.15 release and some improvements in 1.16.
To prepare for that, maybe priority should be renamed to something more related to ordering.

@Frenzie

Frenzie commented Oct 25, 2019

Copy link
Copy Markdown
Member

Sort(ing) order? Position(ing)?

@aledeg

aledeg commented Oct 25, 2019

Copy link
Copy Markdown
Member Author

@Alkarex
I'll make it use drag&drop and change the naming. When do you plan to release v1.15? I would like to make it work fully before shipping.
Let me know

@Frenzie I'll go with position then

@Frenzie

Frenzie commented Oct 25, 2019

Copy link
Copy Markdown
Member

Sounds good!

@Alkarex

Alkarex commented Oct 25, 2019

Copy link
Copy Markdown
Member

I would like to call for testing FreshRSS 1.15 tomorrow and release it by the end October. Therefore a first simple version for now would be nice (i.e. more or less what you already have now), keeping the drag & drop improvements for the next release

@aledeg

aledeg commented Oct 25, 2019

Copy link
Copy Markdown
Member Author

The thing is that with drag&drop, there will be no use for the category configuration field in UI. Thus making the translation obsolete. We can still remove it later but we have to keep that in mind.
I'll make the few changes required tonight and I'll continue to work on it later. Hopefully not like my other PR :)

@aledeg
aledeg force-pushed the feature/category-order branch from 22f74b7 to 28475e1 Compare October 25, 2019 18:19
@aledeg

aledeg commented Oct 25, 2019

Copy link
Copy Markdown
Member Author

@Alkarex @Frenzie
Everything is fixed except for the drag&drop

Each category has a new 'priority' attribute. It is used to sort categories in
views. Categories with the same priority are sorted alphabetically. Categories
with no priority are displayed after those with one.

For example, if we have the following categories:
- A (priority: 2)
- B (no priority)
- C (priority: 1)
- D (priority: 2)
- E (no priority)
- F (priority: 1)

They will be displayed in the following order:
- C
- F
- A
- D
- B
- E

See FreshRSS#190
@aledeg
aledeg force-pushed the feature/category-order branch from 28475e1 to 042fcd5 Compare October 25, 2019 18:23
@Alkarex

Alkarex commented Oct 25, 2019

Copy link
Copy Markdown
Member

Nice, I will try tomorrow morning :-)

It took too much room and will not be so necessary once we have drag &
drop
@Alkarex

Alkarex commented Oct 26, 2019

Copy link
Copy Markdown
Member

Looks all good :-) I have just shorten a bit the help text as it was not looking so good on different layouts

@Alkarex
Alkarex merged commit f6e1057 into FreshRSS:dev Oct 26, 2019
@Alkarex Alkarex added the UI 🎨 User Interfaces label Oct 26, 2019
@Alkarex Alkarex mentioned this pull request Oct 26, 2019
@aledeg
aledeg deleted the feature/category-order branch October 26, 2019 17:18
marienfressinaud added a commit to flusio/FreshRSS that referenced this pull request Oct 31, 2019
I had a bug when some articles in a category were unread. Sometimes,
filtering the category displayed all the articles, even with the "Adjust
showing" option.

A reasonably good guess was to look the last commits that impacted the
categories and, indeed, it was introduced by the new category sorting
system.

The sort function (`usort`) doesn't keep the index association, which is
important here. I must admit I don't understand exactly why (I didn't
search), but the keys are probably used somewhere. Another fix would be
to not rely on these keys anymore.

The bug was introduced in 042fcd5

- Ref PR: FreshRSS#2592
- Ref usort: https://www.php.net/manual/en/function.usort.php
- Ref uasort: https://www.php.net/manual/en/function.uasort.php
Alkarex pushed a commit that referenced this pull request Oct 31, 2019
I had a bug when some articles in a category were unread. Sometimes,
filtering the category displayed all the articles, even with the "Adjust
showing" option.

A reasonably good guess was to look the last commits that impacted the
categories and, indeed, it was introduced by the new category sorting
system.

The sort function (`usort`) doesn't keep the index association, which is
important here. I must admit I don't understand exactly why (I didn't
search), but the keys are probably used somewhere. Another fix would be
to not rely on these keys anymore.

The bug was introduced in 042fcd5

- Ref PR: #2592
- Ref usort: https://www.php.net/manual/en/function.usort.php
- Ref uasort: https://www.php.net/manual/en/function.uasort.php
Alkarex added a commit to Alkarex/FreshRSS that referenced this pull request Mar 13, 2023
$c_show = $c_active || FreshRSS_Context::$user_conf->display_categories;
?>
<li class="tree-folder category<?= $c_active ? ' active' : '' ?>" data-unread="<?= $cat->nbNotRead() ?>">
<li class="tree-folder category<?= $c_active ? ' active' : '' ?>"<?= null === $position ? '' : "data-position='$position'" ?> data-unread="<?= $cat->nbNotRead() ?>">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before data-position fixed in #5203

Alkarex added a commit that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UI 🎨 User Interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants