Merge pull request #486 from eikek/source-filter

Source filter
This commit is contained in:
mergify[bot] 2020-11-30 14:11:56 +00:00 committed by GitHub
commit 5d2acc2894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 5 deletions

View File

@ -5065,6 +5065,8 @@ components:
type: array
items:
$ref: "#/components/schemas/CustomFieldValue"
source:
type: string
ItemLight:
description: |
An item with only a few important properties.

View File

@ -144,6 +144,7 @@ trait Conversions {
.map(_.ids.flatMap(i => Ident.fromString(i).toOption).toSet)
.filter(_.nonEmpty),
m.customValues.map(mkCustomValue),
m.source,
None
)

View File

@ -216,6 +216,7 @@ object QItem {
allNames: Option[String],
itemIds: Option[Set[Ident]],
customValues: Seq[CustomValue],
source: Option[String],
orderAsc: Option[RItem.Columns.type => Column]
)
@ -242,6 +243,7 @@ object QItem {
None,
None,
Seq.empty,
None,
None
)
}
@ -413,9 +415,10 @@ object QItem {
val tagSelectsExcl =
TagItemName.itemsWithTagOrCategory(q.tagsExclude, q.tagCategoryExcl)
val iFolder = IC.folder.prefix("i")
val name = q.name.map(_.toLowerCase).map(QueryWildcard.apply)
val allNames = q.allNames.map(_.toLowerCase).map(QueryWildcard.apply)
val iFolder = IC.folder.prefix("i")
val name = q.name.map(_.toLowerCase).map(QueryWildcard.apply)
val allNames = q.allNames.map(_.toLowerCase).map(QueryWildcard.apply)
val sourceName = q.source.map(_.toLowerCase).map(QueryWildcard.apply)
val cond = and(
IC.cid.prefix("i").is(q.account.collective),
IC.state.prefix("i").isOneOf(q.states),
@ -458,6 +461,7 @@ object QItem {
.getOrElse(Fragment.empty),
q.dueDateFrom.map(d => IC.dueDate.prefix("i").isGt(d)).getOrElse(Fragment.empty),
q.dueDateTo.map(d => IC.dueDate.prefix("i").isLt(d)).getOrElse(Fragment.empty),
sourceName.map(s => IC.source.prefix("i").lowerLike(s)).getOrElse(Fragment.empty),
q.itemIds
.map(ids =>
NonEmptyList

View File

@ -1603,6 +1603,9 @@ resetField flags item tagger field =
Data.Fields.CustomFields ->
Cmd.none
Data.Fields.SourceName ->
Cmd.none
resetHiddenFields :
UiSettings

View File

@ -72,6 +72,7 @@ type alias Model =
, showNameHelp : Bool
, customFieldModel : Comp.CustomFieldMultiInput.Model
, customValues : CustomFieldValueCollect
, sourceModel : Maybe String
}
@ -135,6 +136,7 @@ init =
, showNameHelp = False
, customFieldModel = Comp.CustomFieldMultiInput.initWith []
, customValues = Data.CustomFieldChange.emptyCollect
, sourceModel = Nothing
}
@ -196,6 +198,7 @@ getItemSearch model =
, tagCategoriesInclude = model.tagSelection.includeCats |> List.map .name
, tagCategoriesExclude = model.tagSelection.excludeCats |> List.map .name
, customValues = Data.CustomFieldChange.toFieldValues model.customValues
, source = model.sourceModel
}
@ -234,6 +237,7 @@ resetModel model =
Comp.CustomFieldMultiInput.reset
model.customFieldModel
, customValues = Data.CustomFieldChange.emptyCollect
, sourceModel = Nothing
}
@ -273,6 +277,7 @@ type Msg
| SetFolder IdName
| SetTag String
| CustomFieldMsg Comp.CustomFieldMultiInput.Msg
| SetSource String
type alias NextState =
@ -738,6 +743,17 @@ updateDrop ddm flags settings msg model =
, dragDrop = DD.DragDropData ddm Nothing
}
SetSource str ->
let
next =
Util.Maybe.fromString str
in
{ model = { model | sourceModel = next }
, cmd = Cmd.none
, stateChange = False
, dragDrop = DD.DragDropData ddm Nothing
}
-- View
@ -992,6 +1008,24 @@ viewDrop ddd flags settings model =
]
]
]
, div
[ classList
[ ( segmentClass, not (fieldHidden Data.Fields.SourceName) )
, ( "invisible hidden", fieldHidden Data.Fields.SourceName )
]
]
[ formHeader (Icons.sourceIcon "") "Source"
, div [ class "field" ]
[ input
[ type_ "text"
, onInput SetSource
, Util.Html.onKeyUpCode KeyUpMsg
, model.sourceModel |> Maybe.withDefault "" |> value
, placeholder "Search in item source"
]
[]
]
]
, div
[ classList
[ ( segmentClass, True )

View File

@ -21,6 +21,7 @@ type Field
| Direction
| PreviewImage
| CustomFields
| SourceName
all : List Field
@ -37,6 +38,7 @@ all =
, Direction
, PreviewImage
, CustomFields
, SourceName
]
@ -81,6 +83,9 @@ fromString str =
"customfields" ->
Just CustomFields
"sourcename" ->
Just SourceName
_ ->
Nothing
@ -121,6 +126,9 @@ toString field =
CustomFields ->
"customfields"
SourceName ->
"sourcename"
label : Field -> String
label field =
@ -158,6 +166,9 @@ label field =
CustomFields ->
"Custom Fields"
SourceName ->
"Item Source"
fromList : List String -> List Field
fromList strings =

View File

@ -29,6 +29,8 @@ module Data.Icons exposing
, personIcon
, search
, searchIcon
, source
, sourceIcon
, tag
, tagIcon
, tags
@ -40,6 +42,16 @@ import Html exposing (Html, i)
import Html.Attributes exposing (class)
source : String
source =
"upload icon"
sourceIcon : String -> Html msg
sourceIcon classes =
i [ class (source ++ " " ++ classes) ] []
customFieldType : CustomFieldType -> String
customFieldType ftype =
case ftype of

View File

@ -5,6 +5,7 @@ import Comp.CollectiveSettingsForm
import Comp.SourceManage
import Comp.UserManage
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
import Html.Attributes exposing (..)
@ -35,7 +36,7 @@ view flags settings model =
[ classActive (model.currentTab == Just SourceTab) "link icon item"
, onClick (SetTab SourceTab)
]
[ i [ class "upload icon" ] []
[ Icons.sourceIcon ""
, text "Sources"
]
, div
@ -183,7 +184,7 @@ makeTagStats nc =
viewSources : Flags -> UiSettings -> Model -> List (Html Msg)
viewSources flags settings model =
[ h2 [ class "ui header" ]
[ i [ class "ui upload icon" ] []
[ Icons.sourceIcon ""
, div [ class "content" ]
[ text "Sources"
]