Skip to content

Commit

Permalink
Merge branch 'main' into typebuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
bekand committed Sep 6, 2023
2 parents 6feda0a + 83d3ba1 commit 93810ed
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 75 deletions.
4 changes: 2 additions & 2 deletions cli/src/Morphir/Web/DevelopApp.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ viewDecorationValues model node =
editorState
)
)
|> FieldList.view
|> FieldList.view model.theme
in
column [ spacing (model.theme |> Theme.scaled 5) ]
[ attributeToEditors ]
Expand Down Expand Up @@ -2125,7 +2125,7 @@ viewDefinitionDetails model =
(argState |> Dict.get argName |> Maybe.withDefault (ValueEditor.initEditorState ir argType Nothing))
)
)
|> FieldList.view
|> FieldList.view model.theme

buttonStyles : List (Element.Attribute msg)
buttonStyles =
Expand Down
2 changes: 1 addition & 1 deletion cli/src/Morphir/Web/TryMorphir.elm
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ viewValue valueState ir fullyQualifiedName irView valueDef =
(ValueEditor.initEditorState ir argType Nothing)
)
)
|> FieldList.view
|> FieldList.view theme
in
column []
[ editors
Expand Down
3 changes: 2 additions & 1 deletion src/Morphir/Visual/Components/DrillDownPanel.elm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ drillDownPanel theme config =
, blur = 4
, color = rgba 0 0 0 0.2
}
, Background.color (rgba 1 1 1 1)
, Background.color theme.colors.lightest
, htmlAttribute (style "filter" "brightness(97%)")
, htmlAttribute (style "z-index" (String.fromInt config.zIndex))
]
Expand All @@ -74,6 +74,7 @@ drillDownPanel theme config =
, Border.rounded 4
, Border.width 2
, Border.color (rgba 0 0 0 0.1)
, Background.color theme.colors.lightest
]
[ el [ width (theme |> Theme.largeSpacing |> px) ] (expandIcon theme)
, config.closedElement
Expand Down
15 changes: 6 additions & 9 deletions src/Morphir/Visual/Components/FieldList.elm
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module Morphir.Visual.Components.FieldList exposing (..)

import Element exposing (Element, centerY, el, fill, paddingXY, rgb, shrink, spacingXY, table, text, width)
import Element.Background as Background
import Element exposing (Element, centerY, el, fill, padding, shrink, spacingXY, table, text, width)
import Element.Border as Border
import Element.Font as Font
import Morphir.IR.Name exposing (Name)
import Morphir.Visual.Common exposing (nameToText)
import Morphir.Visual.Theme as Theme exposing (Theme)


view : List ( Name, Element msg ) -> Element msg
view fields =
view : Theme -> List ( Name, Element msg ) -> Element msg
view theme fields =
table
[ width fill
, spacingXY 0 5
Expand All @@ -21,18 +20,16 @@ view fields =
\( fieldName, _ ) ->
el
[ width shrink
, paddingXY 10 5
, centerY
, Font.bold
--, Background.color (rgb 0.2 0.3 0.4)
, padding <| Theme.smallPadding theme
, Border.roundEach
{ topLeft = 6
, bottomLeft = 6
, topRight = 0
, bottomRight = 0
}
]
(text (nameToText fieldName))
(text <| nameToText fieldName ++ " : ")
}
, { header = text ""
, width = shrink
Expand Down
15 changes: 10 additions & 5 deletions src/Morphir/Visual/ValueEditor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ import Element
, table
, text
, width
, centerX
, shrink
, minimum
, maximum
, centerX
)
import Element.Background as Background
import Element.Border as Border
Expand Down Expand Up @@ -92,7 +92,7 @@ import Morphir.Visual.Components.DatePickerComponent as DatePicker
import Morphir.Visual.Components.FieldList as FieldList
import Morphir.Visual.Components.InputComponent as InputComponent
import Morphir.Visual.Components.Picklist as Picklist
import Morphir.Visual.Theme exposing (Theme, scaled)
import Morphir.Visual.Theme as Theme exposing (Theme, scaled)
import Svg
import Svg.Attributes
import Morphir.Visual.Theme as Theme
Expand Down Expand Up @@ -593,7 +593,12 @@ view theme ir valueType updateEditorState editorState =

labelStyle : List (Element.Attr () msg)
labelStyle =
[ centerY, centerX, paddingEach { top = 5, bottom = 5, right = 10, left = 0 }, width (shrink |> minimum (Theme.scaled 10 theme) |> maximum (Theme.scaled 15 theme)), Font.italic ]
[ centerY
, centerX
, paddingEach { top = 5, bottom = 5, right = 10, left = 0 }
, width (shrink |> minimum (Theme.scaled 10 theme) |> maximum (Theme.scaled 15 theme))
, Font.italic
]
in
case editorState.componentState of
TextEditor currentText ->
Expand Down Expand Up @@ -737,11 +742,11 @@ view theme ir valueType updateEditorState editorState =
row [] <|
[ el [ Font.italic, paddingXY 10 5 ] (text "record")
, el
[ padding 7
[ padding <| Theme.largePadding theme
, Background.color theme.colors.brandPrimaryLight
, Theme.borderRounded theme
]
(FieldList.view
(FieldList.view theme
(fieldEditorStates
|> Dict.toList
|> List.map
Expand Down
99 changes: 50 additions & 49 deletions src/Morphir/Visual/ViewApply.elm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ view config viewDefinitionBody viewValue functionValue argValues applyValue =
( (Value.Constructor _ fQName) as constr, _ ) ->
case config.ir |> Distribution.lookupTypeSpecification (config.ir |> Distribution.resolveAliases fQName) of
Just (Type.TypeAliasSpecification _ (Type.Record _ fields)) ->
FieldList.view
FieldList.view config.state.theme
(List.map2
(\field arg ->
( field.name
Expand Down Expand Up @@ -324,56 +324,57 @@ functionOutput config fqName functionValue argValues viewValue =
_ ->
Element.none


pipeVisualisation : Config msg -> EnrichedValue -> (EnrichedValue -> Element msg) -> Element msg
pipeVisualisation config applyValue viewValue=
pipeVisualisation config applyValue viewValue =
let
getMapsRec : EnrichedValue -> List (Element msg)
getMapsRec v =
let
recursiveCall : FQName -> EnrichedValue -> EnrichedValue -> EnrichedValue -> String -> List (Element msg)
recursiveCall currentFQName currentFunctionValue currentFunction src label =
getMapsRec src
++ [ el
[ Border.width 2
, Border.color config.state.theme.colors.brandSecondaryLight
, Theme.borderRounded config.state.theme
, Element.above <| el [ Font.color config.state.theme.colors.mediumGray, padding 4, Element.centerX, Element.centerY ] (text label)
]
<|
viewValue currentFunction
, arrow currentFQName currentFunctionValue [ currentFunction, src ]
]
in
case v of
Value.Apply _ applyFunction applyArgs ->
case Value.uncurryApply applyFunction applyArgs of
( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "map" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "map"

( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "filter" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "filter"

( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "filter", "map" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "filter & map"

_ ->
[ viewValue v ]
getMapsRec : EnrichedValue -> List (Element msg)
getMapsRec v =
let
recursiveCall : FQName -> EnrichedValue -> EnrichedValue -> EnrichedValue -> String -> List (Element msg)
recursiveCall currentFQName currentFunctionValue currentFunction src label =
getMapsRec src
++ [ Element.column
[ Border.width 2
, Border.color config.state.theme.colors.brandSecondaryLight
, Theme.borderRounded config.state.theme
]
[ el [ Font.color config.state.theme.colors.mediumGray, padding 3, Element.centerX, Element.centerY ] (text label)
, viewValue currentFunction
]
, arrow currentFQName currentFunctionValue [ currentFunction, src ]
]
in
case v of
Value.Apply _ applyFunction applyArgs ->
case Value.uncurryApply applyFunction applyArgs of
( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "map" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "map"

( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "filter" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "filter"

( (Value.Reference _ (( [ [ "morphir" ], [ "s", "d", "k" ] ], _, [ "filter", "map" ] ) as fqName)) as mapFunctionValue, [ mapfunc, source ] ) ->
recursiveCall fqName mapFunctionValue mapfunc source "filter & map"

_ ->
[ viewValue v
, arrow ( [], [], [] ) v []
]
[ viewValue v ]

arrow : FQName -> EnrichedValue -> List EnrichedValue -> Element msg
arrow fqName mapFunctionValue args =
el
[ Element.centerX
, Element.centerY
, tooltip Element.below (functionOutput config fqName mapFunctionValue args viewValue)
, htmlAttribute (style "z-index" "10000")
, width (Element.shrink |> Element.minimum (config.state.theme.fontSize * 3) |> Element.maximum (config.state.theme.fontSize * 5))
]
<|
DecisionTree.rightArrow config False
in
row [ spacing <| Theme.smallSpacing config.state.theme ] <|( getMapsRec applyValue) ++ [el [Font.italic] <| text " output "]
_ ->
[ viewValue v
, arrow ( [], [], [] ) v []
]

arrow : FQName -> EnrichedValue -> List EnrichedValue -> Element msg
arrow fqName mapFunctionValue args =
el
[ Element.centerX
, Element.centerY
, tooltip Element.below (functionOutput config fqName mapFunctionValue args viewValue)
, htmlAttribute (style "z-index" "10000")
, width (Element.shrink |> Element.minimum (config.state.theme.fontSize * 3) |> Element.maximum (config.state.theme.fontSize * 5))
]
<|
DecisionTree.rightArrow config False
in
row [ spacing <| Theme.smallSpacing config.state.theme ] <| getMapsRec applyValue ++ [ el [ Font.italic ] <| text " output " ]
11 changes: 5 additions & 6 deletions src/Morphir/Visual/ViewRecord.elm
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module Morphir.Visual.ViewRecord exposing (..)

import Dict exposing (Dict)
import Element exposing (Element, el, none, padding, rgb)
import Element exposing (Element, el, none, padding)
import Element.Background as Background
import Element.Border as Border
import Morphir.IR.Name exposing (Name)
import Morphir.Visual.Components.FieldList as FieldList
import Morphir.Visual.Config exposing (Config)
import Morphir.Visual.EnrichedValue exposing (EnrichedValue)
import Morphir.Visual.Theme exposing (smallPadding)
import Morphir.Visual.Theme exposing (smallPadding, borderRounded)


view : Config msg -> (EnrichedValue -> Element msg) -> Dict Name EnrichedValue -> Element msg
Expand All @@ -23,7 +22,7 @@ view config viewValue items =
else
el
[ smallPadding config.state.theme |> padding
, Background.color (rgb 0.7 0.8 0.9)
, Border.rounded 7
, Background.color config.state.theme.colors.brandPrimaryLight
, borderRounded config.state.theme
]
(FieldList.view fields)
(FieldList.view config.state.theme fields)
4 changes: 2 additions & 2 deletions src/Morphir/Visual/ViewValue.elm
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ viewValueByLanguageFeature config value =
el [ Element.centerX, Element.centerY, smallPadding config.state.theme |> padding ] (text "not set")

Value.UpdateRecord _ record newFields ->
Element.column [ Element.height fill ]
[ Element.row [ smallPadding config.state.theme |> padding ] [ text "updating ", viewValue config record, text " with" ]
Element.column [ Background.color config.state.theme.colors.lightest, Theme.borderRounded config.state.theme ]
[ Element.row [ smallPadding config.state.theme |> padding ] [ text "updating the following fields of ", viewValue config record]
, ViewRecord.view config (viewValue config) newFields
]

Expand Down

0 comments on commit 93810ed

Please sign in to comment.