Merge pull request #1290 from eikek/tag-cat-select

Tag cat select
This commit is contained in:
mergify[bot] 2022-01-15 18:04:22 +00:00 committed by GitHub
commit f71a5f2c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 441 additions and 160 deletions

View File

@ -89,6 +89,7 @@ module Api exposing
, getSources , getSources
, getTagCloud , getTagCloud
, getTags , getTags
, getTagsIgnoreError
, getUsers , getUsers
, initOtp , initOtp
, itemBasePreviewURL , itemBasePreviewURL
@ -1280,20 +1281,35 @@ getContacts flags kind q receive =
--- Tags --- Tags
getTags : Flags -> String -> TagOrder -> (Result Http.Error TagList -> msg) -> Cmd msg getTagsTask : Flags -> String -> TagOrder -> Task.Task Http.Error TagList
getTags flags query order receive = getTagsTask flags query order =
Http2.authGet Http2.authTask
{ url = { url =
flags.config.baseUrl flags.config.baseUrl
++ "/api/v1/sec/tag?sort=" ++ "/api/v1/sec/tag?sort="
++ Data.TagOrder.asString order ++ Data.TagOrder.asString order
++ "&q=" ++ "&q="
++ Url.percentEncode query ++ Url.percentEncode query
, method = "GET"
, headers = []
, account = getAccount flags , account = getAccount flags
, expect = Http.expectJson receive Api.Model.TagList.decoder , body = Http.emptyBody
, resolver = Http2.jsonResolver Api.Model.TagList.decoder
, timeout = Nothing
} }
getTags : Flags -> String -> TagOrder -> (Result Http.Error TagList -> msg) -> Cmd msg
getTags flags query order receive =
getTagsTask flags query order |> Task.attempt receive
getTagsIgnoreError : Flags -> String -> TagOrder -> (TagList -> msg) -> Cmd msg
getTagsIgnoreError flags query order tagger =
getTagsTask flags query order
|> Task.attempt (Result.map tagger >> Result.withDefault (tagger Api.Model.TagList.empty))
postTag : Flags -> Tag -> (Result Http.Error BasicResult -> msg) -> Cmd msg postTag : Flags -> Tag -> (Result Http.Error BasicResult -> msg) -> Cmd msg
postTag flags tag receive = postTag flags tag receive =
let let

View File

