Sort tags by category and then name

Issue: #1396
This commit is contained in:
eikek
2022-02-26 15:39:01 +01:00
parent dcd8267d6e
commit 79d58fe320
3 changed files with 20 additions and 2 deletions

View File

@ -442,7 +442,7 @@ object QItem {
cfields <- Stream.eval(findCustomFieldValuesForItem(item.id)) cfields <- Stream.eval(findCustomFieldValuesForItem(item.id))
} yield ListItemWithTags( } yield ListItemWithTags(
item, item,
ftags.toList.sortBy(_.name), RTag.sort(ftags.toList),
attachs.sortBy(_.position), attachs.sortBy(_.position),
cfields.toList cfields.toList
) )

View File

@ -164,4 +164,23 @@ object RTag {
def delete(tagId: Ident, coll: Ident): ConnectionIO[Int] = def delete(tagId: Ident, coll: Ident): ConnectionIO[Int] =
DML.delete(T, T.tid === tagId && T.cid === coll) DML.delete(T, T.tid === tagId && T.cid === coll)
def sort(tags: List[RTag]): List[RTag] =
tags match {
case Nil => tags
case _ =>
val byCat = tags
.groupBy(_.category)
.view
.mapValues(_.sortBy(_.name))
.toList
.sortBy(_._1)
byCat match {
case (None, tags) :: rest =>
rest.flatMap(_._2) ++ tags
case _ =>
byCat.flatMap(_._2)
}
}
} }

View File

@ -33,7 +33,6 @@ import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Messages.Comp.ItemCardList exposing (Texts) import Messages.Comp.ItemCardList exposing (Texts)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Set exposing (Set)
import Styles as S import Styles as S
import Util.ItemDragDrop as DD import Util.ItemDragDrop as DD
import Util.List import Util.List