Skip to content

Commit 84a169f

Browse files
authored
Merge pull request #1367 from ds-wizard/release/4.18.0
Release 4.18.0
2 parents 1bde0f8 + 2ffb688 commit 84a169f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1350
-672
lines changed

elm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"leojpod/elm-keyboard-shortcut": "1.0.1",
4343
"myrho/elm-round": "1.0.5",
4444
"noahzgordon/elm-color-extra": "1.0.2",
45-
"pablohirafuji/elm-syntax-highlight": "3.7.0",
45+
"pablohirafuji/elm-syntax-highlight": "3.7.1",
4646
"rtfeldman/elm-iso8601-date-strings": "1.1.4",
4747
"rundis/elm-bootstrap": "5.2.0",
4848
"simonh1000/elm-jwt": "7.1.1",

engine-registry/elm/Registry/Api/Models/BootstrapConfig.elm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ module Registry.Api.Models.BootstrapConfig exposing
77
import Json.Decode as D exposing (Decoder)
88
import Json.Decode.Pipeline as D
99
import Registry.Api.Models.BootstrapConfig.AuthenticationConfig as AuthenticationConfig exposing (AuthenticationConfig)
10+
import Registry.Api.Models.BootstrapConfig.LocaleConfig as LocaleConfig exposing (LocaleConfig)
1011

1112

1213
type alias BootstrapConfig =
1314
{ authentication : AuthenticationConfig
15+
, locale : LocaleConfig
1416
}
1517

1618

1719
default : BootstrapConfig
1820
default =
19-
{ authentication = AuthenticationConfig.default }
21+
{ authentication = AuthenticationConfig.default
22+
, locale = LocaleConfig.default
23+
}
2024

2125

2226
decoder : Decoder BootstrapConfig
2327
decoder =
2428
D.succeed BootstrapConfig
2529
|> D.required "authentication" AuthenticationConfig.decoder
30+
|> D.required "locale" LocaleConfig.decoder
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Registry.Api.Models.BootstrapConfig.LocaleConfig exposing (LocaleConfig, decoder, default)
2+
3+
import Json.Decode as D exposing (Decoder)
4+
import Json.Decode.Pipeline as D
5+
6+
7+
type alias LocaleConfig =
8+
{ enabled : Bool }
9+
10+
11+
default : LocaleConfig
12+
default =
13+
{ enabled = True }
14+
15+
16+
decoder : Decoder LocaleConfig
17+
decoder =
18+
D.succeed LocaleConfig
19+
|> D.required "enabled" D.bool

engine-registry/elm/Registry/Layouts/AppLayout.elm

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Gettext exposing (gettext)
55
import Html exposing (Html, a, div, header, img, li, main_, section, small, text, ul)
66
import Html.Attributes exposing (class, classList, height, href, src)
77
import Html.Events exposing (onClick)
8+
import Html.Extra as Html
89
import Registry.Components.FontAwesome exposing (fas)
910
import Registry.Data.AppState as AppState exposing (AppState)
1011
import Registry.Routes as Routes
@@ -101,16 +102,17 @@ viewHeader appState cfg appTitle =
101102
, text (gettext "Document Templates" appState.locale)
102103
]
103104
]
104-
, li [ class "nav-item" ]
105-
[ a
106-
[ class "nav-link"
107-
, classList [ ( "active", appState.route == Routes.Locales ) ]
108-
, href (Routes.toUrl Routes.locales)
105+
, Html.viewIf appState.config.locale.enabled <|
106+
li [ class "nav-item" ]
107+
[ a
108+
[ class "nav-link"
109+
, classList [ ( "active", appState.route == Routes.Locales ) ]
110+
, href (Routes.toUrl Routes.locales)
111+
]
112+
[ fas "fa-language"
113+
, text (gettext "Locales" appState.locale)
114+
]
109115
]
110-
[ fas "fa-language"
111-
, text (gettext "Locales" appState.locale)
112-
]
113-
]
114116
]
115117
]
116118
]

engine-registry/elm/Registry/Pages/Homepage.elm

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Registry.Pages.Homepage exposing (view)
33
import Gettext exposing (gettext)
44
import Html exposing (Html, a, div, h1, p, span, text)
55
import Html.Attributes exposing (class, href)
6+
import Html.Extra as Html
67
import Registry.Components.FontAwesome exposing (fas)
78
import Registry.Data.AppState as AppState exposing (AppState)
89
import Registry.Routes as Routes
@@ -20,7 +21,7 @@ view appState =
2021
[ text (gettext "Customize your experience with prepared content and translations." appState.locale)
2122
]
2223
]
23-
, div [ class "row" ]
24+
, div [ class "row justify-content-center" ]
2425
[ viewLink
2526
{ route = Routes.KnowledgeModels
2627
, icon = "fa-sitemap"
@@ -33,12 +34,13 @@ view appState =
3334
, title = gettext "Document Templates" appState.locale
3435
, description = gettext "Compose documents from questionnaires by selecting templates that handle the transformation of replies." appState.locale
3536
}
36-
, viewLink
37-
{ route = Routes.Locales
38-
, icon = "fa-language"
39-
, title = gettext "Locales" appState.locale
40-
, description = gettext "Adapt the user interface to different languages for a more inclusive experience." appState.locale
41-
}
37+
, Html.viewIf appState.config.locale.enabled <|
38+
viewLink
39+
{ route = Routes.Locales
40+
, icon = "fa-language"
41+
, title = gettext "Locales" appState.locale
42+
, description = gettext "Adapt the user interface to different languages for a more inclusive experience." appState.locale
43+
}
4244
]
4345
]
4446
]

engine-registry/elm/Registry/Routes.elm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,24 @@ parsers config =
6565
else
6666
[]
6767

68+
localeRoutes =
69+
if config.locale.enabled then
70+
[ Parser.map Locales (Parser.s "locales")
71+
, Parser.map LocalesDetail (Parser.s "locales" </> Parser.string)
72+
]
73+
74+
else
75+
[]
76+
6877
publicRoutes =
6978
[ Parser.map Home Parser.top
7079
, Parser.map KnowledgeModels (Parser.s "knowledge-models")
7180
, Parser.map KnowledgeModelsDetail (Parser.s "knowledge-models" </> Parser.string)
7281
, Parser.map DocumentTemplates (Parser.s "document-templates")
7382
, Parser.map DocumentTemplatesDetail (Parser.s "document-templates" </> Parser.string)
74-
, Parser.map Locales (Parser.s "locales")
75-
, Parser.map LocalesDetail (Parser.s "locales" </> Parser.string)
7683
]
7784
in
78-
Parser.oneOf (publicRoutes ++ authRoutes)
85+
Parser.oneOf (publicRoutes ++ localeRoutes ++ authRoutes)
7986

8087

8188
toUrl : Route -> String

engine-shared/elm/Shared/Api.elm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module Shared.Api exposing
2424
, jwtPostEmpty
2525
, jwtPostFile
2626
, jwtPostFileWithData
27+
, jwtPostMultiPart
2728
, jwtPut
2829
, jwtPutString
2930
, wsUrl
@@ -120,6 +121,15 @@ jwtPostFileWithData url data file appState toMsg =
120121
}
121122

122123

124+
jwtPostMultiPart : String -> List Http.Part -> AbstractAppState b -> ToMsg () msg -> Cmd msg
125+
jwtPostMultiPart url data appState toMsg =
126+
Jwt.Http.post appState.session.token.token
127+
{ url = appState.apiUrl ++ url
128+
, body = Http.multipartBody data
129+
, expect = expectWhatever toMsg
130+
}
131+
132+
123133
jwtFetchFileWithData : String -> List Http.Part -> Decoder a -> File -> AbstractAppState b -> ToMsg a msg -> Cmd msg
124134
jwtFetchFileWithData url data decoder file appState toMsg =
125135
Jwt.Http.post appState.session.token.token

engine-shared/elm/Shared/Api/Locales.elm

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Shared.Api.Locales exposing
55
, exportLocaleUrl
66
, getLocale
77
, getLocales
8+
, getLocalesSuggestions
89
, importLocale
910
, pullLocale
1011
, setDefaultLocale
@@ -13,10 +14,12 @@ module Shared.Api.Locales exposing
1314

1415
import File exposing (File)
1516
import Http
17+
import Json.Decode as D
1618
import Shared.AbstractAppState exposing (AbstractAppState)
17-
import Shared.Api exposing (ToMsg, jwtDelete, jwtGet, jwtPostEmpty, jwtPostFile, jwtPostFileWithData, jwtPut)
19+
import Shared.Api exposing (ToMsg, jwtDelete, jwtGet, jwtPostEmpty, jwtPostFile, jwtPostMultiPart, jwtPut)
1820
import Shared.Data.Locale as Locale exposing (Locale)
1921
import Shared.Data.LocaleDetail as LocaleDetail exposing (LocaleDetail)
22+
import Shared.Data.LocaleSuggestion as LocaleSuggestion exposing (LocaleSuggestion)
2023
import Shared.Data.Pagination as Pagination exposing (Pagination)
2124
import Shared.Data.PaginationQueryFilters exposing (PaginationQueryFilters)
2225
import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString)
@@ -34,6 +37,16 @@ getLocales _ qs =
3437
jwtGet url (Pagination.decoder "locales" Locale.decoder)
3538

3639

40+
getLocalesSuggestions : AbstractAppState a -> ToMsg (List LocaleSuggestion) msg -> Cmd msg
41+
getLocalesSuggestions =
42+
let
43+
decoder =
44+
D.map .items <|
45+
Pagination.decoder "locales" LocaleSuggestion.decoder
46+
in
47+
jwtGet "/locales/suggestions" decoder
48+
49+
3750
getLocale : String -> AbstractAppState a -> ToMsg LocaleDetail msg -> Cmd msg
3851
getLocale localeId =
3952
jwtGet ("/locales/" ++ localeId) LocaleDetail.decoder
@@ -57,13 +70,15 @@ setEnabled locale enabled =
5770
jwtPut ("/locales/" ++ locale.id) withDefault
5871

