From 4417a61c82e328d20eac6dda9893f26adb710746 Mon Sep 17 00:00:00 2001 From: Robin Gruenke Date: Wed, 26 Aug 2020 04:59:36 +0200 Subject: [PATCH] ui overhaul #2 incompatible data diff --- _posts/2019-09-05-project-atlantic.markdown | 2 + fixtures/another-with-spaces.csv | 6 +++ fixtures/standard-part-irregular.csv | 6 +++ fixtures/yet-another-with-spaces.csv | 6 +++ src/elm/Main.elm | 51 ++++++++++++++++++--- 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 fixtures/another-with-spaces.csv create mode 100644 fixtures/standard-part-irregular.csv create mode 100644 fixtures/yet-another-with-spaces.csv diff --git a/_posts/2019-09-05-project-atlantic.markdown b/_posts/2019-09-05-project-atlantic.markdown index 6995838..e0256eb 100644 --- a/_posts/2019-09-05-project-atlantic.markdown +++ b/_posts/2019-09-05-project-atlantic.markdown @@ -65,6 +65,8 @@ date: '2018-08-29 10:26' - [ ] Move 'Manage Tags' and 'Tagged Records' Sections into Tagging Section accessible via NavBar Icon 9. Integrate `elm-program-test` + - [Discourse Presentation](https://discourse.elm-lang.org/t/elm-program-test-3-0-0-new-docs-support-for-http-and-ports/4235) + - [Guide](https://elm-program-test.netlify.app) ### Backlog diff --git a/fixtures/another-with-spaces.csv b/fixtures/another-with-spaces.csv new file mode 100644 index 0000000..e8ab3ea --- /dev/null +++ b/fixtures/another-with-spaces.csv @@ -0,0 +1,6 @@ + Date; Description ; Description2; Value + 06.01.2019; Invoice No 345; Client: ABC; -5,00 + 07.01.2019; Invoice No 4314; Client: ABC; -20,00 + 08.01.2019; Invoice No 2314; Client: ABC; -13,00 + 09.01.2019; Invoice No 423; Client: ABC; -20,00 + 10.01.2019; Invoice No 4534; Client: ABC;-3,00 \ No newline at end of file diff --git a/fixtures/standard-part-irregular.csv b/fixtures/standard-part-irregular.csv new file mode 100644 index 0000000..bfb448d --- /dev/null +++ b/fixtures/standard-part-irregular.csv @@ -0,0 +1,6 @@ +Date;Descriptio;Description2;Valu +06.01.2019;Invoice No 345;Client: ABC;-5,00 +07.01.2019;Invoice No 4314;Client: ABC;-20,00 +08.01.2019;Invoice No 2314;Client: ABC;-13,00 +09.01.2019;Invoice No 423;Client: ABC;-20,00 +10.01.2019;Invoice No 4534;Client: ABC;-3,00 \ No newline at end of file diff --git a/fixtures/yet-another-with-spaces.csv b/fixtures/yet-another-with-spaces.csv new file mode 100644 index 0000000..6e58d9b --- /dev/null +++ b/fixtures/yet-another-with-spaces.csv @@ -0,0 +1,6 @@ + Date ; Description; Description2; Value + 06.01.2019; Invoice No 345; Client: ABC; -5,00 + 07.01.2019; Invoice No 4314; Client: ABC; -20,00 + 08.01.2019; Invoice No 2314; Client: ABC; -13,00 + 09.01.2019; Invoice No 423; Client: ABC; -20,00 + 10.01.2019; Invoice No 4534; Client: ABC;-3,00 \ No newline at end of file diff --git a/src/elm/Main.elm b/src/elm/Main.elm index da32e56..aac294f 100755 --- a/src/elm/Main.elm +++ b/src/elm/Main.elm @@ -858,18 +858,57 @@ viewModalContent locale modalContent = ViewDropIrregularRecords headers irregularRecords _ -> div [] - [ h4 [] [ text <| Locale.translateIrregularRowsText locale (List.length irregularRecords) ++ " :" ] + [ h5 [] [ text <| Locale.translateIrregularRowsText locale (List.length irregularRecords) ++ " :" ] , viewRecords Table.Unresponsive headers irregularRecords - , h4 [] [ text <| Locale.translateAskForDrop locale ] + , h5 [] [ text <| Locale.translateAskForDrop locale ] ] ViewIncompatibleData validHeaders unvalidHeaders -> + let + validHeadersWithSemicolons = + setCSVSemicolonsInList validHeaders + + unValidHeadersWithSemicolons = + setCSVSemicolonsInList unvalidHeaders + + viewColumns textClass headerText = + String.toList headerText + |> List.foldl + (\char result -> + if char == ' ' then + List.append result [ span [ style "borderBottom" "1px dotted blue" ] [ text " " ] ] + + else + List.append result [ span [ class textClass ] [ text <| String.fromChar char ] ] + ) + [] + in div [] - [ h4 [] [ text <| Locale.translateIncompatibleDataIntro locale ] - , viewRecords Table.Unresponsive validHeaders [] - , h4 [] [ text <| Locale.translateIncompatibleDataComparison locale ] - , viewRecords Table.Unresponsive unvalidHeaders [] + [ h5 [] [ text <| Locale.translateIncompatibleDataIntro locale ] + , div [ style "whiteSpace" "pre" ] + (validHeadersWithSemicolons + |> List.map (viewColumns "uk-text-success") + |> List.concat + ) + , h5 [] [ text <| Locale.translateIncompatibleDataComparison locale ] + , div [ style "whiteSpace" "pre" ] + (unValidHeadersWithSemicolons + |> List.indexedMap + (\i header -> + case ListExtra.getAt i validHeadersWithSemicolons of + Just validHeader -> + if validHeader == header then + viewColumns "uk-text-success" header + + else + viewColumns "uk-text-danger" header + + Nothing -> + viewColumns "uk-text-danger" header + ) + |> List.concat + ) ] ViewWorkingData headers records ->