From 965244c08c92f2fbeb8d20c206933b70f16ac61a Mon Sep 17 00:00:00 2001 From: Edward <sabinusedward@yahoo.de> Date: Thu, 11 Jun 2020 19:09:13 +0200 Subject: [PATCH] Update von pictureUrlManager erstellt --- src/Manager/ModalManager.elm | 46 +++++++++++++++++++++++++---------- src/Manager/UpdateManager.elm | 6 +++++ src/Manager/ViewManager.elm | 8 +++++- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/Manager/ModalManager.elm b/src/Manager/ModalManager.elm index c23bc54..9950c09 100644 --- a/src/Manager/ModalManager.elm +++ b/src/Manager/ModalManager.elm @@ -1,4 +1,6 @@ module Manager.ModalManager exposing (..) +-- Url +import Url -- Own import Util.Util exposing (MousePosition) import Util.ShapeManager exposing (..) @@ -9,6 +11,7 @@ type Modal | ShowInput Shape String String | ShowShape Int Int | EditShape Int ShapeStyle + | ShowManagePicUrl String (Maybe Url.Url) type ModalMsg = CloseModal @@ -17,6 +20,7 @@ type ModalMsg | OpenShowInput | OpenShowShape Int Int | OpenEditShape Int ShapeStyle String String + | OpenManagePicUrl String -- for input / delete Shapes | ResetShowInput | Check String @@ -58,6 +62,9 @@ updateModal msg modal = else shapeStyle _ -> shapeStyle ) + OpenManagePicUrl string -> case Url.fromString string of + Just url -> ShowManagePicUrl "" (Just url) + Nothing -> ShowManagePicUrl "Ungültige Url." Nothing ResetShowInput -> ShowInput (deleteCoordsFromShape (getInputShapeFromModal modal) @@ -69,17 +76,19 @@ updateModal msg modal = else modal Input inputType value -> case modal of - NoModal -> modal -- ERROR - ShowTable -> modal -- ERROR - ShowShape _ _ -> modal -- ERROR + NoModal -> modal -- ERROR + ShowTable -> modal -- ERROR + ShowShape _ _ -> modal -- ERROR ShowInput iShape ix iy -> updateInput inputType value modal "ShowInput" iShape ix iy {x = 0, y = 0} - EditShape _ _ -> modal -- ERROR + EditShape _ _ -> modal -- ERROR + ShowManagePicUrl _ _ -> modal -- ERROR InputPoint -> case modal of - NoModal -> modal -- ERROR - ShowTable -> modal -- ERROR - ShowShape _ _ -> modal -- ERROR + NoModal -> modal -- ERROR + ShowTable -> modal -- ERROR + ShowShape _ _ -> modal -- ERROR ShowInput iShape ix iy -> ShowInput (Polygon ((ix,iy)::(getPointListFromPolygon iShape))) "" "" - EditShape _ _ -> modal -- ERROR + EditShape _ _ -> modal -- ERROR + ShowManagePicUrl _ _ -> modal -- ERROR updateInput : Char -> String -> Modal -> String -> Shape -> String -> String -> MousePosition -> Modal updateInput inputType value modal modalType iShape ix iy mouse = case inputType of @@ -118,6 +127,15 @@ modalInputConstruktor modalType shape x y mouse = eq_String_Modal : String -> Modal -> Bool eq_String_Modal string modal = string==(modalNameToString modal) -- Get Methods : Parameter of Modal +getUrlFromModal : Modal -> Maybe Url.Url +getUrlFromModal modal = + case modal of + NoModal -> Nothing + ShowTable -> Nothing + ShowInput _ _ _ -> Nothing + ShowShape _ _ -> Nothing + EditShape _ _ -> Nothing + ShowManagePicUrl _ url -> url getInputShapeFromModal : Modal -> Shape getInputShapeFromModal modal = case modal of @@ -126,12 +144,14 @@ getInputShapeFromModal modal = ShowInput shape _ _ -> shape ShowShape _ _ -> Empty EditShape _ _ -> Empty + ShowManagePicUrl _ _-> Empty -- Transform Modal to other Types modalNameToString : Modal -> String modalNameToString modal = case modal of - NoModal -> "NoModal" - ShowTable -> "ShowTable" - ShowInput _ _ _ -> "ShowInput" - ShowShape _ _ -> "ShowShape" - EditShape _ _ -> "EditShape" \ No newline at end of file + NoModal -> "NoModal" + ShowTable -> "ShowTable" + ShowInput _ _ _ -> "ShowInput" + ShowShape _ _ -> "ShowShape" + EditShape _ _ -> "EditShape" + ShowManagePicUrl _ _-> "ShowManagePicUrl" \ No newline at end of file diff --git a/src/Manager/UpdateManager.elm b/src/Manager/UpdateManager.elm index 0b5c182..af8d802 100644 --- a/src/Manager/UpdateManager.elm +++ b/src/Manager/UpdateManager.elm @@ -31,12 +31,18 @@ updateModel msg model = OpenShowTable -> updateModal modalMsg modal OpenShowShape _ _ -> updateModal modalMsg modal OpenEditShape id ss iT _ -> updateModal (OpenEditShape id ss iT value) modal + OpenManagePicUrl _ -> updateModal modalMsg modal ResetShowInput -> updateModal modalMsg modal Check _ -> updateModal modalMsg modal Input inputType _ -> updateModal (Input inputType value) modal InputPoint -> updateModal modalMsg modal ) ) + , pictureUrl = if (eq_String_Modal "ShowManagePicUrl" modal) + then case getUrlFromModal modal of + Just url -> url + Nothing -> model.pictureUrl + else model.pictureUrl } ManageShapes shapesMsg value-> case shapesMsg of diff --git a/src/Manager/ViewManager.elm b/src/Manager/ViewManager.elm index b7d35b8..5697e7e 100644 --- a/src/Manager/ViewManager.elm +++ b/src/Manager/ViewManager.elm @@ -51,6 +51,7 @@ view model = ) ] EditShape id shapeStyle-> [viewEditShapeModal id shapeStyle] + ShowManagePicUrl s url -> [] -- not implemented ] ) -- Parts of the VIEW @@ -60,7 +61,12 @@ viewHeader_Buttons state = [ div [class "section"] [ h1 [class "title"] [text "ShapePicture Editor"] ] , div [ style "margin-left" "25px"] - [ button [ onClick (ManageModal OpenShowInput "") + [ button [ onClick (ManageModal (OpenManagePicUrl "") "") + , class "button is-success is-pulled-left is-size-6" + , style "margin-bottom" "15px" + , style "margin-right" "15px" + ] [ text "Bild auswählen" ] + , button [ onClick (ManageModal OpenShowInput "") , class "button is-success is-pulled-left is-size-6" , style "margin-bottom" "15px" , style "margin-right" "15px" -- GitLab