5972

60-
createFromPO : List ( String, String ) -> File -> AbstractAppState a -> ToMsg () msg -> Cmd msg
61-
createFromPO params =
73+
createFromPO : List ( String, String ) -> File -> File -> AbstractAppState a -> ToMsg () msg -> Cmd msg
74+
createFromPO params wizardContent mailContent =
6275
let
6376
httpParams =
64-
List.map (\( k, v ) -> Http.stringPart k v) params
77+
Http.filePart "wizardContent" wizardContent
78+
:: Http.filePart "mailContent" mailContent
79+
:: List.map (\( k, v ) -> Http.stringPart k v) params
6580
in
66-
jwtPostFileWithData "/locales" httpParams
81+
jwtPostMultiPart "/locales" httpParams
6782

6883

6984
deleteLocale : String -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg

engine-shared/elm/Shared/Api/Users.elm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
module Shared.Api.Users exposing
22
( deleteUser
3+
, getCurrentUserLocale
34
, getCurrentUserSubmissionProps
45
, getUser
56
, getUsers
67
, getUsersSuggestions
78
, getUsersSuggestionsWithOptions
89
, postUser
910
, postUserPublic
11+
, putCurrentUserLocale
1012
, putCurrentUserSubmissionProps
1113
, putUser
1214
, putUserActivation
@@ -24,6 +26,7 @@ import Shared.Data.PaginationQueryFilters as PaginationQueryFilters exposing (Pa
2426
import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString)
2527
import Shared.Data.SubmissionProps as SubmissionProps exposing (SubmissionProps)
2628
import Shared.Data.User as User exposing (User)
29+
import Shared.Data.UserLocale as UserLocale exposing (UserLocale)
2730
import Shared.Data.UserSuggestion as UserSuggestion exposing (UserSuggestion)
2831

2932

@@ -82,6 +85,20 @@ getCurrentUserSubmissionProps =
8285
jwtGet "/users/current/submission-props" (D.list SubmissionProps.decoder)
8386

8487

88+
getCurrentUserLocale : AbstractAppState a -> ToMsg UserLocale msg -> Cmd msg
89+
getCurrentUserLocale =
90+
jwtGet "/users/current/locale" UserLocale.decoder
91+
92+
93+
putCurrentUserLocale : AbstractAppState a -> UserLocale -> ToMsg () msg -> Cmd msg
94+
putCurrentUserLocale appState userLocale =
95+
let
96+
body =
97+
UserLocale.encode userLocale
98+
in
99+
jwtPut "/users/current/locale" body appState
100+
101+
85102
postUser : E.Value -> AbstractAppState a -> ToMsg () msg -> Cmd msg
86103
postUser =
87104
jwtPost "/users"

engine-shared/elm/Shared/Data/BootstrapConfig.elm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Shared.Data.BootstrapConfig.AppSwitcherItem as AppSwitcherItem exposing (
1212
import Shared.Data.BootstrapConfig.AuthenticationConfig as AuthenticationConfig exposing (AuthenticationConfig)
1313
import Shared.Data.BootstrapConfig.CloudConfig as CloudConfig exposing (CloudConfig)
1414
import Shared.Data.BootstrapConfig.DashboardAndLoginScreenConfig as DashboardAndLoginScreenConfig exposing (DashboardAndLoginScreenConfig)
15-
import Shared.Data.BootstrapConfig.LocaleConfig as LocaleConfig exposing (LocaleConfig)
1615
import Shared.Data.BootstrapConfig.LookAndFeelConfig as LookAndFeelConfig exposing (LookAndFeelConfig)
1716
import Shared.Data.BootstrapConfig.OrganizationConfig as OrganizationConfig exposing (OrganizationConfig)
1817
import Shared.Data.BootstrapConfig.OwlConfig as OwlConfig exposing (OwlConfig)
@@ -37,7 +36,6 @@ type alias BootstrapConfig =
3736
, submission : SubmissionConfig
3837
, cloud : CloudConfig
3938
, owl : OwlConfig
40-
, locales : List LocaleConfig
4139
, modules : List AppSwitcherItem
4240
, signalBridge : SignalBridgeConfig
4341
, user : Maybe UserInfo
@@ -58,7 +56,6 @@ default =
5856
, submission = SubmissionConfig.default
5957
, cloud = CloudConfig.default
6058
, owl = OwlConfig.default
61-
, locales = []
6259
, modules = []
6360
, signalBridge = SignalBridgeConfig.default
6461
, user = Nothing
@@ -80,7 +77,6 @@ decoder =
8077
|> D.required "submission" SubmissionConfig.decoder
8178
|> D.required "cloud" CloudConfig.decoder
8279
|> D.required "owl" OwlConfig.decoder
83-
|> D.required "locales" (D.list LocaleConfig.decoder)
8480
|> D.required "modules" (D.list AppSwitcherItem.decoder)
8581
|> D.required "signalBridge" SignalBridgeConfig.decoder
8682
|> D.required "user" (D.maybe UserInfo.decoder)

0 commit comments

Comments
 (0)