@ -22,9 +22,9 @@ import Api.Model.TagList exposing (TagList)
import Comp.Basic as B import Comp.Basic as B
import Comp.CalEventInput import Comp.CalEventInput
import Comp.ChannelForm import Comp.ChannelForm
import Comp.Dropdown
import Comp.IntField import Comp.IntField
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Comp.TagDropdown
import Comp.YesNoDimmer import Comp.YesNoDimmer
import Data.CalEvent exposing (CalEvent) import Data.CalEvent exposing (CalEvent)
import Data.ChannelType exposing (ChannelType) import Data.ChannelType exposing (ChannelType)
@ -50,8 +50,8 @@ import Util.Update
type alias Model = type alias Model =
{ settings : PeriodicDueItemsSettings { settings : PeriodicDueItemsSettings
, channelModel : Comp.ChannelForm.Model , channelModel : Comp.ChannelForm.Model
, tagInclModel : Comp.Dropdown.Model Tag , tagInclModel : Comp.TagDropdown.Model
, tagExclModel : Comp.Dropdown.Model Tag , tagExclModel : Comp.TagDropdown.Model
, remindDays : Maybe Int , remindDays : Maybe Int
, remindDaysModel : Comp.IntField.Model , remindDaysModel : Comp.IntField.Model
, capOverdue : Bool , capOverdue : Bool
@ -87,8 +87,8 @@ type Action
type Msg type Msg
= Submit = Submit
| TagIncMsg (Comp.Dropdown.Msg Tag) | TagIncMsg Comp.TagDropdown.Msg
| TagExcMsg (Comp.Dropdown.Msg Tag) | TagExcMsg Comp.TagDropdown.Msg
| GetTagsResp (Result Http.Error TagList) | GetTagsResp (Result Http.Error TagList)
| RemindDaysMsg Comp.IntField.Msg | RemindDaysMsg Comp.IntField.Msg
| ToggleEnabled | ToggleEnabled
@ -112,16 +112,6 @@ initWith flags s =
( im, ic ) = ( im, ic ) =
init flags ct init flags ct
removeAction ( tm, _, tc ) =
( tm, tc )
( nm, nc ) =
Util.Update.andThen1
[ update flags (TagIncMsg (Comp.Dropdown.SetSelection s.tagsInclude)) >> removeAction
, update flags (TagExcMsg (Comp.Dropdown.SetSelection s.tagsExclude)) >> removeAction
]
im
newSchedule = newSchedule =
Data.CalEvent.fromEvent s.schedule Data.CalEvent.fromEvent s.schedule
|> Maybe.withDefault Data.CalEvent.everyMonth |> Maybe.withDefault Data.CalEvent.everyMonth
@ -132,9 +122,11 @@ initWith flags s =
( cfm, cfc ) = ( cfm, cfc ) =
Comp.ChannelForm.initWith flags s.channel Comp.ChannelForm.initWith flags s.channel
in in
( { nm ( { im
| settings = s | settings = s
, channelModel = cfm , channelModel = cfm
, tagExclModel = Comp.TagDropdown.initWith [] s.tagsExclude
, tagInclModel = Comp.TagDropdown.initWith [] s.tagsInclude
, remindDays = Just s.remindDays , remindDays = Just s.remindDays
, enabled = s.enabled , enabled = s.enabled
, capOverdue = s.capOverdue , capOverdue = s.capOverdue
@ -146,8 +138,7 @@ initWith flags s =
, summary = s.summary , summary = s.summary
} }
, Cmd.batch , Cmd.batch
[ nc [ ic
, ic
, Cmd.map CalEventMsg sc , Cmd.map CalEventMsg sc
, Cmd.map ChannelMsg cfc , Cmd.map ChannelMsg cfc
] ]
@ -168,8 +159,8 @@ init flags ct =
in in
( { settings = Data.PeriodicDueItemsSettings.empty ct ( { settings = Data.PeriodicDueItemsSettings.empty ct
, channelModel = cfm , channelModel = cfm
, tagInclModel = Util.Tag.makeDropdownModel , tagInclModel = Comp.TagDropdown.initWith [] []
, tagExclModel = Util.Tag.makeDropdownModel , tagExclModel = Comp.TagDropdown.initWith [] []
, remindDays = Just 1 , remindDays = Just 1
, remindDaysModel = Comp.IntField.init (Just 1) Nothing True , remindDaysModel = Comp.IntField.init (Just 1) Nothing True
, enabled = False , enabled = False
@ -218,8 +209,8 @@ makeSettings model =
make days timer channel = make days timer channel =
{ prev { prev
| tagsInclude = Comp.Dropdown.getSelected model.tagInclModel | tagsInclude = Comp.TagDropdown.getSelected model.tagInclModel
, tagsExclude = Comp.Dropdown.getSelected model.tagExclModel , tagsExclude = Comp.TagDropdown.getSelected model.tagExclModel
, remindDays = days , remindDays = days
, capOverdue = model.capOverdue , capOverdue = model.capOverdue
, enabled = model.enabled , enabled = model.enabled
@ -283,7 +274,7 @@ update flags msg model =
TagIncMsg m -> TagIncMsg m ->
let let
( m2, c2 ) = ( m2, c2 ) =
Comp.Dropdown.update m model.tagInclModel Comp.TagDropdown.update m model.tagInclModel
in in
( { model ( { model
| tagInclModel = m2 | tagInclModel = m2
@ -296,7 +287,7 @@ update flags msg model =
TagExcMsg m -> TagExcMsg m ->
let let
( m2, c2 ) = ( m2, c2 ) =
Comp.Dropdown.update m model.tagExclModel Comp.TagDropdown.update m model.tagExclModel
in in
( { model ( { model
| tagExclModel = m2 | tagExclModel = m2
@ -308,20 +299,20 @@ update flags msg model =
GetTagsResp (Ok tags) -> GetTagsResp (Ok tags) ->
let let
tagList = incModel =
Comp.Dropdown.SetOptions tags.items Comp.TagDropdown.initWith tags.items model.settings.tagsInclude
removeAction ( tm, _, tc ) = excModel =
( tm, tc ) Comp.TagDropdown.initWith tags.items model.settings.tagsExclude
( m, c ) = newModel =
Util.Update.andThen1 { model
[ update flags (TagIncMsg tagList) >> removeAction | loading = model.loading - 1
, update flags (TagExcMsg tagList) >> removeAction , tagExclModel = excModel
] , tagInclModel = incModel
{ model | loading = model.loading - 1 } }
in in
( m, NoAction, c ) ( newModel, NoAction, Cmd.none )
GetTagsResp (Err err) -> GetTagsResp (Err err) ->
( { model ( { model
@ -556,9 +547,10 @@ view2 texts extraClasses settings model =
[ label [ class S.inputLabel ] [ label [ class S.inputLabel ]
[ text texts.tagsInclude ] [ text texts.tagsInclude ]
, Html.map TagIncMsg , Html.map TagIncMsg
(Comp.Dropdown.view2 (Comp.TagDropdown.view
(Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle) texts.tagDropdown
settings settings
DS.mainStyle
model.tagInclModel model.tagInclModel
) )
, span [ class "opacity-50 text-sm" ] , span [ class "opacity-50 text-sm" ]
@ -569,9 +561,10 @@ view2 texts extraClasses settings model =
[ label [ class S.inputLabel ] [ label [ class S.inputLabel ]
[ text texts.tagsExclude ] [ text texts.tagsExclude ]
, Html.map TagExcMsg , Html.map TagExcMsg
(Comp.Dropdown.view2 (Comp.TagDropdown.view
(Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle) texts.tagDropdown
settings settings
DS.mainStyle
model.tagExclModel model.tagExclModel
) )
, span [ class "opacity-50 text-sm" ] , span [ class "opacity-50 text-sm" ]

View File

@ -21,7 +21,7 @@ import Comp.ItemDetail.Model
) )
import Comp.KeyInput import Comp.KeyInput
import Comp.Tabs as TB import Comp.Tabs as TB
import Data.Direction import Comp.TagDropdown
import Data.DropdownStyle import Data.DropdownStyle
import Data.Fields import Data.Fields
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
@ -38,7 +38,6 @@ import Set exposing (Set)
import Styles as S import Styles as S
import Util.Folder import Util.Folder
import Util.Person import Util.Person
import Util.Tag
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
@ -213,10 +212,7 @@ formTabs texts flags settings model =
, body = , body =
[ div [ class "mb-4 flex flex-col" ] [ div [ class "mb-4 flex flex-col" ]
[ Html.map TagDropdownMsg [ Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings texts.basics.chooseTag dds) (Comp.TagDropdown.view texts.tagDropdown settings dds model.tagModel)
settings
model.tagModel
)
, div [ class "flex flex-row items-center justify-end" ] , div [ class "flex flex-row items-center justify-end" ]
[ a [ a
[ class S.secondaryButton [ class S.secondaryButton

View File

@ -53,6 +53,7 @@ import Comp.KeyInput
import Comp.LinkTarget exposing (LinkTarget) import Comp.LinkTarget exposing (LinkTarget)
import Comp.MarkdownInput import Comp.MarkdownInput
import Comp.SentMails import Comp.SentMails
import Comp.TagDropdown
import Data.Direction exposing (Direction) import Data.Direction exposing (Direction)
import Data.Fields exposing (Field) import Data.Fields exposing (Field)
import DatePicker exposing (DatePicker) import DatePicker exposing (DatePicker)
@ -73,7 +74,7 @@ type alias Model =
, visibleAttach : Int , visibleAttach : Int
, attachMenuOpen : Bool , attachMenuOpen : Bool
, menuOpen : Bool , menuOpen : Bool
, tagModel : Comp.Dropdown.Model Tag , tagModel : Comp.TagDropdown.Model
, directionModel : Comp.Dropdown.Model Direction , directionModel : Comp.Dropdown.Model Direction
, corrOrgModel : Comp.Dropdown.Model IdName , corrOrgModel : Comp.Dropdown.Model IdName
, corrPersonModel : Comp.Dropdown.Model IdName , corrPersonModel : Comp.Dropdown.Model IdName
@ -204,7 +205,7 @@ emptyModel =
, visibleAttach = 0 , visibleAttach = 0
, attachMenuOpen = False , attachMenuOpen = False
, menuOpen = False , menuOpen = False
, tagModel = Util.Tag.makeDropdownModel , tagModel = Comp.TagDropdown.emptyModel
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ options = Data.Direction.all { options = Data.Direction.all
@ -272,7 +273,7 @@ type Msg
| SetItem ItemDetail | SetItem ItemDetail
| SetActiveAttachment Int | SetActiveAttachment Int
| ToggleAttachment String | ToggleAttachment String
| TagDropdownMsg (Comp.Dropdown.Msg Tag) | TagDropdownMsg Comp.TagDropdown.Msg
| DirDropdownMsg (Comp.Dropdown.Msg Direction) | DirDropdownMsg (Comp.Dropdown.Msg Direction)
| OrgDropdownMsg (Comp.Dropdown.Msg IdName) | OrgDropdownMsg (Comp.Dropdown.Msg IdName)
| CorrPersonMsg (Comp.Dropdown.Msg IdName) | CorrPersonMsg (Comp.Dropdown.Msg IdName)

View File

@ -32,6 +32,7 @@ import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..), tabName) import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..), tabName)
import Comp.ItemDetail.FormChange exposing (FormChange(..)) import Comp.ItemDetail.FormChange exposing (FormChange(..))
import Comp.Tabs as TB import Comp.Tabs as TB
import Comp.TagDropdown
import Data.CustomFieldChange exposing (CustomFieldChange(..)) import Data.CustomFieldChange exposing (CustomFieldChange(..))
import Data.Direction exposing (Direction) import Data.Direction exposing (Direction)
import Data.DropdownStyle import Data.DropdownStyle
@ -60,7 +61,6 @@ import Time
import Util.Folder import Util.Folder
import Util.List import Util.List
import Util.Maybe import Util.Maybe
import Util.Tag
@ -80,7 +80,7 @@ type TagEditMode
type alias Model = type alias Model =
{ tagModel : Comp.Dropdown.Model Tag { tagModel : Comp.TagDropdown.Model
, nameModel : String , nameModel : String
, nameSaveThrottle : Throttle Msg , nameSaveThrottle : Throttle Msg
, folderModel : Comp.Dropdown.Model IdName , folderModel : Comp.Dropdown.Model IdName
@ -112,13 +112,12 @@ type Msg
| ConfirmMsg Bool | ConfirmMsg Bool
| ToggleTagEditMode | ToggleTagEditMode
| FolderDropdownMsg (Comp.Dropdown.Msg IdName) | FolderDropdownMsg (Comp.Dropdown.Msg IdName)
| TagDropdownMsg (Comp.Dropdown.Msg Tag) | TagDropdownMsg Comp.TagDropdown.Msg
| DirDropdownMsg (Comp.Dropdown.Msg Direction) | DirDropdownMsg (Comp.Dropdown.Msg Direction)
| OrgDropdownMsg (Comp.Dropdown.Msg IdName) | OrgDropdownMsg (Comp.Dropdown.Msg IdName)
| CorrPersonMsg (Comp.Dropdown.Msg IdName) | CorrPersonMsg (Comp.Dropdown.Msg IdName)
| ConcPersonMsg (Comp.Dropdown.Msg IdName) | ConcPersonMsg (Comp.Dropdown.Msg IdName)
| ConcEquipMsg (Comp.Dropdown.Msg IdName) | ConcEquipMsg (Comp.Dropdown.Msg IdName)
| GetTagsResp (Result Http.Error TagList)
| GetOrgResp (Result Http.Error ReferenceList) | GetOrgResp (Result Http.Error ReferenceList)
| GetPersonResp (Result Http.Error PersonList) | GetPersonResp (Result Http.Error PersonList)
| GetEquipResp (Result Http.Error EquipmentList) | GetEquipResp (Result Http.Error EquipmentList)
@ -129,7 +128,7 @@ type Msg
init : Model init : Model
init = init =
{ tagModel = Util.Tag.makeDropdownModel { tagModel = Comp.TagDropdown.initWith [] []
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
{ options = Data.Direction.all { options = Data.Direction.all
@ -159,16 +158,19 @@ loadModel flags =
let let
( _, dpc ) = ( _, dpc ) =
Comp.DatePicker.init Comp.DatePicker.init
( _, tc ) =
Comp.TagDropdown.init flags
in in
Cmd.batch Cmd.batch
[ Api.getTags flags "" Data.TagOrder.NameAsc GetTagsResp [ Api.getOrgLight flags GetOrgResp
, Api.getOrgLight flags GetOrgResp
, Api.getPersons flags "" Data.PersonOrder.NameAsc GetPersonResp , Api.getPersons flags "" Data.PersonOrder.NameAsc GetPersonResp
, Api.getEquipments flags "" Data.EquipmentOrder.NameAsc GetEquipResp , Api.getEquipments flags "" Data.EquipmentOrder.NameAsc GetEquipResp
, Api.getFolders flags "" Data.FolderOrder.NameAsc False GetFolderResp , Api.getFolders flags "" Data.FolderOrder.NameAsc False GetFolderResp
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags) , Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags)
, Cmd.map ItemDatePickerMsg dpc , Cmd.map ItemDatePickerMsg dpc
, Cmd.map DueDatePickerMsg dpc , Cmd.map DueDatePickerMsg dpc
, Cmd.map TagDropdownMsg tc
] ]
@ -213,8 +215,8 @@ update flags msg model =
TagDropdownMsg m -> TagDropdownMsg m ->
let let
( m2, _ ) = ( m2, c2 ) =
Comp.Dropdown.update m model.tagModel Comp.TagDropdown.update m model.tagModel
newModel = newModel =
{ model | tagModel = m2 } { model | tagModel = m2 }
@ -231,8 +233,8 @@ update flags msg model =
ReplaceTagChange list ReplaceTagChange list
change = change =
if isDropdownChangeMsg m then if Comp.TagDropdown.isChangeMsg m then
Comp.Dropdown.getSelected newModel.tagModel Comp.TagDropdown.getSelected newModel.tagModel
|> Util.List.distinct |> Util.List.distinct
|> List.map (\t -> IdName t.id t.name) |> List.map (\t -> IdName t.id t.name)
|> ReferenceList |> ReferenceList
@ -241,12 +243,12 @@ update flags msg model =
else else
NoFormChange NoFormChange
in in
resultNoCmd change newModel UpdateResult newModel (Cmd.map TagDropdownMsg c2) Sub.none change
ToggleTagEditMode -> ToggleTagEditMode ->
let let
( m2, _ ) = ( m2, _ ) =
Comp.Dropdown.update (Comp.Dropdown.SetSelection []) model.tagModel Comp.TagDropdown.update (Comp.TagDropdown.setSelected []) model.tagModel
newModel = newModel =
{ model | tagModel = m2 } { model | tagModel = m2 }
@ -261,16 +263,6 @@ update flags msg model =
ReplaceTags -> ReplaceTags ->
resultNone { newModel | tagEditMode = AddTags } resultNone { newModel | tagEditMode = AddTags }
GetTagsResp (Ok tags) ->
let
tagList =
Comp.Dropdown.SetOptions tags.items
in
update flags (TagDropdownMsg tagList) model
GetTagsResp (Err _) ->
resultNone model
FolderDropdownMsg m -> FolderDropdownMsg m ->
let let
( m2, _ ) = ( m2, _ ) =
@ -756,8 +748,10 @@ renderEditForm2 texts flags cfg settings model =
] ]
] ]
, Html.map TagDropdownMsg , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Util.Tag.tagSettings texts.basics.chooseTag dds) (Comp.TagDropdown.view
texts.tagDropdown
settings settings
dds
model.tagModel model.tagModel
) )
, Markdown.toHtml [ class "opacity-50 text-sm" ] tagModeMsg , Markdown.toHtml [ class "opacity-50 text-sm" ] tagModeMsg

View File

@ -57,6 +57,7 @@ import Comp.MarkdownInput
import Comp.OrgForm import Comp.OrgForm
import Comp.PersonForm import Comp.PersonForm
import Comp.SentMails import Comp.SentMails
import Comp.TagDropdown
import Data.CustomFieldChange exposing (CustomFieldChange(..)) import Data.CustomFieldChange exposing (CustomFieldChange(..))
import Data.Direction import Data.Direction
import Data.EquipmentOrder import Data.EquipmentOrder
@ -124,7 +125,7 @@ update key flags inav settings msg model =
flags flags
inav inav
settings settings
(TagDropdownMsg (Comp.Dropdown.SetSelection item.tags)) (TagDropdownMsg (Comp.TagDropdown.setSelected item.tags))
model model
res2 = res2 =
@ -348,13 +349,13 @@ update key flags inav settings msg model =
TagDropdownMsg m -> TagDropdownMsg m ->
let let
( m2, c2 ) = ( m2, c2 ) =
Comp.Dropdown.update m model.tagModel Comp.TagDropdown.update m model.tagModel
newModel = newModel =
{ model | tagModel = m2 } { model | tagModel = m2 }
save = save =
if isDropdownChangeMsg m then if Comp.TagDropdown.isChangeMsg m then
saveTags flags newModel saveTags flags newModel
else else
@ -615,10 +616,13 @@ update key flags inav settings msg model =
GetTagsResp (Ok tags) -> GetTagsResp (Ok tags) ->
let let
tagList = tagModel =
Comp.Dropdown.SetOptions tags.items Comp.TagDropdown.initWith tags.items model.item.tags
newModel =
{ model | allTags = tags.items, tagModel = tagModel }
in in
update key flags inav settings (TagDropdownMsg tagList) { model | allTags = tags.items } resultModel newModel
GetTagsResp (Err _) -> GetTagsResp (Err _) ->
resultModel model resultModel model
@ -1645,7 +1649,7 @@ saveTags : Flags -> Model -> Cmd Msg
saveTags flags model = saveTags flags model =
let let
tags = tags =
Comp.Dropdown.getSelected model.tagModel Comp.TagDropdown.getSelected model.tagModel
|> Util.List.distinct |> Util.List.distinct
|> List.map (\t -> t.id) |> List.map (\t -> t.id)
|> StringList |> StringList

View File

@ -22,7 +22,7 @@ import Api.Model.IdName exposing (IdName)
import Api.Model.ImapSettingsList exposing (ImapSettingsList) import Api.Model.ImapSettingsList exposing (ImapSettingsList)
import Api.Model.ScanMailboxSettings exposing (ScanMailboxSettings) import Api.Model.ScanMailboxSettings exposing (ScanMailboxSettings)
import Api.Model.StringList exposing (StringList) import Api.Model.StringList exposing (StringList)
import Api.Model.Tag exposing (Tag) import Api.Model.Tag
import Api.Model.TagList exposing (TagList) import Api.Model.TagList exposing (TagList)
import Comp.Basic as B import Comp.Basic as B
import Comp.CalEventInput import Comp.CalEventInput
@ -32,6 +32,7 @@ import Comp.IntField
import Comp.MenuBar as MB import Comp.MenuBar as MB
import Comp.StringListInput import Comp.StringListInput
import Comp.Tabs import Comp.Tabs
import Comp.TagDropdown
import Comp.YesNoDimmer import Comp.YesNoDimmer
import Data.CalEvent exposing (CalEvent) import Data.CalEvent exposing (CalEvent)
import Data.Direction exposing (Direction(..)) import Data.Direction exposing (Direction(..))
@ -51,10 +52,9 @@ import Messages.Comp.ScanMailboxForm exposing (Texts)
import Messages.Data.Language import Messages.Data.Language
import Set exposing (Set) import Set exposing (Set)
import Styles as S import Styles as S
import Util.Folder exposing (mkFolderOption) import Util.Folder
import Util.List import Util.List
import Util.Maybe import Util.Maybe
import Util.Tag
import Util.Update import Util.Update
@ -77,7 +77,7 @@ type alias Model =
, folderModel : Comp.Dropdown.Model IdName , folderModel : Comp.Dropdown.Model IdName
, allFolders : List FolderItem , allFolders : List FolderItem
, itemFolderId : Maybe String , itemFolderId : Maybe String
, tagModel : Comp.Dropdown.Model Tag , tagModel : Comp.TagDropdown.Model
, existingTags : List String , existingTags : List String
, fileFilter : Maybe String , fileFilter : Maybe String
, subjectFilter : Maybe String , subjectFilter : Maybe String
@ -161,7 +161,7 @@ type Msg
| GetFolderResp (Result Http.Error FolderList) | GetFolderResp (Result Http.Error FolderList)
| FolderDropdownMsg (Comp.Dropdown.Msg IdName) | FolderDropdownMsg (Comp.Dropdown.Msg IdName)
| GetTagResp (Result Http.Error TagList) | GetTagResp (Result Http.Error TagList)
| TagDropdownMsg (Comp.Dropdown.Msg Tag) | TagDropdownMsg Comp.TagDropdown.Msg
| SetFileFilter String | SetFileFilter String
| SetSubjectFilter String | SetSubjectFilter String
| LanguageMsg (Comp.FixedDropdown.Msg Language) | LanguageMsg (Comp.FixedDropdown.Msg Language)
@ -206,7 +206,7 @@ initWith flags s =
, formState = FormStateInitial , formState = FormStateInitial
, yesNoDelete = Comp.YesNoDimmer.emptyModel , yesNoDelete = Comp.YesNoDimmer.emptyModel
, itemFolderId = s.itemFolder , itemFolderId = s.itemFolder
, tagModel = Util.Tag.makeDropdownModel , tagModel = Comp.TagDropdown.initWith [] []
, existingTags = , existingTags =
Maybe.map .items s.tags Maybe.map .items s.tags
|> Maybe.withDefault [] |> Maybe.withDefault []
@ -256,7 +256,7 @@ init flags =
, folderModel = Comp.Dropdown.makeSingle , folderModel = Comp.Dropdown.makeSingle
, allFolders = [] , allFolders = []
, itemFolderId = Nothing , itemFolderId = Nothing
, tagModel = Util.Tag.makeDropdownModel , tagModel = Comp.TagDropdown.initWith [] []
, existingTags = [] , existingTags = []
, fileFilter = Nothing , fileFilter = Nothing
, subjectFilter = Nothing , subjectFilter = Nothing
@ -322,7 +322,7 @@ makeSettings model =
, fileFilter = model.fileFilter , fileFilter = model.fileFilter
, subjectFilter = model.subjectFilter , subjectFilter = model.subjectFilter
, tags = , tags =
case Comp.Dropdown.getSelected model.tagModel of case Comp.TagDropdown.getSelected model.tagModel of
[] -> [] ->
Nothing Nothing
@ -628,17 +628,9 @@ update flags msg model =
selected = selected =
List.filter isExistingTag list.items List.filter isExistingTag list.items
|> Comp.Dropdown.SetSelection
opts = tagModel_ =
Comp.Dropdown.SetOptions list.items Comp.TagDropdown.initWith list.items selected
( tagModel_, tagcmd ) =
Util.Update.andThen1
[ Comp.Dropdown.update selected
, Comp.Dropdown.update opts
]
model.tagModel
nextModel = nextModel =
{ model { model
@ -648,7 +640,7 @@ update flags msg model =
in in
( nextModel ( nextModel
, NoAction , NoAction
, Cmd.map TagDropdownMsg tagcmd , Cmd.none
) )
GetTagResp (Err _) -> GetTagResp (Err _) ->
@ -660,7 +652,7 @@ update flags msg model =
TagDropdownMsg lm -> TagDropdownMsg lm ->
let let
( m2, c2 ) = ( m2, c2 ) =
Comp.Dropdown.update lm model.tagModel Comp.TagDropdown.update lm model.tagModel
newModel = newModel =
{ model | tagModel = m2 } { model | tagModel = m2 }
@ -1177,9 +1169,10 @@ viewMetadata2 texts flags settings model =
[ label [ class S.inputLabel ] [ label [ class S.inputLabel ]
[ text texts.basics.tags ] [ text texts.basics.tags ]
, Html.map TagDropdownMsg , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Comp.TagDropdown.view
(Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle) texts.tagDropdown
settings settings
DS.mainStyle
model.tagModel model.tagModel
) )
, div [ class "opacity-50 text-sm" ] , div [ class "opacity-50 text-sm" ]

View File

@ -25,12 +25,12 @@ import Api.Model.TagList exposing (TagList)
import Comp.Basic as B import Comp.Basic as B
import Comp.Dropdown exposing (isDropdownChangeMsg) import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.FixedDropdown import Comp.FixedDropdown
import Comp.TagDropdown
import Data.DropdownStyle as DS import Data.DropdownStyle as DS
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.FolderOrder import Data.FolderOrder
import Data.Language exposing (Language) import Data.Language exposing (Language)
import Data.Priority exposing (Priority) import Data.Priority exposing (Priority)
import Data.TagOrder
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
@ -41,7 +41,6 @@ import Messages.Comp.SourceForm exposing (Texts)
import Styles as S import Styles as S
import Util.Folder exposing (mkFolderOption) import Util.Folder exposing (mkFolderOption)
import Util.Maybe import Util.Maybe
import Util.Tag
import Util.Update import Util.Update
@ -55,7 +54,7 @@ type alias Model =
, folderModel : Comp.Dropdown.Model IdName , folderModel : Comp.Dropdown.Model IdName
, allFolders : List FolderItem , allFolders : List FolderItem
, folderId : Maybe String , folderId : Maybe String
, tagModel : Comp.Dropdown.Model Tag , tagModel : Comp.TagDropdown.Model
, fileFilter : Maybe String , fileFilter : Maybe String
, languageModel : Comp.Dropdown.Model Language , languageModel : Comp.Dropdown.Model Language
, language : Maybe String , language : Maybe String
@ -75,7 +74,7 @@ emptyModel =
, folderModel = Comp.Dropdown.makeSingle , folderModel = Comp.Dropdown.makeSingle
, allFolders = [] , allFolders = []
, folderId = Nothing , folderId = Nothing
, tagModel = Util.Tag.makeDropdownModel , tagModel = Comp.TagDropdown.initWith [] []
, fileFilter = Nothing , fileFilter = Nothing
, languageModel = , languageModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
@ -89,10 +88,14 @@ emptyModel =
init : Flags -> ( Model, Cmd Msg ) init : Flags -> ( Model, Cmd Msg )
init flags = init flags =
( emptyModel let
( tm, tc ) =
Comp.TagDropdown.init flags
in
( { emptyModel | tagModel = tm }
, Cmd.batch , Cmd.batch
[ Api.getFolders flags "" Data.FolderOrder.NameAsc False GetFolderResp [ Api.getFolders flags "" Data.FolderOrder.NameAsc False GetFolderResp
, Api.getTags flags "" Data.TagOrder.NameAsc GetTagResp , Cmd.map TagDropdownMsg tc
] ]
) )
@ -112,7 +115,7 @@ getSource model =
st.source st.source
tags = tags =
Comp.Dropdown.getSelected model.tagModel Comp.TagDropdown.getSelected model.tagModel
n = n =
{ s { s
@ -137,8 +140,7 @@ type Msg
| PrioDropdownMsg (Comp.FixedDropdown.Msg Priority) | PrioDropdownMsg (Comp.FixedDropdown.Msg Priority)
| GetFolderResp (Result Http.Error FolderList) | GetFolderResp (Result Http.Error FolderList)
| FolderDropdownMsg (Comp.Dropdown.Msg IdName) | FolderDropdownMsg (Comp.Dropdown.Msg IdName)
| GetTagResp (Result Http.Error TagList) | TagDropdownMsg Comp.TagDropdown.Msg
| TagDropdownMsg (Comp.Dropdown.Msg Tag)
| SetFileFilter String | SetFileFilter String
| LanguageMsg (Comp.Dropdown.Msg Language) | LanguageMsg (Comp.Dropdown.Msg Language)
| ToggleAttachmentsOnly | ToggleAttachmentsOnly
@ -213,7 +215,7 @@ update flags msg model =
[] []
tags = tags =
Comp.Dropdown.SetSelection t.tags.items Comp.TagDropdown.setSelected t.tags.items
in in
Util.Update.andThen1 Util.Update.andThen1
[ update flags (FolderDropdownMsg (Comp.Dropdown.SetSelection sel)) [ update flags (FolderDropdownMsg (Comp.Dropdown.SetSelection sel))
@ -286,20 +288,10 @@ update flags msg model =
in in
( model_, Cmd.map FolderDropdownMsg c2 ) ( model_, Cmd.map FolderDropdownMsg c2 )
GetTagResp (Ok list) ->
let
opts =
Comp.Dropdown.SetOptions list.items
in
update flags (TagDropdownMsg opts) model
GetTagResp (Err _) ->
( model, Cmd.none )
TagDropdownMsg lm -> TagDropdownMsg lm ->
let let
( m2, c2 ) = ( m2, c2 ) =
Comp.Dropdown.update lm model.tagModel Comp.TagDropdown.update lm model.tagModel
newModel = newModel =
{ model | tagModel = m2 } { model | tagModel = m2 }
@ -348,9 +340,6 @@ view2 flags texts settings model =
, style = DS.mainStyle , style = DS.mainStyle
} }
tagCfg =
Util.Tag.tagSettings texts.basics.chooseTag DS.mainStyle
languageCfg = languageCfg =
{ makeOption = { makeOption =
\a -> \a ->
@ -477,9 +466,10 @@ view2 flags texts settings model =
[ text texts.basics.tags [ text texts.basics.tags
] ]
, Html.map TagDropdownMsg , Html.map TagDropdownMsg
(Comp.Dropdown.view2 (Comp.TagDropdown.view
tagCfg texts.tagDropdown
settings settings
DS.mainStyle
model.tagModel model.tagModel
) )
, div [ class "opacity-50 text-sm" ] , div [ class "opacity-50 text-sm" ]

View File

@ -70,7 +70,7 @@ searchMenuStyle =
{ rootClasses = "border-0 " { rootClasses = "border-0 "
, tabClasses = "border-0 " , tabClasses = "border-0 "
, titleClasses = "py-4 md:py-2 pl-2 bg-blue-50 hover:bg-blue-100 dark:bg-slate-700 dark:hover:bg-opacity-100 dark:hover:bg-slate-600 rounded" , titleClasses = "py-4 md:py-2 pl-2 bg-blue-50 hover:bg-blue-100 dark:bg-slate-700 dark:hover:bg-opacity-100 dark:hover:bg-slate-600 rounded"
, bodyClasses = "mt-1 py-1 pl-2" , bodyClasses = "mt-1 pl-2"
} }

View File

@ -0,0 +1,264 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.TagDropdown exposing
( Model
, Msg
, emptyModel
, getSelected
, init
, initSelected
, initWith
, isChangeMsg
, setSelected
, update
, view
)
import Api
import Api.Model.Tag exposing (Tag)
import Api.Model.TagList exposing (TagList)
import Comp.Dropdown
import Data.DropdownStyle exposing (DropdownStyle)
import Data.Flags exposing (Flags)
import Data.TagOrder
import Data.UiSettings exposing (UiSettings)
import Html exposing (Html, a, div, i)
import Html.Attributes exposing (class, classList, href, title)
import Html.Events exposing (onClick)
import Messages.Comp.TagDropdown exposing (Texts)
import Util.List
type alias Model =
{ ddm : Comp.Dropdown.Model Tag
, allTags : List Tag
, constrainedCat : Maybe String
}
type Msg
= DropdownMsg (Comp.Dropdown.Msg Tag)
| GetTagsResp TagList
| ConstrainCat String
emptyModel : Model
emptyModel =
{ ddm = makeDropdownModel
, allTags = []
, constrainedCat = Nothing
}
init : Flags -> ( Model, Cmd Msg )
init flags =
( emptyModel, getOptions flags )
initSelected : Flags -> List Tag -> ( Model, Cmd Msg )
initSelected flags selected =
( update (setSelected selected) emptyModel
|> Tuple.first
, getOptions flags
)
initWith : List Tag -> List Tag -> Model
initWith options selected =
update (setSelected selected) emptyModel
|> Tuple.first
|> update (setOptions options)
|> Tuple.first
getSelected : Model -> List Tag
getSelected model =
Comp.Dropdown.getSelected model.ddm
setOptions : List Tag -> Msg
setOptions tags =
GetTagsResp (TagList 0 tags)
setSelected : List Tag -> Msg
setSelected tags =
DropdownMsg (Comp.Dropdown.SetSelection tags)
isChangeMsg : Msg -> Bool
isChangeMsg msg =
case msg of
DropdownMsg m ->
Comp.Dropdown.isDropdownChangeMsg m
_ ->
False
isConstrained : Model -> String -> Bool
isConstrained model category =
model.constrainedCat == Just category
--- api
getOptions : Flags -> Cmd Msg
getOptions flags =
Api.getTagsIgnoreError flags "" Data.TagOrder.NameAsc GetTagsResp
--- update
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
DropdownMsg lm ->
let
( dm, dc ) =
Comp.Dropdown.update lm model.ddm
in
( { model
| ddm = dm
, constrainedCat =
if isChangeMsg msg then
Nothing
else
model.constrainedCat
}
, Cmd.map DropdownMsg dc
)
GetTagsResp list ->
let
newModel =
{ model | allTags = list.items }
ddMsg =
Comp.Dropdown.SetOptions newModel.allTags
in
update (DropdownMsg ddMsg) newModel
ConstrainCat cat ->
let
setOpts tags =
DropdownMsg (Comp.Dropdown.SetOptions tags)
in
if model.constrainedCat == Just cat then
update (setOpts model.allTags)
{ model | constrainedCat = Nothing }
else
update (setOpts <| List.filter (isCategory cat) model.allTags)
{ model | constrainedCat = Just cat }
isCategory : String -> Tag -> Bool
isCategory cat tag =
tag.category == Just cat || (tag.category == Nothing && cat == "")
--- view
view : Texts -> UiSettings -> DropdownStyle -> Model -> Html Msg
view texts settings dds model =
let
viewSettings =
tagSettings texts.placeholder dds
in
div [ class "flex flex-col" ]
[ viewCategorySelect texts settings model
, Html.map DropdownMsg (Comp.Dropdown.view2 viewSettings settings model.ddm)
]
viewCategorySelect : Texts -> UiSettings -> Model -> Html Msg
viewCategorySelect texts settings model =
let
categories =
List.map .category model.allTags
|> List.map (Maybe.withDefault "")
|> Util.List.distinct
|> List.sort
catFilterLink cat =
a
[ classList
[ ( "opacity-75", not (isConstrained model cat) )
]
, href "#"
, title <|
if cat == "" then
texts.noCategory
else
cat
, onClick (ConstrainCat cat)
]
[ if cat == "" then
i
[ class <|
if isConstrained model cat then
"fa fa-check-circle font-thin"
else
"fa fa-circle font-thin"
]
[]
else
i
[ classList
[ ( "fa fa-circle", not (isConstrained model cat) )
, ( "fa fa-check-circle", isConstrained model cat )
]
, class <| Data.UiSettings.catColorFg2 settings cat
]
[]
]
in
div
[ class "flex-wrap space-x-1 text-xl sm:text-sm "
, classList [ ( "hidden", not model.ddm.menuOpen ) ]
]
(List.map catFilterLink categories)
--- private helper
makeDropdownModel : Comp.Dropdown.Model Tag
makeDropdownModel =
let
m =
Comp.Dropdown.makeModel
{ multiple = True
, searchable = \n -> n > 0
}
in
{ m | searchWithAdditional = True }
tagSettings : String -> DropdownStyle -> Comp.Dropdown.ViewSettings Tag
tagSettings placeholder ds =
{ makeOption = \tag -> { text = tag.name, additional = Maybe.withDefault "" tag.category }
, labelColor =
\tag ->
\settings ->
Data.UiSettings.tagColorString2 tag settings
, placeholder = placeholder
, style = ds
}

View File

@ -243,7 +243,7 @@ toStringFg2 color =
"text-purple-600 dark:text-purple-400" "text-purple-600 dark:text-purple-400"
Pink -> Pink ->
"text-pink-600 text:text-pink-400" "text-pink-600 dark:text-pink-400"
Brown -> Brown ->
"text-amber-700 dark:text-amber-700" "text-amber-700 dark:text-amber-700"

View File

@ -16,6 +16,7 @@ import Messages.Basics
import Messages.Comp.CalEventInput import Messages.Comp.CalEventInput
import Messages.Comp.ChannelForm import Messages.Comp.ChannelForm
import Messages.Comp.HttpError import Messages.Comp.HttpError
import Messages.Comp.TagDropdown
import Messages.Data.ChannelType import Messages.Data.ChannelType
@ -24,6 +25,7 @@ type alias Texts =
, calEventInput : Messages.Comp.CalEventInput.Texts , calEventInput : Messages.Comp.CalEventInput.Texts
, httpError : Http.Error -> String , httpError : Http.Error -> String
, channelForm : Messages.Comp.ChannelForm.Texts , channelForm : Messages.Comp.ChannelForm.Texts
, tagDropdown : Messages.Comp.TagDropdown.Texts
, reallyDeleteTask : String , reallyDeleteTask : String
, startOnce : String , startOnce : String
, startTaskNow : String , startTaskNow : String
@ -58,6 +60,7 @@ gb =
, calEventInput = Messages.Comp.CalEventInput.gb , calEventInput = Messages.Comp.CalEventInput.gb
, httpError = Messages.Comp.HttpError.gb , httpError = Messages.Comp.HttpError.gb
, channelForm = Messages.Comp.ChannelForm.gb , channelForm = Messages.Comp.ChannelForm.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, reallyDeleteTask = "Really delete this notification task?" , reallyDeleteTask = "Really delete this notification task?"
, startOnce = "Start Once" , startOnce = "Start Once"
, startTaskNow = "Start this task now" , startTaskNow = "Start this task now"
@ -96,6 +99,7 @@ de =
, calEventInput = Messages.Comp.CalEventInput.de , calEventInput = Messages.Comp.CalEventInput.de
, httpError = Messages.Comp.HttpError.de , httpError = Messages.Comp.HttpError.de
, channelForm = Messages.Comp.ChannelForm.gb , channelForm = Messages.Comp.ChannelForm.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, reallyDeleteTask = "Diesen Benachrichtigungsauftrag wirklich löschen?" , reallyDeleteTask = "Diesen Benachrichtigungsauftrag wirklich löschen?"
, startOnce = "Jetzt starten" , startOnce = "Jetzt starten"
, startTaskNow = "Starte den Auftrag sofort" , startTaskNow = "Starte den Auftrag sofort"

View File

@ -14,6 +14,7 @@ module Messages.Comp.ItemDetail.EditForm exposing
import Data.Direction exposing (Direction) import Data.Direction exposing (Direction)
import Messages.Basics import Messages.Basics
import Messages.Comp.CustomFieldMultiInput import Messages.Comp.CustomFieldMultiInput
import Messages.Comp.TagDropdown
import Messages.Data.Direction import Messages.Data.Direction
import Messages.DateFormat as DF import Messages.DateFormat as DF
import Messages.UiLanguage import Messages.UiLanguage
@ -22,6 +23,7 @@ import Messages.UiLanguage
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, customFieldInput : Messages.Comp.CustomFieldMultiInput.Texts , customFieldInput : Messages.Comp.CustomFieldMultiInput.Texts
, tagDropdown : Messages.Comp.TagDropdown.Texts
, createNewCustomField : String , createNewCustomField : String
, chooseDirection : String , chooseDirection : String
, dueDateTab : String , dueDateTab : String
@ -45,6 +47,7 @@ gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, customFieldInput = Messages.Comp.CustomFieldMultiInput.gb , customFieldInput = Messages.Comp.CustomFieldMultiInput.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, createNewCustomField = "Create new custom field" , createNewCustomField = "Create new custom field"
, chooseDirection = "Choose a direction" , chooseDirection = "Choose a direction"
, dueDateTab = "Due Date" , dueDateTab = "Due Date"
@ -68,6 +71,7 @@ de : Texts
de = de =
{ basics = Messages.Basics.de { basics = Messages.Basics.de
, customFieldInput = Messages.Comp.CustomFieldMultiInput.de , customFieldInput = Messages.Comp.CustomFieldMultiInput.de
, tagDropdown = Messages.Comp.TagDropdown.de
, createNewCustomField = "Erstelle neues Benutzerfeld" , createNewCustomField = "Erstelle neues Benutzerfeld"
, chooseDirection = "Wähle Richtung" , chooseDirection = "Wähle Richtung"
, dueDateTab = "Fälligkeitsdatum" , dueDateTab = "Fälligkeitsdatum"

View File

@ -14,12 +14,14 @@ module Messages.Comp.ItemDetail.MultiEditMenu exposing
import Data.Direction exposing (Direction) import Data.Direction exposing (Direction)
import Messages.Basics import Messages.Basics
import Messages.Comp.CustomFieldMultiInput import Messages.Comp.CustomFieldMultiInput
import Messages.Comp.TagDropdown
import Messages.Data.Direction import Messages.Data.Direction
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts , customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts
, tagDropdown : Messages.Comp.TagDropdown.Texts
, tagModeAddInfo : String , tagModeAddInfo : String
, tagModeRemoveInfo : String , tagModeRemoveInfo : String
, tagModeReplaceInfo : String , tagModeReplaceInfo : String
@ -37,6 +39,7 @@ gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb , customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, tagModeAddInfo = "Tags chosen here are *added* to all selected items." , tagModeAddInfo = "Tags chosen here are *added* to all selected items."
, tagModeRemoveInfo = "Tags chosen here are *removed* from all selected items." , tagModeRemoveInfo = "Tags chosen here are *removed* from all selected items."
, tagModeReplaceInfo = "Tags chosen here *replace* those on selected items." , tagModeReplaceInfo = "Tags chosen here *replace* those on selected items."
@ -54,6 +57,7 @@ de : Texts
de = de =
{ basics = Messages.Basics.de { basics = Messages.Basics.de
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.de , customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.de
, tagDropdown = Messages.Comp.TagDropdown.de
, tagModeAddInfo = "Tags werden zu gewählten Dokumenten *hinzugefügt*." , tagModeAddInfo = "Tags werden zu gewählten Dokumenten *hinzugefügt*."
, tagModeRemoveInfo = "Tags werden von gewählten Dokumenten *entfernt*." , tagModeRemoveInfo = "Tags werden von gewählten Dokumenten *entfernt*."
, tagModeReplaceInfo = "Tags *ersetzen* die der gewählten Dokumente." , tagModeReplaceInfo = "Tags *ersetzen* die der gewählten Dokumente."

View File

@ -15,12 +15,14 @@ import Http
import Messages.Basics import Messages.Basics
import Messages.Comp.CalEventInput import Messages.Comp.CalEventInput
import Messages.Comp.HttpError import Messages.Comp.HttpError
import Messages.Comp.TagDropdown
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, calEventInput : Messages.Comp.CalEventInput.Texts , calEventInput : Messages.Comp.CalEventInput.Texts
, httpError : Http.Error -> String , httpError : Http.Error -> String
, tagDropdown : Messages.Comp.TagDropdown.Texts
, reallyDeleteTask : String , reallyDeleteTask : String
, startOnce : String , startOnce : String
, startNow : String , startNow : String
@ -83,6 +85,7 @@ gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, calEventInput = Messages.Comp.CalEventInput.gb , calEventInput = Messages.Comp.CalEventInput.gb
, httpError = Messages.Comp.HttpError.gb , httpError = Messages.Comp.HttpError.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, reallyDeleteTask = "Really delete this scan mailbox task?" , reallyDeleteTask = "Really delete this scan mailbox task?"
, startOnce = "Start Once" , startOnce = "Start Once"
, startNow = "Start this task now" , startNow = "Start this task now"
@ -167,6 +170,7 @@ de =
{ basics = Messages.Basics.de { basics = Messages.Basics.de
, calEventInput = Messages.Comp.CalEventInput.de , calEventInput = Messages.Comp.CalEventInput.de
, httpError = Messages.Comp.HttpError.de , httpError = Messages.Comp.HttpError.de
, tagDropdown = Messages.Comp.TagDropdown.de
, reallyDeleteTask = "Den Auftrag wirklich löschen?" , reallyDeleteTask = "Den Auftrag wirklich löschen?"
, startOnce = "Jetzt starten" , startOnce = "Jetzt starten"
, startNow = "Den Auftrag sofort starten" , startNow = "Den Auftrag sofort starten"

View File

@ -13,11 +13,13 @@ module Messages.Comp.SourceForm exposing
import Data.Language exposing (Language) import Data.Language exposing (Language)
import Messages.Basics import Messages.Basics
import Messages.Comp.TagDropdown
import Messages.Data.Language import Messages.Data.Language
type alias Texts = type alias Texts =
{ basics : Messages.Basics.Texts { basics : Messages.Basics.Texts
, tagDropdown : Messages.Comp.TagDropdown.Texts
, description : String , description : String
, enabled : String , enabled : String
, priority : String , priority : String
@ -38,6 +40,7 @@ type alias Texts =
gb : Texts gb : Texts
gb = gb =
{ basics = Messages.Basics.gb { basics = Messages.Basics.gb
, tagDropdown = Messages.Comp.TagDropdown.gb
, description = "Description" , description = "Description"
, enabled = "Enabled" , enabled = "Enabled"
, priority = "Priority" , priority = "Priority"
@ -69,6 +72,7 @@ Specify a file glob to filter files when uploading archives
de : Texts de : Texts
de = de =
{ basics = Messages.Basics.de { basics = Messages.Basics.de
, tagDropdown = Messages.Comp.TagDropdown.de
, description = "Beschreibung" , description = "Beschreibung"
, enabled = "Aktiviert" , enabled = "Aktiviert"
, priority = "Priorität" , priority = "Priorität"

View File

@ -0,0 +1,37 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Messages.Comp.TagDropdown exposing
( Texts
, de
, gb
)
import Messages.Basics
type alias Texts =
{ basics : Messages.Basics.Texts
, placeholder : String
, noCategory : String
}
gb : Texts
gb =
{ basics = Messages.Basics.gb
, placeholder = "Search"
, noCategory = "No category"
}
de : Texts
de =
{ basics = Messages.Basics.de
, placeholder = "Suche"
, noCategory = "Keine Kategorie"
}

View File

@ -9,41 +9,14 @@ module Util.Tag exposing
( catSettings ( catSettings
, getCategories , getCategories
, makeCatDropdownModel , makeCatDropdownModel
, makeDropdownModel
, tagSettings
) )
import Api.Model.Tag exposing (Tag) import Api.Model.Tag exposing (Tag)
import Comp.Dropdown import Comp.Dropdown
import Data.DropdownStyle as DS import Data.DropdownStyle as DS
import Data.UiSettings
import Util.List import Util.List
makeDropdownModel : Comp.Dropdown.Model Tag
makeDropdownModel =
let
init =
Comp.Dropdown.makeModel
{ multiple = True
, searchable = \n -> n > 0
}
in
{ init | searchWithAdditional = True }
tagSettings : String -> DS.DropdownStyle -> Comp.Dropdown.ViewSettings Tag
tagSettings placeholder ds =
{ makeOption = \tag -> { text = tag.name, additional = Maybe.withDefault "" tag.category }
, labelColor =
\tag ->
\settings ->
Data.UiSettings.tagColorString2 tag settings
, placeholder = placeholder
, style = ds
}
makeCatDropdownModel : Comp.Dropdown.Model String makeCatDropdownModel : Comp.Dropdown.Model String
makeCatDropdownModel = makeCatDropdownModel =
Comp.Dropdown.makeModel Comp.Dropdown.makeModel