From dd743cf2730dbc5a10bf4422ee076ca3909e5b3b Mon Sep 17 00:00:00 2001 From: Stefan Scheidewig <stefan.scheidewig@staffbase.com> Date: Sun, 18 Apr 2021 22:27:50 +0200 Subject: [PATCH] Reformatted changed source files with elm-format --- modules/webapp/src/main/elm/Api.elm | 4 +++ .../src/main/elm/Comp/ItemDetail/Model.elm | 5 +++ .../elm/Comp/ItemDetail/SingleAttachment.elm | 33 +++++++++++-------- .../src/main/elm/Comp/ItemDetail/Update.elm | 14 ++++---- .../Comp/ItemDetail/SingleAttachment.elm | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/modules/webapp/src/main/elm/Api.elm b/modules/webapp/src/main/elm/Api.elm index 2f2ea00a..2ecf5171 100644 --- a/modules/webapp/src/main/elm/Api.elm +++ b/modules/webapp/src/main/elm/Api.elm @@ -610,8 +610,11 @@ deleteAttachment flags attachId receive = , expect = Http.expectJson receive Api.Model.BasicResult.decoder } + + --- Delete Attachments + deleteAttachments : Flags -> Set String @@ -626,6 +629,7 @@ deleteAttachments flags attachIds receive = } + --- Attachment Metadata diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm index af0e5f86..04bb61ae 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/Model.elm @@ -111,19 +111,23 @@ type alias Model = , viewMode : ViewMode } + type ViewMode = SimpleView | SelectView SelectViewModel + type alias SelectViewModel = { ids : Set String , action : SelectActionMode } + type SelectActionMode = NoneAction | DeleteSelected + type NotesField = ViewNotes | EditNotes Comp.MarkdownInput.Model @@ -204,6 +208,7 @@ emptyModel = , viewMode = SimpleView } + initSelectViewModel : SelectViewModel initSelectViewModel = { ids = Set.empty diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm index abec8078..a1e87c4d 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/SingleAttachment.elm @@ -114,6 +114,7 @@ attachHeader texts settings model _ attach = case model.viewMode of SelectView _ -> True + _ -> False @@ -121,6 +122,7 @@ attachHeader texts settings model _ attach = case model.viewMode of SelectView _ -> texts.exitSelectMode + _ -> texts.selectModeTitle @@ -163,11 +165,12 @@ attachHeader texts settings model _ attach = [ i [ class "fa fa-eye font-thin" ] [] ] , a - [ classList [ (S.secondaryBasicButton ++ " text-sm", True) - , ( "bg-gray-200 dark:bg-bluegray-600", selectView ) - , ( "hidden", not selectPossible ) - , ( "ml-2", True ) - ] + [ classList + [ ( S.secondaryBasicButton ++ " text-sm", True ) + , ( "bg-gray-200 dark:bg-bluegray-600", selectView ) + , ( "hidden", not selectPossible ) + , ( "ml-2", True ) + ] , href "#" , title selectToggleText , onClick ToggleSelectView @@ -175,11 +178,12 @@ attachHeader texts settings model _ attach = [ i [ class "fa fa-tasks" ] [] ] , a - [ classList [ ( S.deleteButton, True ) - , ( "disabled", noAttachmentsSelected ) - , ( "hidden", not selectPossible || not selectView ) - , ( "ml-2", True ) - ] + [ classList + [ ( S.deleteButton, True ) + , ( "disabled", noAttachmentsSelected ) + , ( "hidden", not selectPossible || not selectView ) + , ( "ml-2", True ) + ] , href "#" , title texts.deleteAttachments , onClick RequestDeleteSelected @@ -356,8 +360,10 @@ menuItem texts model pos attach = SelectView svm -> if Set.member attach.id svm.ids then "fa fa-check-circle ml-1" + else "fa fa-circle ml-1" + _ -> "fa fa-check-circle ml-1" @@ -365,16 +371,17 @@ menuItem texts model pos attach = case model.viewMode of SelectView _ -> True + _ -> model.visibleAttach == pos msg = case model.viewMode of SelectView _ -> - (ToggleAttachment attach.id) - _ -> - (SetActiveAttachment pos) + ToggleAttachment attach.id + _ -> + SetActiveAttachment pos in a ([ classList <| diff --git a/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm b/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm index 95c7513f..65e56c05 100644 --- a/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm +++ b/modules/webapp/src/main/elm/Comp/ItemDetail/Update.elm @@ -24,7 +24,7 @@ import Comp.Dropdown exposing (isDropdownChangeMsg) import Comp.Dropzone import Comp.EquipmentForm import Comp.ItemDetail.FieldTabState as FTabState -import Comp.ItemDetail.Model exposing (AttachmentRename, Model, Msg(..), NotesField(..), SaveNameState(..), SelectActionMode(..), UpdateResult, isEditNotes, resultModel, resultModelCmd, resultModelCmdSub) +import Comp.ItemDetail.Model exposing (AttachmentRename, Model, Msg(..), NotesField(..), SaveNameState(..), SelectActionMode(..), UpdateResult, ViewMode(..), initSelectViewModel, isEditNotes, resultModel, resultModelCmd, resultModelCmdSub) import Comp.ItemMail import Comp.KeyInput import Comp.LinkTarget @@ -44,7 +44,6 @@ import Dict import Html5.DragDrop as DD import Http import Page exposing (Page(..)) -import Comp.ItemDetail.Model exposing (ViewMode(..), initSelectViewModel) import Set exposing (Set) import Throttle import Time @@ -275,11 +274,13 @@ update key flags inav settings msg model = svm_ = if Set.member id svm.ids then { svm | ids = Set.remove id svm.ids } + else { svm | ids = Set.insert id svm.ids } in resultModel { model | viewMode = SelectView svm_ } + _ -> resultModel model @@ -1404,10 +1405,11 @@ update key flags inav settings msg model = withSub ( model_, Cmd.none ) ToggleAttachMenu -> - resultModel { model - | attachMenuOpen = not model.attachMenuOpen - , viewMode = SimpleView - } + resultModel + { model + | attachMenuOpen = not model.attachMenuOpen + , viewMode = SimpleView + } UiSettingsUpdated -> let diff --git a/modules/webapp/src/main/elm/Messages/Comp/ItemDetail/SingleAttachment.elm b/modules/webapp/src/main/elm/Messages/Comp/ItemDetail/SingleAttachment.elm index ec52d724..d7e12583 100644 --- a/modules/webapp/src/main/elm/Messages/Comp/ItemDetail/SingleAttachment.elm +++ b/modules/webapp/src/main/elm/Messages/Comp/ItemDetail/SingleAttachment.elm @@ -17,7 +17,7 @@ type alias Texts = , deleteThisFile : String , selectModeTitle : String , exitSelectMode : String - , deleteAttachments: String + , deleteAttachments : String }