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

API support for SPA Featured Items #10943

Open
g-saracca opened this issue Oct 21, 2024 · 0 comments · May be fixed by #11124
Open

API support for SPA Featured Items #10943

g-saracca opened this issue Oct 21, 2024 · 0 comments · May be fixed by #11124
Assignees
Labels
Feature: API FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) FY25 Sprint 11 FY25 Sprint 11 (2024-11-20 - 2024-12-04) FY25 Sprint 12 FY25 Sprint 12 (2024-12-04 - 2024-12-18) FY25 Sprint 14 FY25 Sprint 14 (2025-01-02 - 2025-01-15) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 50 Size: 50 A percentage of a sprint. 35 hours. SPA.Q4.5 Collections page with a more Website-like or CMS look and feel SPA These changes are required for the Dataverse SPA Type: Feature a feature request

Comments

@g-saracca
Copy link
Contributor

g-saracca commented Oct 21, 2024

Overview of the Feature Request
As a first iteration of this feature I think we should focus on creating/updating custom featured items and then we could move on to creating featured collections, datasets and files.

We need two API endpoints:

  • To create/update the featured items.

  • To get the featured items of a specific collection.

This could be the model of the objects returned by the endpoint 👇

type FeaturedItem = CustomFeaturedItem | DvObjectFeaturedItem

type CustomFeaturedItem = {
  id: string
  type: 'custom'
  order: number
  title: string
  content: string
  imageUrl?: string
}

type DvObjectFeaturedItem = {
  id: string
  type: DvObjectType // 'collection' | 'dataset' | 'file'
  order: number
  linkUrl: string
  title: string
  description?: string
}

About the create/update I was thinking about something like this, let's say the user adds 3 new featured items, only one contains a file, and one featured item already exists (last one), then from the SPA we would send a FormData doing the following for example:

  const formData = new FormData()

  const items = [
    { type: 'custom', order: 1, title: 'Title 1', content: 'Content 1' },
    { type: 'custom', order: 2, title: 'Title 2', content: 'Content 2', file: file.files[0] },
    { type: 'custom', order: 3, title: 'Title 3', content: 'Content 3' },
    { id: 'some-id', type: 'custom', order: 4, title: 'Title 4', content: 'Content 4' }
  ]

  items.forEach((item, index) => {
    if (item.id) {
      formData.append(`items[${index}][id]`, item.id)
    }
    formData.append(`items[${index}][type]`, item.type)
    formData.append(`items[${index}][order]`, item.order)
    formData.append(`items[${index}][title]`, item.title)
    formData.append(`items[${index}][content]`, item.content)

    if (item.file) {
      formData.append(`items[${index}][file]`, item.file)
    }
  })

Although I have a doubt, how could we handle the cases in which an existing featured item does not modify its image, only its title let's say, in that case what should we send to the endpoint? a property that says keepFile? this boolean could also be useful if the user removed the image.

What kind of user is the feature intended for?
API Users, SPA Users

What inspired the request?
Q4 Roadmap

What existing behavior do you want changed?
None

Any brand new behavior do you want to add to Dataverse?
Add the possibility to create featured items within a collection.

Any open or closed issues related to this feature request?
IQSS/dataverse-frontend#514

@g-saracca g-saracca added Type: Feature a feature request Feature: API SPA These changes are required for the Dataverse SPA GREI Re-arch Issues related to the GREI Dataverse rearchitecture Size: 50 A percentage of a sprint. 35 hours. Original size: 50 SPA.Q4.5 Collections page with a more Website-like or CMS look and feel labels Oct 21, 2024
@GPortas GPortas moved this to SPRINT READY in IQSS Dataverse Project Nov 7, 2024
@GPortas GPortas added the FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) label Nov 7, 2024
@cmbz cmbz added the FY25 Sprint 11 FY25 Sprint 11 (2024-11-20 - 2024-12-04) label Nov 21, 2024
@cmbz cmbz added the FY25 Sprint 12 FY25 Sprint 12 (2024-12-04 - 2024-12-18) label Dec 5, 2024
@GPortas GPortas self-assigned this Dec 12, 2024
@GPortas GPortas moved this from This Sprint 🏃‍♀️ 🏃 to In Progress 💻 in IQSS Dataverse Project Dec 12, 2024
@GPortas GPortas linked a pull request Jan 2, 2025 that will close this issue
@cmbz cmbz added the FY25 Sprint 14 FY25 Sprint 14 (2025-01-02 - 2025-01-15) label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: API FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) FY25 Sprint 11 FY25 Sprint 11 (2024-11-20 - 2024-12-04) FY25 Sprint 12 FY25 Sprint 12 (2024-12-04 - 2024-12-18) FY25 Sprint 14 FY25 Sprint 14 (2025-01-02 - 2025-01-15) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 50 Size: 50 A percentage of a sprint. 35 hours. SPA.Q4.5 Collections page with a more Website-like or CMS look and feel SPA These changes are required for the Dataverse SPA Type: Feature a feature request
Projects
Status: In Progress 💻
Development

Successfully merging a pull request may close this issue.

3 participants