Skip to content

Commit

Permalink
Fix/v1.9.0 hotfix (#499)
Browse files Browse the repository at this point in the history
* Remove animation on Feedback

* Remove animations on Feedback

* Show out of stock on search

* Format and warning fix

* Update package json version

* Add translations

* Update GraphQL

* Add sorting on claim analysis history page
  • Loading branch information
lucca65 authored Apr 1, 2021
1 parent 98be02b commit 07f52f3
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.8.0",
"version": "1.9.1",
"private": true,
"engines": {
"node": "14.8.0"
Expand Down
6 changes: 5 additions & 1 deletion public/translations/amh-ETH.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,11 @@
"status": {
"label": "የተግባር ሁኔታ",
"pending_review": "እየተየ ነዉ(ምርጫዬ ዘገየ)"
}
},
"sort": {
"asc": "ወደ ላይ መውጣት ማዘዝ",
"desc": "ማዘዣ መውረድ"
}
}
},
"claim": {
Expand Down
4 changes: 4 additions & 0 deletions public/translations/cat-CAT.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@
"status": {
"label": "Estat de l’acció",
"pending_review": "En revisió (el meu vot està pendent)"
},
"sort": {
"asc": "Ordenació ascendent",
"desc": "Ordenant descendent"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions public/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,10 @@
"status": {
"label": "Action state",
"pending_review": "Under Review (my vote is pending)"
},
"sort": {
"asc": "Ordering ascending",
"desc": "Ordering descending"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions public/translations/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@
"status": {
"label": "estado de acción",
"pending_review": "Bajo revisión (mi voto está pendiente)"
},
"sort": {
"asc": "Orden ascendente",
"desc": "Orden descendente"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions public/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,10 @@
"status": {
"label": "Estado da ação",
"pending_review": "Sob análise (meu voto está pendente)"
},
"sort": {
"asc": "Ordenação ascendente",
"desc": "Ordenação descendente"
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions src/elm/Icons.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Icons exposing
, search
, settings
, shop
, sortDirection
, success
, telegram
, thumbDown
Expand Down Expand Up @@ -380,3 +381,15 @@ phone class_ =
, class class_
]
[ Svg.path [ d "M18.5789 13.6387L16.2657 11.317C15.8014 10.8358 15.24 10.5783 14.6406 10.5783C14.0454 10.5783 13.4797 10.8316 13.0027 11.3086L11.8124 12.4947C11.7997 12.4863 11.787 12.4821 11.7701 12.4736C11.7322 12.4567 11.6984 12.4356 11.6604 12.4145C11.5127 12.3428 11.3776 12.271 11.2678 12.2035C10.0437 11.4268 8.92928 10.4095 7.86132 9.10088C7.40121 8.51836 7.0804 8.03292 6.83979 7.53904C7.10151 7.28999 7.35056 7.04094 7.59116 6.79611L7.67981 6.70747C7.73891 6.64837 7.798 6.58505 7.8571 6.52596C7.9162 6.46686 7.97529 6.40776 8.03439 6.34867C8.51983 5.86323 8.78154 5.28915 8.78154 4.69396C8.78154 4.09877 8.52405 3.52891 8.03439 3.03926L6.882 1.88687C6.75115 1.75601 6.62029 1.62516 6.49366 1.49008C6.24461 1.23259 5.97445 0.95821 5.69163 0.696496C5.23152 0.240608 4.67432 0 4.08758 0C3.50083 0 2.93519 0.240608 2.4582 0.700717L1.01455 2.15703C0.427805 2.74377 0.0943304 3.46137 0.018349 4.29295C-0.0871808 5.57619 0.284284 6.76234 0.575546 7.54326C1.27204 9.42591 2.31468 11.1608 3.85119 13.0097C5.7254 15.2512 7.98374 17.0156 10.5587 18.2609C11.5591 18.7336 12.893 19.2908 14.3788 19.3837C14.4759 19.3879 14.5688 19.3921 14.6574 19.3921C15.7127 19.3921 16.5992 19.0122 17.2957 18.2566L17.3252 18.2229V18.2186C17.3252 18.2144 17.3295 18.2144 17.3295 18.2102C17.5194 17.978 17.7431 17.7628 17.9795 17.5348L18.0344 17.4799C18.2539 17.2689 18.4312 17.0916 18.5916 16.927C19.0601 16.4415 19.305 15.8717 19.305 15.2765C19.3092 14.6813 19.0559 14.1114 18.5789 13.6387ZM6.48521 5.51709L6.48099 5.52131C6.10531 5.90544 5.78449 6.22203 5.43414 6.54284C5.42569 6.55128 5.40881 6.56395 5.39192 6.58505C4.89382 7.09582 5.06267 7.63191 5.12177 7.8092L5.13865 7.85563L5.14287 7.86407C5.45102 8.607 5.88158 9.31194 6.54431 10.152L6.55697 10.1688C7.74313 11.6252 8.98838 12.7607 10.3645 13.6302C10.5502 13.7484 10.7317 13.8371 10.909 13.9257C11.0568 13.9975 11.1918 14.0692 11.3058 14.1368L11.3311 14.1494C11.348 14.1579 11.3649 14.1705 11.3776 14.179C11.5591 14.2676 11.7364 14.314 11.9179 14.314C12.3822 14.314 12.6608 14.0354 12.7537 13.9426L14.1973 12.4989C14.3071 12.3892 14.4675 12.2626 14.6406 12.2626C14.8178 12.2626 14.9698 12.3976 15.0458 12.4821L17.3885 14.8248C17.6883 15.1203 17.7094 15.3778 17.4603 15.6775C17.4603 15.6775 16.3206 16.8088 16.0504 17.1254C15.679 17.5222 15.24 17.7037 14.6659 17.7037C14.6068 17.7037 14.5435 17.7037 14.4886 17.6994C13.2813 17.6235 12.15 17.1465 11.2974 16.737C8.94195 15.5973 6.87356 13.9764 5.15976 11.9291C3.74566 10.2237 2.79167 8.64077 2.16693 6.94808C1.79125 5.93921 1.65195 5.16251 1.71105 4.42381C1.74904 3.99747 1.91366 3.64289 2.21337 3.33896L3.64857 1.90376C3.80476 1.75601 3.96094 1.68003 4.10024 1.68003C4.27331 1.68003 4.42527 1.79823 4.52236 1.89531L4.53924 1.9122C4.77985 2.13592 5.01202 2.37231 5.29062 2.65935C5.35393 2.72689 5.42147 2.79443 5.48479 2.85774L5.49323 2.86619C5.56077 2.93373 5.62409 3.00127 5.69585 3.07303L6.84824 4.22541C7.19015 4.56733 7.19015 4.80793 6.84824 5.14563C6.80602 5.18784 6.76381 5.23005 6.72582 5.26804C6.6414 5.36091 6.56542 5.43689 6.48521 5.51709Z", fill "black" ] [] ]


sortDirection : String -> Html msg
sortDirection class_ =
svg
[ width "20"
, height "20"
, viewBox "0 0 20 20"
, fill "none"
, class class_
]
[ Svg.path [ d "M11.2543 6.8125C11.379 6.6875 11.5036 6.5 11.5036 6.25C11.5036 6.0625 11.4413 5.875 11.2543 5.6875L6.76744 1.1875L2.28052 5.6875C2.09357 5.875 2.03125 6.0625 2.03125 6.25C2.03125 6.4375 2.09357 6.625 2.28052 6.8125C2.40516 6.9375 2.59211 7.0625 2.84139 7.0625C3.02834 7.0625 3.2153 7 3.40225 6.8125L6.01962 4.1875V10.75C6.01962 11.1875 6.39353 11.5 6.76744 11.5C7.14135 11.5 7.51525 11.125 7.51525 10.75V4.125L10.1326 6.75C10.5065 7.0625 11.0051 7.0625 11.2543 6.8125Z", fill "#F99D33" ] [], Svg.path [ d "M17.8598 12.75C17.5482 12.4375 17.0497 12.4375 16.8004 12.75L14.183 15.375V8.8125C14.183 8.375 13.8091 8.0625 13.4352 8.0625C13.0613 8.0625 12.5628 8.375 12.5628 8.8125V15.375L9.9454 12.75C9.63381 12.4375 9.13526 12.4375 8.88599 12.75C8.76136 12.875 8.63672 13.0625 8.63672 13.3125C8.63672 13.5625 8.69904 13.6875 8.88599 13.875L13.3729 18.375L17.8598 13.875C17.9845 13.75 18.1091 13.5625 18.1091 13.3125C18.1091 13.0625 18.0468 12.875 17.8598 12.75Z", fill "#F99D33" ] [] ]
78 changes: 57 additions & 21 deletions src/elm/Page/Dashboard/Analysis.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Page.Dashboard.Analysis exposing

import Api.Graphql
import Api.Relay
import Cambiatus.Enum.Direction
import Cambiatus.Query
import Claim
import Community
Expand Down Expand Up @@ -87,12 +88,18 @@ type CommunityStatus
type alias Filter =
{ profile : Maybe Profile.Minimal
, statusFilter : StatusFilter
, direction : FilterDirection
}


type FilterDirection
= ASC
| DESC


initFilter : Filter
initFilter =
{ profile = Nothing, statusFilter = All }
{ profile = Nothing, statusFilter = All, direction = DESC }


type StatusFilter
Expand Down Expand Up @@ -177,11 +184,8 @@ view ({ shared } as loggedIn) model =
viewFilters : LoggedIn.Model -> Model -> Html Msg
viewFilters ({ shared } as loggedIn) model =
let
t =
shared.translators.t

text_ s =
text (t s)
text (shared.translators.t s)
in
div [ class "mt-4 mb-12" ]
[ div []
Expand Down Expand Up @@ -253,6 +257,19 @@ viewFilters ({ shared } as loggedIn) model =
[ text_ "all_analysis.pending" ]
]
]
, div [ class "mt-6" ]
[ button
[ class "w-full button button-secondary relative"
, onClick ToggleSorting
]
[ if model.filters.direction == ASC then
text_ "all_analysis.filter.sort.asc"

else
text_ "all_analysis.filter.sort.desc"
, Icons.sortDirection "absolute right-1"
]
]
]


Expand Down Expand Up @@ -317,6 +334,7 @@ type Msg
| ShowMore
| ClearSelectSelection
| SelectStatusFilter StatusFilter
| ToggleSorting
| ClearFilters


Expand Down Expand Up @@ -566,9 +584,32 @@ update msg model loggedIn =
|> UR.init
|> UR.addCmd (fetchAnalysis loggedIn initFilter Nothing)

ToggleSorting ->
let
oldFilters =
model.filters

sortDirection =
if model.filters.direction == ASC then
DESC

else
ASC

newModel =
{ model
| filters = { oldFilters | direction = sortDirection }
, reloadOnNextQuery = True
, status = Loading
}
in
newModel
|> UR.init
|> UR.addCmd (fetchAnalysis loggedIn newModel.filters Nothing)


fetchAnalysis : LoggedIn.Model -> Filter -> Maybe String -> Cmd Msg
fetchAnalysis { selectedCommunity, shared, authToken } { profile, statusFilter } maybeCursorAfter =
fetchAnalysis { selectedCommunity, shared, authToken } { profile, statusFilter, direction } maybeCursorAfter =
let
optionalClaimer =
case profile of
Expand All @@ -595,19 +636,15 @@ fetchAnalysis { selectedCommunity, shared, authToken } { profile, statusFilter }
filterRecord =
{ claimer = optionalClaimer
, status = optionalStatus
, direction =
case direction of
ASC ->
Present Cambiatus.Enum.Direction.Asc

-- TODO
, direction = Absent
DESC ->
Present Cambiatus.Enum.Direction.Desc
}

filter =
case ( filterRecord.claimer, filterRecord.status ) of
( Absent, Absent ) ->
Absent

( _, _ ) ->
Present filterRecord

required =
{ communityId = Eos.symbolToString selectedCommunity }

Expand All @@ -626,11 +663,7 @@ fetchAnalysis { selectedCommunity, shared, authToken } { profile, statusFilter }
, after =
Maybe.andThen mapFn maybeCursorAfter
|> Maybe.withDefault Absent
, filter = filter

-- TODO
, before = Absent
, last = Absent
, filter = Present filterRecord
}
in
Api.Graphql.query shared
Expand Down Expand Up @@ -751,3 +784,6 @@ msgToString msg =

ClearFilters ->
[ "ClearFilters" ]

ToggleSorting ->
[ "ToggleSorting" ]
7 changes: 6 additions & 1 deletion src/elm/Page/Shop.elm
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,12 @@ viewCard model ({ shared } as loggedIn) index card =
]
[ div [ class "md:hidden rounded-lg bg-white h-32 flex" ]
[ div [ class "w-1/4" ]
[ img [ class "rounded-l-lg object-cover h-32 w-full", src image, on "error" (Json.Decode.succeed (OnImageError index)) ] []
[ img
[ class "rounded-l-lg object-cover h-32 w-full"
, src image
, on "error" (Json.Decode.succeed (OnImageError index))
]
[]
]
, div [ class "px-4 pb-2 flex flex-wrap" ]
[ p [ class "font-medium pt-2 w-full" ] [ text card.product.title ]
Expand Down
49 changes: 33 additions & 16 deletions src/elm/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ type alias Offer =
, title : String
, price : Float
, image : Maybe String
, units : Int
, trackStock : Bool
}


Expand Down Expand Up @@ -124,11 +126,13 @@ searchResultSelectionSet queryString =

offersSelectionSet : SelectionSet Offer Cambiatus.Object.Product
offersSelectionSet =
SelectionSet.map4 Offer
SelectionSet.map6 Offer
Cambiatus.Object.Product.id
Cambiatus.Object.Product.title
Cambiatus.Object.Product.price
Cambiatus.Object.Product.image
Cambiatus.Object.Product.units
Cambiatus.Object.Product.trackStock



Expand Down Expand Up @@ -360,7 +364,7 @@ viewSearchBody translators selectedCommunity maybeToday searchToMsg actionToMsg
Just OffersTab ->
div [ class "w-full" ]
[ viewTabs translators results OffersTab
, viewOffers selectedCommunity results.offers
, viewOffers translators selectedCommunity results.offers
]
|> Html.map searchToMsg

Expand Down Expand Up @@ -516,31 +520,44 @@ viewResultsOverview { t } { offers, actions } =
]


viewOffers : Symbol -> List Offer -> Html Msg
viewOffers symbol offers =
viewOffers : Translators -> Symbol -> List Offer -> Html Msg
viewOffers translators symbol offers =
let
viewOffer : Offer -> Html Msg
viewOffer offer =
let
imageUrl =
case offer.image of
Nothing ->
"/icons/shop-placeholder1.svg"

Just "" ->
"/icons/shop-placeholder1.svg"

Just url ->
url
in
li
[ class "flex px-2 w-1/2 sm:w-1/3 md:w-1/4" ]
[ div
[ class "rounded-md overflow-hidden bg-white flex-grow mb-4 pb-4 cursor-pointer hover:shadow"
, onClick (FoundItemClicked (Route.ViewSale (String.fromInt offer.id)))
]
[ case offer.image of
Nothing ->
text ""

Just url ->
img [ src url ] []
[ img [ src imageUrl ] []
, h3 [ class "p-3" ] [ text offer.title ]
, p [ class "px-3 leading-none" ]
[ span [ class "text-xl text-green font-medium" ] [ text <| String.fromFloat offer.price ]
, br [] []
, span [ class "text-gray-300 text-xs" ]
[ text <| Eos.symbolToSymbolCodeString symbol
, if offer.units == 0 && offer.trackStock then
p [ class "px-3 leading-none text-xl text-red" ]
[ text (translators.t "shop.out_of_stock")
]

else
p [ class "px-3 leading-none" ]
[ span [ class "text-xl text-green font-medium" ] [ text <| String.fromFloat offer.price ]
, br [] []
, span [ class "text-gray-300 text-xs" ]
[ text <| Eos.symbolToSymbolCodeString symbol
]
]
]
]
]
in
Expand Down
6 changes: 1 addition & 5 deletions src/elm/Session/LoggedIn.elm
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ viewFeedback status message =
, style "grid-template" "\". text x\" 100% / 10% 80% 10%"
]
[ span
[ class "flex justify-center items-center transition duration-500 ease-in-out text-sm h-10 leading-snug text-white font-bold transform hover:-translate-y-1 hover:scale-110"
[ class "flex justify-center items-center text-sm h-10 leading-snug text-white font-bold"
, style "grid-area" "text"
]
[ text message ]
Expand All @@ -326,10 +326,6 @@ viewFeedback status message =

viewHelper : (Msg -> pageMsg) -> Page -> Profile.Model -> Model -> Html pageMsg -> Html pageMsg
viewHelper pageMsg page profile_ ({ shared } as model) content =
let
{ t } =
shared.translators
in
div
[ class "min-h-screen flex flex-col" ]
([ div [ class "bg-white" ]
Expand Down

0 comments on commit 07f52f3

Please sign in to comment.