From 6b9fc0de61b974ddd3dc3842899add8008a8d19b Mon Sep 17 00:00:00 2001 From: Andrey Troeglazov <81006789+andreytroeglazov@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:25:54 +0700 Subject: [PATCH] Improve Paragraphs breadcrumbs (#56) --- Web/Controller/ParagraphCtas.hs | 4 ++++ Web/Controller/ParagraphHeroImages.hs | 4 ++++ Web/Controller/ParagraphQuotes.hs | 3 +++ Web/View/ParagraphCtas/Edit.hs | 5 ++++- Web/View/ParagraphCtas/New.hs | 5 ++++- Web/View/ParagraphHeroImages/Edit.hs | 5 ++++- Web/View/ParagraphHeroImages/New.hs | 5 ++++- Web/View/ParagraphQuotes/Edit.hs | 7 +++++-- Web/View/ParagraphQuotes/New.hs | 5 ++++- 9 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Web/Controller/ParagraphCtas.hs b/Web/Controller/ParagraphCtas.hs index a3406d7..a5b1d6d 100644 --- a/Web/Controller/ParagraphCtas.hs +++ b/Web/Controller/ParagraphCtas.hs @@ -15,6 +15,7 @@ instance Controller ParagraphCtasController where -- Get all landing pages, so we can select the one we want to link to. landingPages <- query @LandingPage |> fetch + landingPage <- fetch paragraphCta.landingPageId render NewView { .. } @@ -23,6 +24,7 @@ instance Controller ParagraphCtasController where -- Get all landing pages, so we can select the one we want to link to. landingPages <- query @LandingPage |> fetch + landingPage <- fetch paragraphCta.landingPageId render EditView { .. } @@ -33,6 +35,7 @@ instance Controller ParagraphCtasController where |> ifValid \case Left paragraphCta -> do landingPages <- query @LandingPage |> fetch + landingPage <- fetch paragraphCta.landingPageId render EditView { .. } Right paragraphCta -> do paragraphCta <- paragraphCta |> updateRecord @@ -46,6 +49,7 @@ instance Controller ParagraphCtasController where |> ifValid \case Left paragraphCta -> do landingPages <- query @LandingPage |> fetch + landingPage <- fetch paragraphCta.landingPageId render NewView { .. } Right paragraphCta -> do paragraphCta <- paragraphCta |> createRecord diff --git a/Web/Controller/ParagraphHeroImages.hs b/Web/Controller/ParagraphHeroImages.hs index 891b9d4..daf2d23 100644 --- a/Web/Controller/ParagraphHeroImages.hs +++ b/Web/Controller/ParagraphHeroImages.hs @@ -12,6 +12,7 @@ instance Controller ParagraphHeroImagesController where |> set #weight weight let formStatus = FormStatusNotSubmitted + landingPage <- fetch paragraphHeroImage.landingPageId render NewView { .. } @@ -19,6 +20,8 @@ instance Controller ParagraphHeroImagesController where paragraphHeroImage <- fetch paragraphHeroImageId -- Get from the session, if the form was submitted successfully. formStatus <- getAndClearFormStatus + landingPage <- fetch paragraphHeroImage.landingPageId + render EditView { .. } action UpdateParagraphHeroImageAction { paragraphHeroImageId } = do @@ -56,6 +59,7 @@ createOrUpdateParagraphHeroImageAction maybeParagraphHeroImageId = do >>= ifValid \case Left paragraphHeroImage -> do setFormStatus FormStatusError + landingPage <- fetch paragraphHeroImage.landingPageId if isJust maybeParagraphHeroImageId then render EditView { .. } else render NewView { .. } diff --git a/Web/Controller/ParagraphQuotes.hs b/Web/Controller/ParagraphQuotes.hs index 688c35a..6ef5017 100644 --- a/Web/Controller/ParagraphQuotes.hs +++ b/Web/Controller/ParagraphQuotes.hs @@ -12,11 +12,13 @@ instance Controller ParagraphQuotesController where |> set #weight weight let formStatus = FormStatusNotSubmitted + landingPage <- fetch paragraphQuote.landingPageId render NewView { .. } action EditParagraphQuoteAction { paragraphQuoteId } = do paragraphQuote <- fetch paragraphQuoteId + landingPage <- fetch paragraphQuote.landingPageId -- Get from the session, if the form was submitted successfully. formStatus <- getAndClearFormStatus render EditView { .. } @@ -57,6 +59,7 @@ createOrUpdateParagraphQuoteAction maybeParagraphQuoteId = do >>= ifValid \case Left paragraphQuote -> do setFormStatus FormStatusError + landingPage <- fetch paragraphQuote.landingPageId if isJust maybeParagraphQuoteId then render EditView { .. } else render NewView { .. } diff --git a/Web/View/ParagraphCtas/Edit.hs b/Web/View/ParagraphCtas/Edit.hs index eaac7ab..ad8b61c 100644 --- a/Web/View/ParagraphCtas/Edit.hs +++ b/Web/View/ParagraphCtas/Edit.hs @@ -7,6 +7,7 @@ import Web.Element.ElementWrap data EditView = EditView { paragraphCta :: ParagraphCta , landingPages :: [LandingPage] + , landingPage :: LandingPage } instance View EditView where @@ -17,7 +18,9 @@ instance View EditView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "Edit Cta" + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "Edit CTA" ] renderForm :: ParagraphCta -> [LandingPage] -> Html diff --git a/Web/View/ParagraphCtas/New.hs b/Web/View/ParagraphCtas/New.hs index 28432f6..95b668d 100644 --- a/Web/View/ParagraphCtas/New.hs +++ b/Web/View/ParagraphCtas/New.hs @@ -6,6 +6,7 @@ import Web.Element.ElementWrap data NewView = NewView { paragraphCta :: ParagraphCta , landingPages :: [LandingPage] + , landingPage :: LandingPage } instance View NewView where @@ -16,7 +17,9 @@ instance View NewView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "New Cta" + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "New CTA" ] renderForm :: ParagraphCta -> [LandingPage] -> Html diff --git a/Web/View/ParagraphHeroImages/Edit.hs b/Web/View/ParagraphHeroImages/Edit.hs index e8f740c..a7c9336 100644 --- a/Web/View/ParagraphHeroImages/Edit.hs +++ b/Web/View/ParagraphHeroImages/Edit.hs @@ -5,6 +5,7 @@ import Web.View.ParagraphHeroImages.Form data EditView = EditView { paragraphHeroImage :: ParagraphHeroImage , formStatus :: FormStatus + , landingPage :: LandingPage } instance View EditView where @@ -15,5 +16,7 @@ instance View EditView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "Edit Hero Image" + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "Edit Hero Image" ] diff --git a/Web/View/ParagraphHeroImages/New.hs b/Web/View/ParagraphHeroImages/New.hs index 95341af..a091623 100644 --- a/Web/View/ParagraphHeroImages/New.hs +++ b/Web/View/ParagraphHeroImages/New.hs @@ -6,6 +6,7 @@ import Web.View.ParagraphHeroImages.Form data NewView = NewView { paragraphHeroImage :: ParagraphHeroImage , formStatus :: FormStatus + , landingPage :: LandingPage } instance View NewView where @@ -16,6 +17,8 @@ instance View NewView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "New Hero Image" + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "New Hero Image" ] diff --git a/Web/View/ParagraphQuotes/Edit.hs b/Web/View/ParagraphQuotes/Edit.hs index 690d85b..6053f5f 100644 --- a/Web/View/ParagraphQuotes/Edit.hs +++ b/Web/View/ParagraphQuotes/Edit.hs @@ -5,6 +5,7 @@ import Web.View.ParagraphQuotes.Form data EditView = EditView { paragraphQuote :: ParagraphQuote , formStatus :: FormStatus + , landingPage :: LandingPage } instance View EditView where @@ -15,5 +16,7 @@ instance View EditView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "Edit Quote" - ] + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "Edit Quote" + ] \ No newline at end of file diff --git a/Web/View/ParagraphQuotes/New.hs b/Web/View/ParagraphQuotes/New.hs index a88907b..0b0ca6a 100644 --- a/Web/View/ParagraphQuotes/New.hs +++ b/Web/View/ParagraphQuotes/New.hs @@ -6,6 +6,7 @@ import Web.View.ParagraphQuotes.Form data NewView = NewView { paragraphQuote :: ParagraphQuote , formStatus :: FormStatus + , landingPage :: LandingPage } instance View NewView where @@ -16,6 +17,8 @@ instance View NewView where |] where breadcrumb = renderBreadcrumb - [ breadcrumbText "New Quote" + [ breadcrumbText "Landing Page" + , breadcrumbLink (cs landingPage.title) (EditLandingPageAction landingPage.id) + , breadcrumbText "New Quote" ]