Geeks-Solutions / vue-sections

This npm package provides a VueJS Component to use right off the bat to interface with Sections' server
https://sections.geeks.solutions
2 stars 3 forks source link

Library updates needed after the backend fixes done on media #93

Closed akramsarkis closed 1 year ago

akramsarkis commented 1 year ago

Example

here is an example with the field images declared as an image field in the static section type and containing a list of images: Request body

"options":[{},{},...,
{"images":[{"files":[{"filename":"sections/785338d3d1e6411b93768cf729d0beaf6fa7526dcac548d7b17d43f53cb7eed6.jpg","url":"https://s3.amazonaws.com/eweevtestbucketprivate/sections%2F785338d3d1e6411b93768cf729d0beaf6fa7526dcac548d7b17d43f53cb7eed6.jpg"}],"media_id":"62a725b0605a1d75ca7be83b"},{"files":[{"filename":"sections/1e1fa4b7dc524fb3a879006019bd0225af8e7d0cb0ce4076b774055e51ee99b5.jpg","url":"https://s3.amazonaws.com/eweevtestbucketprivate/sections%2F1e1fa4b7dc524fb3a879006019bd0225af8e7d0cb0ce4076b774055e51ee99b5.jpg"}],"media_id":"62a725b3605a1d75cada799e"}]

will return the following reponse:

{
                    "images": [
                        {
                            "url": "https://s3.amazonaws.com/eweevtestbucketprivate/sections%2F1e1fa4b7dc524fb3a879006019bd0225af8e7d0cb0ce4076b774055e51ee99b5.jpg",
                            "media_id": "62a725b3605a1d75cada799e"
                        },
                        {
                            "url": "https://s3.amazonaws.com/eweevtestbucketprivate/sections%2F785338d3d1e6411b93768cf729d0beaf6fa7526dcac548d7b17d43f53cb7eed6.jpg",
                            "media_id": "62a725b0605a1d75ca7be83b"
                        }
                    ]
                }
mahfouzhseineweev commented 1 year ago

When declaring a static section type, the body should contain information about the fields that will be used inside this section type (https://api.sections-saas.k8s-dev.geeks.solutions/docs/frontend/index.html#creates-a-static-section-type) the image type is important as this is what the backend relies to correctly bind

Currently on a sections project we have a simple field that holds the section type name. So I didn't get this point and regarding this part the body should contain information about the fields that will be used inside this section type, there is no way for a user to know exactly what fields He is going to use in inside a section because most of the time these fields change

When adding a section into a page, the options field can't be a json string but it should be a list of json objects and the image field should be at the root of one of the object in the list. I made an update on the backend for the image field to be a list (so multiple images in one field), but now with the version that is on the test env. only a single image is supported (so the image field should contain only one image).

Isn't it already the case for the options field ? Because adding a section into a page is still working

The image field only need to carry a media_id key with the media id value, any other value will be replaced by the file url of the media coming from the DB.

What image field are we talking about exactly ? In the example there is images field and it is carrying the filename, url and media_id. The only thing that a section on a page cares about is actually the url and nothing else (previously the media_id was also saved in order to delete a current media from AWS when editing the image with a new one). But now the delete management will be on the Media Meta components. So removing an image used in a section should only send an empty url: "" field in order to unlink the media used or update the url: "" field with the media selected from the Media Meta component.

@jfayad We really need to groom this issue to elaborate more on it and to perform the only updates needed

mahfouzhseineweev commented 1 year ago

@akramsarkis For this issue you will have to test:

Note: For this test I have prepared a new section type that you can add on sections website Home page. It is called TitleTextMediaLinkContent and it has media as a field name.

Below are the threads related to the problems I have found while working on this issue:

https://mattermost.gl.eweev.com/eweev/pl/idficn1bgtbqfxepz6h1nz869c

https://mattermost.gl.eweev.com/eweev/pl/n7nn7xp5o3bybg74fkce87gico