Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDFBRA-279 - Add video bundle paragraph #1993

Merged
merged 8 commits into from
Jan 22, 2025

Conversation

Dresse
Copy link
Contributor

@Dresse Dresse commented Jan 21, 2025

Link to issue

https://reload.atlassian.net/browse/DDFBRA-279

Description

This PR adds 2 new paragraphs for use on the GO site:

  1. GO Video Bundle - Automatic --- (go_video_bundle_automatic)
  2. GO Video Bundle - Manual --- (go_video_bundle_manuel)

Both paragraphs will be used to show a Video and display a range of related/recommended materials.
The GO Editor can chose a video and a title to display. The material that is displayed can be added automatically by use of a CQL search string (GO Video Bundle - Automatic). Or can be chosen by the GO Editor by searching for specific materials to show (GO Video Bundle - Manual).

The CQL field and WorkID fields used here, are custom fields that we also use in FB CMS. The fields was not supported in GraphQL by default, so a custom SchemaType and FieldType for each of them has been added to the dpl_graphql module. This also make it possible to implement the "GO Material List - Automatic" and GO Material List - Manual" in the future.

Both paragraphs are added to the Paragraph category "GO Paragraphs" and can be used on the following content types:

  • GO Article
  • GO Category
  • GO Page

The paragraphs has also been enabled in GraphQL Compose.

The PR also comes with minor adjustments to the GO Video paragraph:

  • Renaming the label from "Go video" to "GO Video" to match the other GO paragraphs.
  • Added a new paragraph icon which shows the actual FE design.

Screenshot of the result

"GO Video Bundle - Automatic" paragraph in BE:
Screenshot 2025-01-21 at 03 23 48

"GO Video Bundle - Manual" paragraph in BE:
Screenshot 2025-01-21 at 03 26 02

Additional comments or questions

GraphQL query example for fetching a GO Category containing a "GO Video Bundle - Automatic" paragraph:
Query:

query MyQuery {
  route(path: "go-test-page") {
    ... on RouteInternal {
      __typename
      entity {
        ... on NodeGoCategory {
          id
          paragraphs {
            ... on ParagraphGoVideoBundleAutomatic {
              id
              goVideoTitle
              cqlSearch {
                value
              }
              videoAmountOfMaterials
              url
            }
          }
        }
      }
    }
  }
}

Result:

{
  "data": {
    "route": {
      "__typename": "RouteInternal",
      "entity": {
        "id": "97cf7926-ce65-45be-b6bd-c858335c9d83",
        "paragraphs": [
          {
            "id": "958fd2e2-d147-451a-94af-d62267461cc8",
            "goVideoTitle": "Dette er en Video Bundle Test - Automatic",
            "cqlSearch": {
              "value": "'gardening' AND term.mainlanguage= 'engelsk' AND 'garden' OR 'vegetables' AND term.accesstype='online'"
            },
            "videoAmountOfMaterials": 5,
            "url": "https://media.videotool.dk/?vn=557_2023103014511477700668916683"
          },
          {}
        ]
      }
    }
  }
}

GraphQL query example for fetching a GO Category containing a "GO Video Bundle - Manuel "paragraph:
Query:

query MyQuery {
  route(path: "go-test-page") {
    ... on RouteInternal {
      __typename
      entity {
        ... on NodeGoCategory {
          id
          paragraphs {
            ... on ParagraphGoVideoBundleManuel {
              id
              goVideoTitle
              url
              videoBundleWorkIds {
                material_type
                work_id
              }
            }
            ... on ParagraphGoVideoBundleAutomatic {
              id
              goVideoTitle
              cqlSearch {
                value
              }
              videoAmountOfMaterials
              url
            }
          }
        }
      }
    }
  }
}

Result:

{
  "data": {
    "route": {
      "__typename": "RouteInternal",
      "entity": {
        "id": "97cf7926-ce65-45be-b6bd-c858335c9d83",
        "paragraphs": [
          {},
          {
            "id": "1d0e1d81-cf36-4544-aa8c-2e19e0efcc96",
            "goVideoTitle": "Dette er en Video Bundle Test - Manuel",
            "url": "https://media.videotool.dk/?vn=557_2023103014511477700668916683",
            "videoBundleWorkIds": [
              {
                "material_type": "bog",
                "work_id": "work-of:870970-basis:25197887"
              },
              {
                "material_type": "billedbog",
                "work_id": "work-of:870970-basis:49073399"
              },
              {
                "material_type": "e-bog",
                "work_id": "work-of:870970-basis:07132301"
              }
            ]
          }
        ]
      }
    }
  }
}

… and "Work ID" fields.

This is done by adding a new fieldType and SchemaType for the 2 custom fields in the
"dpl_graphql" module.
and some recommended/related materials.

This can be done in two ways:
- GO Video Bundle - Automatic -- This paragraph lets you input a CQL search string.
- GO Video Bundle - Manuel -- This paragraph lets you search for specific materials to include.

Also updated the existing GO Video paragraph with a capitalized GO in the name and added a new
paragraph icon that matches the GO Video styling.

The new paragraphs has been enabled in GraphQL Compose.
Also fixed the returned array in the "resolveFieldItem" function in ColorItem.php.
Copy link
Collaborator

@spaceo spaceo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
I dont really understand why you talk about excluding paragraphs in fb-cms context. Isn't it just a matter of not attaching the paragraåhs to the field definitions of the content types?

@Dresse
Copy link
Contributor Author

Dresse commented Jan 22, 2025

Looks good! I dont really understand why you talk about excluding paragraphs in fb-cms context. Isn't it just a matter of not attaching the paragraåhs to the field definitions of the content types?

Yes, this is exactly what the exclude list does, just in reverse.

Example:
Go and edit content type "Article", go to "Manage fields" -> Paragraphs.
Here you can decide which paragraphs should be available for choosing. This can be set to be either an include or exclude list.

For the FB-CMS paragraph definitions, its and exclude list (they already have a few paragraphs added here), I just expand the list with the GO Paragraphs, so they are not available.

On GO paragraph field definitions its instead an include list (so I only include the GO Paragraphs).

Hope it makes sense? :)

Its a bit cumbersome to it this way though as you need to remove/add new paragraphs on each content type.

We already are using a module for dividing paragraphs into Paragraph Categories, so it would be nice if we could somehow do the include/exclude on a Paragraph Category level, but this is currently not possible without custom code I think.

@Dresse Dresse merged commit 694c5bd into develop Jan 22, 2025
25 checks passed
@Dresse Dresse deleted the DDFBRA-279-add-video-bundle-paragraph branch January 22, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants